Skip to content

✨ agents: CLI auto-memory off by default; clear_memory_on_kick wipes per-agent memory before each kick - #17055

Closed
clubanderson wants to merge 2 commits into
fix/agent-memory-isolationfrom
feat/agent-cli-memory-config
Closed

clubanderson wants to merge 2 commits into
fix/agent-memory-isolationfrom
feat/agent-cli-memory-config

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #17032

Stacked on #17039 (fix/agent-memory-isolation) — it relies on the per-agent ~/.claude / ~/.gemini / ~/.copilot homes introduced there. Base is that branch; retarget to v5 once #17039 merges. Only the last commit is this PR's.

Why

Even with per-agent homes (#17039), each subscription CLI keeps a hidden long-lived notebook (Claude auto-memory MEMORY.md, Codex memories/, Copilot memory) that accumulates stale one-off inferences and survives every /clear — clear_on_kick only resets the conversation. Hive agents get durable context from beads/knowledge/kick prompt, so the default should be off, with an opt-in and a per-kick wipe.

Config

agents:
  cli_memory:
    auto_memory: false     # default false
    clear_on_kick: false   # default false
  scanner:
    cli_memory: { auto_memory: true }   # per-agent override

CLIMemoryConfig (crux/config/cli_memory.go), stamped onto each agent like session_recycle; AutoMemoryEnabled() is nil-safe (default false). Settings-parity leaves + dashboard allowlist updated.

Exact vendor switches (seeded only when auto_memory is false; true pins the opposite so an operator's own setting is never shadowed)

CLI Switch Source
Claude Code CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 in the agent env (per-process → per-agent override works) https://code.claude.com/docs/en/memory
Codex [features] memories = false merged into $CODEX_HOME/config.toml (codexConfigSeed, alongside the update-check pin) https://developers.openai.com/codex/memories , https://developers.openai.com/codex/config-reference
Copilot CLI "memory": false in the per-agent ~/.copilot/settings.json (the key `/memory on off` writes)
Gemini CLI no auto-memory feature; nothing to pin —

clear_on_kick

manager_kick.go: before every non-resume kick, right before the /clear block, clearCLIMemoryForKick removes this agent's ~/.claude/projects/*/memory/, $CODEX_HOME/memories*/, ~/.gemini/GEMINI.md (RemoveAll, su-exec rm -rf fallback on EPERM). Skipped for uid 0 / HIVE_SHARED_AGENT_HOME=1 (would touch the shared tree). Copilot memory is server-side — no local store.

Tests (-race, no sleeps)

  • crux/agent/cli_memory_test.go: env pin default + opt-in; Codex TOML merge cases incl. existing [features] table and codexConfigSeed(nil,false); Copilot settings seed + owns-the-key; kick wipe removes only this agent's stores and leaves the sibling/shared trees; off-by-default and shared-home skip.
  • pkg/config/cli_memory_test.go: YAML parse, defaults, per-agent override stamping.
  • internal/settingsparity leaves; manager_test.go env-count adjusted for the Claude pin.

Docs: docs/agent-configuration.md — cli_memory in the per-agent YAML example and a new "CLI auto-memory (agents.cli_memory)" section with the table above. Changelog changelog.d/added-agent-cli-memory-config.md.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 7, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hanthor for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: fix/agent-memory-isolation

Conflicts are checked with every PR merged onto the current tip of fix/agent-memory-isolation, so a PR that only needs a rebase is not reported as conflicting with its siblings.

No conflicting open PRs or same-file overlaps were found.

@clubanderson
clubanderson force-pushed the feat/agent-cli-memory-config branch from 6f649b1 to c5231e0 Compare November 7, 2026 18:45
…per-agent memory before each kick

Adds agents.cli_memory {auto_memory, clear_on_kick} with per-agent override,
seeds the vendor off-switches (Claude env var, Codex [features] memories,
Copilot settings.json memory) and removes the agent's own memory stores next
to the /clear kick when clear_on_kick is set.

Fixes #17032

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
… cli_memory in agent-knowledge-and-memory.md

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the feat/agent-cli-memory-config branch from c5231e0 to 0940aab Compare November 7, 2026 18:55
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • check-failure

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision needed: @clubanderson should decide whether this PR or #17040 lands for #17032 — both add the same agents.cli_memory.{auto_memory,clear_on_kick} keys with different mechanisms, so only one can merge; this one also needs its base retargeted to v5 now that #17039 (943d807) merged.

Two things block this independently of the code.

  1. Base branch. #17039 merged to v5 as 943d807, so fix/agent-memory-isolation is gone as a target and this PR shows CONFLICTING. Retargeting to v5 should leave only the last commit, as the body says.

  2. Conflict with #17040 (Karibhou), which implements the same issue. Both add agents.cli_memory with auto_memory / clear_on_kick, a new src/crux/agent/cli_memory.go and src/crux/config/cli_memory.go, parity leaves and the dashboard allowlist entry. I read both diffs in full. Same intent and config shape, different code — so they cannot both merge. The substantive differences:

#17055 (this) #17040
Config type AutoMemory *bool (src/crux/config/cli_memory.go:23), nil inherits fleet AutoMemory bool (:19)
Claude disable CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 in the launch env (src/crux/agent/cli_memory.go:34) merge-only "autoMemoryEnabled": false in settings.json (:31)
Codex pins memories = <policy>, overwriting an existing operator line (:68) adds memories = false only when the operator wrote nothing (:89)
Copilot CLI overwrites memory in per-agent ~/.copilot/settings.json (:136) nothing seeded
Store discovery perAgentCLIHomes specs from #17039 (:176) Lstat symlink-bridge walk (:213)

One thing a maintainer should weigh: this PR's Codex and Copilot seeds overwrite an operator's own value (by design, :145 "OVERWRITES the key"), while #17040 and the rest of hive's seeds are merge-only. That is a deliberate policy difference, not a bug, but it is the kind of behaviour the issue did not specify.

I have not closed anything. I posted the same comparison on #17040.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant