Skip to content

agent-memory: ~/.claude/agent-memory/<agent>/* is user-scope single-file shared across concurrent agent instances → silent overwrites between sessions #810

@michael-wojcik

Description

@michael-wojcik

Symptom

Files under ~/.claude/agent-memory/<agent-name>/ (e.g. pact-secretary/session_processed_tasks.md) are user-scope single-file with no session or team isolation. When two PACT sessions run concurrently — e.g. one secretary on team A working on project X, another secretary on team B working on project Y — both write to the same path with last-writer-wins overwrites.

Observed: a PACT-prompt secretary (team pact-7642b0c9, project actor-discriminator bundle PR #808) overwrote a reflectica/webapp-frontend secretary's (team pact-3655e8cc) session_processed_tasks.md mid-cycle. The reflectica secretary discovered the overwrite during its #31 harvest when its own processed-tasks baseline was unrecognizably replaced with content describing a different project's tasks.

Impact

For the processed-tasks log specifically: the harvest skill's Step 8 says "overwrite, not append" — which is correct WITHIN a session but breaks across concurrent sessions because the dedup baseline gets silently replaced. The reflectica secretary recovered by:

  1. Falling back to the independent dedup signal (session-journal agent_handoff events + own conversation history)
  2. Rewriting the log with team-namespacing to prevent recurrence within the same path

The team-namespaced format groups entries by team_id and is forward-compatible: each concurrent secretary writes under its own team section, no overwrite collision.

For other agent-memory files (feedback memos, MEMORY.md, etc.): the same collision class exists but the symptom is subtler — same-named feedback memos accumulate cross-session learning interleaved without team attribution.

Suggested fix

Two options (either resolves the failure mode):

  1. Session/team isolation: change path from ~/.claude/agent-memory/<agent>/<file> to ~/.claude/agent-memory/<agent>/<team_id>/<file> (or include session_id). Backward-incompatible.

  2. Single-file team-namespacing convention: keep the single-file path but require agents to write entries under team-scoped sections (e.g. ## team=<team_id> headers). The reflectica secretary applied this as a session workaround; promoting to a documented convention prevents recurrence.

(2) is the cheaper fix and doesn't require migrating existing agent-memory content. The PACT secretary skill could be updated to read/write the team-namespaced format with backward-compatible behavior (treat unnamespaced content as legacy/team-unknown).

Cross-references

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions