Skip to content

fix: identity system, persistent memory, and VPS redeploy durability#4

Open
jbellsolutions wants to merge 5 commits into
mainfrom
fix/identity-memory-persistence
Open

fix: identity system, persistent memory, and VPS redeploy durability#4
jbellsolutions wants to merge 5 commits into
mainfrom
fix/identity-memory-persistence

Conversation

@jbellsolutions
Copy link
Copy Markdown
Owner

Summary

  • Memory wiring: hermes_self/invoke.py now loads identity from AGENT_IDENTITY env var, injects the system prompt from identities/<name>.yaml, loads conversation history from vault, and writes turns back after each response
  • /identity command: Telegram users can switch agent personas mid-conversation without redeploying
  • Memory persistence across redeploys: scripts/start.sh enables memory_enabled/user_profile_enabled in the Hermes profile config and seeds MEMORY.md/USER.md from config/memories/ on first boot (no-clobber — live edits survive)
  • Docs: QUICKSTART and SETUP updated with persona/identity system documentation

Why

The Hermes gateway was amnesiac — it re-explained already-decided architecture (SDR fleet design, delegate_task limits, subordinate agent patterns) every session because:

  1. invoke.py never passed a system prompt or history to the LLM
  2. memory_enabled defaults to false in Hermes profiles
  3. The memories directory was empty on fresh deploys

Files changed

File Change
src/agent_os/runtimes/hermes_self/invoke.py Identity + history loading + vault writes
src/agent_os/orchestrator/adapters/vault_memory.py Added parse_history()
src/agent_os/channels/telegram/bot.py Pass user_id in Job metadata
src/agent_os/orchestrator/adapters/plan_overrides.py /identity command parsing
scripts/start.sh Memory config + seed file bootstrap
config/memories/MEMORY.md Seed: architectural decisions
config/memories/USER.md Seed: user preferences
QUICKSTART.md, SETUP.md Persona system docs

Test plan

  • Fresh VPS deploy: ./scripts/start.sh creates memories/MEMORY.md and memories/USER.md
  • Re-run on existing VPS: existing memory files NOT overwritten
  • Telegram: send /identity → lists personas; /identity coo → switches to COO
  • Telegram: send message, restart, ask "what did we talk about?" → agent recalls prior turns
  • Agent does not re-explain SDR fleet architecture that's already in MEMORY.md

🤖 Generated with Claude Code

Justin Bellware and others added 5 commits May 21, 2026 16:51
The agent had no system prompt and no conversation history — every turn
started cold. Three missing wire-ups fixed:

1. vault_memory.py — add parse_history() to convert the markdown log
   back to OpenAI-style messages list so runtimes can pass it to LLMs.

2. hermes_self/invoke.py — load supersan.yaml system_prompt (cached),
   load per-user vault history, pass both to every LLM call, then
   write the turn back to vault so the next session can recall it.

3. bot.py — pass metadata={"user_id": str(chat_id)} on the Job so
   invoke.py knows which conversation file to open/append.

Also: fix pyproject.toml missing pythonpath=["src"] so uv run pytest
works without PYTHONPATH override; clean 4 pre-existing ruff warnings
in bot.py (unused import, unsorted imports, asyncio.TimeoutError).

All 19 tests pass (11 unit + 8 smoke).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each deployed agent now sets AGENT_IDENTITY=<name> and gets its own
system prompt loaded from orchestrator/config/identities/<name>.yaml.

Supported names: supersan, coo, gtm, head_of_ops (one YAML per agent).

Per-job override also works: job.metadata["identity"] = "coo" lets the
orchestrator pin an identity at dispatch time without relying on env var.

Prompts are cached per identity name so the YAML is only read once.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Send /identity to list available personas and the current one.
Send /identity <name> to switch (e.g. /identity coo, /identity video_agent).

The selected persona is stored per chat_id and passed as
job.metadata["identity"] on every subsequent message, which causes
hermes_self to load that agent's system_prompt from its YAML file.

Adding a new agent persona is now: create the YAML, send /identity <name>.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… SETUP

QUICKSTART gets a new Step 5 covering /identity in plain English:
what it does, how to switch, how to create a new persona from a YAML
file, and how to set AGENT_IDENTITY as the deployment default.

SETUP gets a dedicated "Agent personas" section up front explaining
how the system works, the four built-in personas, how to switch via
Telegram, how to set a default per service, and a full walkthrough
for creating a new persona from scratch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
start.sh now enables memory_enabled + user_profile_enabled in the
profile config on every deploy, and seeds MEMORY.md / USER.md from
config/memories/ on first boot (no-clobber so live edits survive).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant