Local-first π§ memory for Hermes Agent that lives in your Obsidian vault and remembers project context. Nightly π΄ dream passes turn repeat corrections into confirmed preferences with measurable confidence. Adapters ship for Claude Code, Codex, and OpenClaw, with an MCP server for anything else.
Recon: identity and attribution β who a write says it is, and who may read it
Read-only reconnaissance against feat/a-label-is-not-a-boundary @ 280469d2
(v1.48.0). Covers kanban t_3ebb6e0e (agent identity modes) and t_0c6f31ee
(on_delegation episodic capture). Every claim below carries a file:line
anchor that was opened; three findings were reproduced by execution and say so.
Both task bodies are wrong in the same direction. They assume the missing thing is a way to CARRY identity across a boundary. What is missing is a boundary at all: identity is already carried, freely, by whoever asks.
What exists
The identity path, end to end
Resolution. One function: resolveAgentName(configPath?)
(src/core/config.ts:373-380). Order is VAULT_AGENT_NAME env β config
agent_name / agentName β the literal string "agent". Nothing else resolves
an identity. openclaw/index.js:1683 is a vendored duplicate in the bundled
plugin, not a second source.
Two derivations sit on top:
normalizeAgentArgument(value)(src/core/agent-identity.ts:44-55) strips a leading@, trims, canonicalises_β-, and returnsnullfor anything inPLACEHOLDER_AGENT_VALUES(:19-42) so a model that guessedclaudeorassistantfalls through to the server value.deriveRuntimeAgentName(runtimeId, operatorName)(src/core/agent-identity.ts:84-93) rewritesclaude-vps-agentintoopenclaw-vps-agentfor a non-primary runtime. Callers:src/openclaw/index.ts:58,src/core/install/identity.ts:29,51.
Where it is stamped. Every writer takes the same shape β an optional caller argument, then the resolved server value:
| Surface | Anchor |
|---|---|
| MCP feedback / evidence | src/mcp/brain/feedback-tools.ts:114,368,600 |
| MCP admin | src/mcp/brain/admin-tools.ts:81,234,290 |
| MCP knowledge | src/mcp/brain/knowledge-tools.ts:527,600 |
| MCP write-batch | src/mcp/brain/write-batch-tools.ts:167 |
MCP synthesis (brain_session_checkpoint) |
src/mcp/brain/synthesis-tools.ts:224 |
MCP context (brain_write_session) |
src/mcp/brain/context-tools.ts:80 |
| Core note | src/core/brain/note.ts:64-65 |
| Core decisions | src/core/brain/decisions/record.ts:397-398,476-477,528-529 |
| Core tombstone / temporal-replace | src/core/brain/lifecycle/tombstone.ts:236-237, lifecycle/temporal-replace.ts:218-219 |
| Core tensions | src/core/brain/tensions.ts:375 |
| Core diagnostics | src/core/brain/diagnostics.ts:1166 |
Entity registry (source_agent) |
src/core/brain/entities/registry.ts:504,542 |
| Claude-memory import | src/core/brain/import-claude-memory.ts:250 |
| Session lifecycle hook | hooks/session-capture.ts:51 |
| Shared-namespace mirror | src/core/brain/shared-namespace.ts:50,77 |
| CLI verbs | apply-evidence.ts:29, dream.ts:200, handoff.ts:32, import-session.ts:51, maintenance.ts:166, session-hook.ts:23 |
Where it is read back.
src/core/brain/agent-source/vault-provider.ts:28,117,142-149,169-175β the only reader that turns a storedagentstring into a queryable roster (signals'agent, log entries'agent).src/core/brain/agent-source/registry.ts:39-80folds that intoAgentSourceSummary;query.ts:46-70filters it;diff.ts:38-63is the per-agent viewbrain_agent_diffserves βper_agentcounts,shared_topics,unique_topics,topic_map.src/core/graph/agent-scope.ts:104isOwnerVisible(owner, scope)β the read side, comparing a page'sowner:frontmatter against a requested scope.src/mcp/server.ts:167-169βServerContext.agentName, a getter so a config edit takes effect without a restart, and soConfigReadErrorreaches only the handlers that actually need an identity.src/mcp/server.ts:295-316,433-435β theinitializehandshake renders the identity into the instructions, or renders the reason there is none.templates/identity-reminder.txt:1,.hermes.txt:1,.openclaw.txt:1viabuildReminder(agent, target)(src/core/identity-reminder.ts:134-141).
Per-turn injection. Hermes prefetch (plugins/hermes/provider.py:503-505)
and OpenClaw before_prompt_build (src/openclaw/index.ts:47-59). Claude Code
and Codex get no identity reminder at all β their nudge is
hooks/lib/messages.ts:postWriteReminder, which carries no @agent
(src/core/identity-reminder.ts:12-14, hooks/README.md "What the hooks do").
Hook events: what this repo registers, what the host delivers
hooks/hooks.json registers seven event names: PostToolUse (two matchers:
brain_feedback, Write|Edit|MultiEdit|apply_patch), SessionStart,
UserPromptSubmit, PreToolUse, Stop, SessionEnd, PostCompact. Nine entry
scripts back them (hooks/active-inject.ts, gap-agenda.ts, gap-promote.ts,
nav-inject.ts, post-write-reminder.ts, pretool-orient.ts,
recall-inject.ts, session-capture.ts, stop-log-guardrail.ts).
The host's full event list is
~/.claude/plugins/marketplaces/claude-plugins-official/plugins/plugin-dev/README.md:63:
PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification.
Cross the two lists:
SubagentStopis delivered and not registered. It is the delegation boundary event, and it exists today.~/.claude/cache/changelog.md:1315,1672confirms it is live and carries the same input shape asStop.PreCompactandNotificationare likewise delivered and not registered.PostCompactis registered and is not in the host's list βhooks/README.mdandhooks/lib/context-events.ts:12-19already say so ("current Claude Code has no PostCompact hook event"), keeping the registration as a deliberate no-op.
What a sub-agent leaves behind today (reproduced)
Against a real transcript tree in
~/.claude/projects/-srv-projects-open-second-brain/c67b3203-ea88-4049-9972-12d0a00c0448/:
- Sub-agent turns are written to a separate file,
<parent-session-id>/subagents/agent-<id>.jsonl. The parent transcript contains none of them. - Every line in that file carries
sessionIdequal to the parent's session id, plus its ownagentIdandisSidechain: true. claudeAdapter.detect()returnstrueon it andclaudeAdapter.iterate()yields 85 turns and 25 tool calls (executed).turnFromLine(src/core/brain/sessions/claude.ts:32-82) reads onlytype,uuid,timestamp,messageβ it reads neitheragentIdnorisSidechain. A sub-agent transcript imports as an ordinary session of the parent.importSessionPath(src/core/brain/sessions/import.ts:637-676) walks a directory recursively for*.jsonl, so pointing it at a project directory ingests parent and sub-agent transcripts into one flat stream.- In this harness the delegation tool is named
Agent(21 calls in that transcript), and it is asynchronous: thetool_resultat the call site is"Async agent launched successfullyβ¦ agentId: β¦"(1112 bytes of launch metadata), not the sub-agent's answer. The answer arrives later as a synthetic user turn<task-notification>carrying<task-id>,<tool-use-id>,<output-file>(a path under/tmp/claude-β¦/tasks/),<status>and<summary>.
So the parent transcript alone already holds both halves of the pair, joinable on
tool-use-id: the task (the Agent tool_use input.prompt) and the completion
record (the <task-notification> turn). The full result body lives in a /tmp
file that is not part of the transcript.
Continuity records and the agent field
docs/observability.md:73 (the task body cites :66; the line is 73) says:
"Multi-agent vaults attribute writers via per-agent identity
(brain_agent_query); continuity records do not yet thread parent/child agent
ids". Still true, and understated.
session_turnpayload (src/core/brain/session-recall.ts:350-364) andsession_summary_nodepayload (:400-410) carrysession_id,turn_id,timestamp,role,text, hashes, lineage β and no agent field at all. Not "no parent id": no id.CONTINUITY_AGENT_ID_KEY = "agent_id"exists (src/core/brain/continuity/types.ts:15) and is clip-protected (:38-42), but the only writer isbrain_context_pack_outcome, from a caller argument (src/mcp/brain/recall-tools.ts:760).- The envelope is pinned at eight fields
(
docs/observability.md:32,tests/core/brain/continuity/record-envelope.test.ts), so an agent id can only ride insidepayloadas an additive field β which is exactly whatdocs/observability.md:73already promises. - Session lineage (
src/core/brain/lineage/resolve.ts:1-19) threadsparent_session_id/root_session_id/compression_depth(hooks/lib/stdin.ts:28-30), but the docblock is explicit that this answers "which conversation does this session id belong to" for compression chains. It cannot separate a sub-agent anyway: finding 2 above shows the sub-agent reuses the parent'ssessionId.
Shared-namespace attribution
src/core/brain/shared-namespace.ts mirrors explicit remember-writes into a
second vault named by the shared_namespace config key (:31-35). Attribution
is carried twice: the existing agent field and origin_vault, the basename of
the primary vault (:50, :77). Writers: src/cli/brain/verbs/feedback.ts:97-101
and src/mcp/brain/feedback-tools.ts:59 for signals, src/core/brain/note.ts:75-79
for notes. Self-mirror is refused as "failed" rather than silently duplicated
(:92-94).
What does not exist
- No
on_delegationhook, in any spelling. A repository-wide search fordelegation,on_delegation,subagent,sub-agent,SubagentStop(all file types, excludingnode_modulesanddocs/brainstorm/) returns only docblocks about dispatching work outward βingest/batch-plan.ts:10-11,ingest/checkpoint.ts:172,sync-lockfile.ts:232,health/reconcile.ts:7β and generic "delegates to" prose. Nothing captures a returning sub-agent. - No identity mode switch. No config key, env var, tool argument, or CLI flag
selects between identity behaviours.
resolveAgentNamehas one code path. - No
off. There is no way to suppress identity. The bottom of the chain is the literal string"agent"(src/core/config.ts:379), which is itself inPLACEHOLDER_AGENT_VALUES(src/core/agent-identity.ts:20) β so the "no identity configured" state is a value that every argument-normalising surface rejects, andsrc/openclaw/index.ts:53special-cases by comparing to it. - No
tool_responseconsumer in capture.hooks/lib/stdin.ts:41declares the field and:57maps grok'stoolResponseonto it, butnormalizePayload(src/core/brain/session-lifecycle.ts:528-570) liftstool_nameandtool_inputand nottool_response. The only reader anywhere ishooks/post-write-reminder.ts:100, and it only asks whether the call errored. - No reader for
origin_vault. Grep acrosssrc/,tests/,docs/: it is written atshared-namespace.ts:50,77, persisted into signal frontmatter atsrc/core/brain/signal.ts:403-404, asserted present bytests/core/brain/shared-namespace.test.ts:67,94, and read by nothing. No query filter, no display field, no roster dimension.brain_agent_diffcannot tell a mirrored contribution from a native one. - No credential.
src/core/write-binding/index.ts:12-22states the position in the source: there is no credential in this system to key a fence to, and a caller who can call the tool can name itself anything.initializediscardsclientInfo;handleToolsCallperforms no JSON-schema validation, sorequiredandadditionalProperties: falseare advisory to the model.
Correction to premise (A) β managed / passthrough / off
passthrough is not missing. It is the default, it is unconditional, and it is
the defect.
Enumerated by loading the shipped schemas (executed against
src/mcp/brain-tools.ts, 92 tools, plus search-tools/skill-tools/
schema-tools/watchdog-tools, 12 tools):
- 21 tools accept a caller-supplied
agentand stamp it verbatim onto the record:brain_apply_evidence,brain_dead_ends,brain_decision,brain_delete_by_source,brain_derive_fact,brain_distill_source,brain_dream,brain_feedback,brain_generation_reports,brain_ingest_source,brain_intake_entities,brain_labels,brain_lifecycle,brain_maintenance,brain_note,brain_research_report,brain_secrets,brain_session_checkpoint,brain_tension,brain_truth,brain_write_session. - 12 tools accept a caller-supplied
agent_scope:brain_agent_query,brain_anticipatory_context,brain_brief,brain_context_pack,brain_deep_synthesis,brain_file_context,brain_pre_compress_pack,brain_query,brain_retrieval_plan,brain_search,brain_search_expand,brain_search_by_source.
The only filter on a supplied agent is normalizeAgentArgument
(src/core/agent-identity.ts:44-55), which rejects 22 well-known placeholder
strings and accepts every other string on sight. A sub-agent can already write
under the orchestrator's identity today by passing agent: "<parent-name>". That
is passthrough, shipped, with no switch and no verification. The project has
written the reason down itself: src/mcp/brain/recall-tools.ts:738-750 argues
that "the identity a client asserts is exactly as self-asserted as the one the
config holds".
managed does not exist except in one place. brain_context is the single
surface with no agent argument, so ServerContext.agentName is its only source
of identity (src/mcp/server.ts:151-169, src/mcp/brain/context-tools.ts:388-397).
Everywhere else, the config value is a default, not an owner.
The read side has the same hole, and it is worse because it is sold as
isolation. coerceAgentScope(ctx, args, fallbackToServerIdentity)
(src/mcp/coerce.ts:115-123) returns an explicit argument unconditionally;
the server identity is consulted only when the argument is absent. Six gated
call sites pass true (recall-tools.ts:379, pack-tools.ts:151,567,656,
brief-tools.ts:74,150). resolveOwnerScopeDelivery
(src/core/brain/preferences-collect.ts:171-185) then sets
enforcedScope = requestedScope under owner_scope_delivery: fail β the scope
enforced is the one the caller asked for, never checked against the caller. So
with the isolation gate ON, any caller reads any owner's owner-private
preferences by naming that owner in agent_scope. The label is the boundary.
off has no subject. There is no identity behaviour to disable β no
per-record cost, no per-turn injection on Claude Code / Codex at all. Suppressing
"identity noise in a single-agent vault" would mean not rendering
templates/identity-reminder.txt on Hermes/OpenClaw, which is one string in one
prompt, and the operator already gets that by leaving agent_name unset
(src/openclaw/index.ts:53 returns undefined and injects nothing).
Correction to premise (B) β on_delegation
The validator's finding is confirmed β no hook, no capture β but the framing is wrong on three counts.
"The capture point sits on the HOST runtime's delegation boundary, not inside Open Second Brain." Half right. The host exposes exactly the boundary this repo needs and this repo does not register it:
SubagentStop. It carriessession_idandtranscript_pathlikeStopdoes, and the sub-agent transcript it names is a real file on disk thatclaudeAdapteralready parses (reproduced above: 85 turns, 25 tool calls)."Captures each delegated sub-agent's (task, result) pair." At the delegation tool boundary in this harness there is no result to capture. The
Agenttool is async; itstool_resultis a 1112-byte launch receipt. A hook built onPostToolUse/Agentwould persist a task and a receipt β a capture that captures nothing, which is precisely the do-nothing fallback this repository forbids. The result is recoverable only from (a) the<task-notification>turn later in the parent transcript, or (b) the sub-agent's own transcript file, or (c) the/tmpoutput file, which is ephemeral."Scoped to the PARENT agent's namespace." There is no namespace to scope to.
sessionIdis identical for parent and sub-agent (finding 2), and theagentlabel is a per-adapter constant (see the defect below), so both halves of the intended key are already collapsed before any hook runs.
Does an orchestrator's later turn recall what a dispatched worker found?
No β and the mechanism that would carry it erases the distinction rather than
losing it. Today the only route is o2b brain import-session over the
transcript tree, which flattens sub-agent turns into the parent session id under
the label "claude". brain_session_checkpoint
(src/mcp/brain/synthesis-tools.ts:213-230) and brain_write_session
(src/mcp/brain/context-tools.ts:60-160) are voluntary: the agent must decide to
call them, and a sub-agent that finishes without calling one leaves nothing.
brain_pre_compact_extract (src/mcp/brain/pack-tools.ts:604-620) requires
session_id, turn_start, turn_end and text from the caller β it is a
kernel for text the caller already holds, not a capture.
Smallest native unit per task
For t_3ebb6e0e β the honest unit is a REFUSAL, not a mode
The three-mode vocabulary does not map. passthrough ships as the ungated
default; off has no subject. The one mode that does not exist is managed, and
naming it "a mode" hides that today's behaviour is the unsafe one.
Smallest native unit: a config key that makes the server-resolved identity authoritative, and refuses a conflicting caller-supplied one.
- One key, default off so existing vaults are byte-identical. When on,
normalizeAgentArgument(args.agent)that resolves to something other than the server identity becomes anINVALID_PARAMSerror naming both values, rather than being silently accepted (21 write tools) or silently honoured (12 read tools). - The read side is the load-bearing half: under
owner_scope_delivery: fail,coerceAgentScope(src/mcp/coerce.ts:120-121) must stop letting an explicit argument outrankctx.agentName. Today the isolation gate isolates by self-declaration, which is not isolation. This is a real behaviour change and belongs in the release notes as one. - It changes something observable in both directions, so it is not a mode that changes nothing.
What it does not buy, stated honestly: nothing here authenticates a caller. A
process that can reach the MCP socket can edit agent_name or set
VAULT_AGENT_NAME. The value is that a cooperating multi-agent setup stops
being able to cross the line by accident, and a crossing becomes an error with a
name instead of a record.
For t_0c6f31ee β register the boundary the host already fires
The premise "an on_delegation hook β¦ writes a (task, result) pair" does not
hold as written: the delegation call site has no result. What does hold:
Smallest native unit: a SubagentStop registration in hooks/hooks.json
routing to session-capture, plus the two fields that make a sub-agent
distinguishable.
- Register
SubagentStopinhooks/hooks.jsonalongsideStop, same launcher shape, same fail-soft contract. The event is delivered today and this repo ignores it. - Lift the sub-agent discriminators the transcript already carries into
SessionTurn:agentIdandisSidechaininsrc/core/brain/sessions/claude.ts:32-82, and a corresponding optional field insessions/types.ts. Without this, step 1 records a second session under the parent's id and the boundary is still erased. - Persist the sub-agent's turns as
session_turncontinuity records under a payload that names both ids β the additive-field pathdocs/observability.md:73already commits to, no schema bump. The parent recalls the worker throughsearchSessionRecall(src/core/brain/session-recall.ts:190-200), which is the read surface that already exists.
Bounded and fail-soft come free: armProcessCeiling
(hooks/session-capture.ts:20-37) and the capture boundary
(src/core/brain/session-lifecycle.ts:186-190) already govern every lifecycle
event.
If SubagentStop cannot be relied on across the host matrix, the fallback that
is still honest is the <task-notification> turn in the parent transcript β it
is ordinary transcript text, already parsed into a SessionTurn, and joinable to
the Agent tool_use on tool-use-id. That records the summary and the status,
never the full result, and should say so.
Defects noticed
--agentono2b brain import-sessionis accepted, validated, and discarded.agentLabelForTurn(src/core/brain/sessions/import.ts:601-604) isgetAdapter(adapter).defaultAgent.trim() || fallback. Every shippeddefaultAgentis a non-empty constant, sofallbackβ theopts.agentthatsrc/cli/brain/verbs/import-session.ts:47-51computed from--agentorresolveAgentName(config)β is unreachable. Executed: with--agent claude-vps-agenton a claude transcript the emitted label is"claude". Four call sites are affected (import.ts:427,458,490,520). The docblock at:597-600documents the precedence as intentional; the CLI flag contradicts it, and one of the two is wrong.Three of five session adapters stamp a label that every other surface treats as "no identity". Executed against
src/core/brain/sessions/registry.ts:36-42:normalizeAgentArgument("claude") β null,"codex" β null,"hermes" β null;"opencode"and"grok"survive. So session-imported signals are attributed to a string thatnormalizeAgentArgumentrejects everywhere else, andbrain_agent_queryrosters an agent namedclaudethat no writer could ever have named itself.origin_vaultis write-only. Written atsrc/core/brain/shared-namespace.ts:50,77, persisted atsrc/core/brain/signal.ts:403-404, read by nothing insrc/. The module docblock (:9-10) advertises it as one of two attribution carriers. A contributor field no reader consults is attribution in name only.tool_responseis declared and dropped.hooks/lib/stdin.ts:41and:57carry it tocaptureSessionLifecycleEvent, andnormalizePayload(src/core/brain/session-lifecycle.ts:563-568) liftstool_nameandtool_inputpast it. Any capture of what a tool returned β including the delegation unit above β starts by fixing this line.agentLabelForTurntakes aturnit discards.src/core/brain/sessions/import.ts:602isvoid turn; // reserved for future per-turn role-aware fallback. It is the exact seam where a sub-agent turn would need to be labelled differently, and it is currently a parameter that exists to be ignored.resolveOwnerScopeDeliveryenforces the requested scope, not the caller's.src/core/brain/preferences-collect.ts:182:enforcedScope: mode === GATE_MODE.fail ? requestedScope : null. Combined withsrc/mcp/coerce.ts:120-121, turning the isolation gate on gives a caller the ability to select which owner's private memory it receives. This is the sharpest instance of the release's thesis and the one place where the current behaviour is worse than having no gate, because the gate's presence implies a check that is not performed.