镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

feat(agents): keep each agent's core memory in one host-owned cache - #1155

Merged
wpfleger96 merged 9 commits into
mainfrom
duncan/core-memory-cache
Oct 15, 2026
Merged

wpfleger96 merged 9 commits into
mainfrom
duncan/core-memory-cache

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

🤖 Each agent's core memory now lives in one host-owned cache in the agents service, shared by Claude Code, Codex and Goose. The cache is held in memory only, so decrypted memory never reaches web storage or disk. Plugins get it with agents.core(pubkey): it returns the cached copy with no relay request, or waits once (up to 5 seconds) when nothing has been read yet. That wait, and every refresh, reads core alone by its slug (the #d address read from #1200), so the size of the rest of an agent's memory never affects it. No plugin keeps any refresh logic.

Where it lives

  • src/features/agents/core-memory-cache.ts: CoreMemoryCache, one in-memory entry per community and agent.
    • A restart starts empty. The service reads core again when the community connects.
    • A read that started before a newer read or write never overwrites it.
    • A partial listing that misses core never replaces a known copy or declares core missing.
    • Nothing read through a replaced connection is kept.
    • Leaving a community drops its copies and fences reads still under way. A disconnect alone keeps them.
  • src/features/agents/service.ts: Agents.core(), and refreshes when a community connects and when its live socket returns to connected in the same session. These use the service's existing binding subscriptions, so the cache owns no listeners and leaving a community stops its refreshes.
  • src/features/agents/runner.ts: two new RunnerHost callbacks. remembered fires from the agent handle's remember, so a core write is kept at once. finished fires when a run and everything it passed to workingUntil have ended, including watch and timer turns, and refreshes in the background.
  • src/features/communities/device-state.ts: the leave-community purge clears the cache.
  • docs/agent-memories.md: describes when core is read, that the copy lives only in memory, and what leaving a community clears.

Plugins

  • Claude Code and Codex read core through the host call instead of their own relay read at each session or turn start.
  • Goose drops its five-minute copy and the relay read at start. Its memory tools still read the relay directly.

Related: #1185 (the host-owned store for agent instructions and settings, which agent config will use once it lives on the relay)

buzz-review-completed

@wpfleger96
wpfleger96 marked this pull request as ready for review October 15, 2026 14:41
@wpfleger96
wpfleger96 requested a review from a team as a code owner October 15, 2026 14:41
@wpfleger96
wpfleger96 marked this pull request as draft October 15, 2026 14:57
@wpfleger96
wpfleger96 force-pushed the duncan/core-memory-cache branch from 0844afd to 7517482 Compare October 15, 2026 15:09
@wpfleger96 wpfleger96 changed the title feat(agents): cache core memory so starts never wait on the relay feat(agents): keep each agent's core memory in one host-owned cache Oct 15, 2026
@wpfleger96
wpfleger96 force-pushed the duncan/core-memory-cache branch from 301eec6 to e5906e7 Compare October 15, 2026 17:26
@wpfleger96
wpfleger96 force-pushed the duncan/core-memory-cache branch 4 times, most recently from fa4dd21 to 80242f2 Compare October 15, 2026 18:19
@wpfleger96
wpfleger96 marked this pull request as ready for review October 15, 2026 18:25

@kalvinnchau kalvinnchau 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.

🤖 Two findings remain: unencrypted core-memory persistence and contradictory lifetime documentation.

Comment thread docs/agent-memories.md Resolved
@wpfleger96
wpfleger96 force-pushed the duncan/core-memory-cache branch from 80242f2 to b3d3120 Compare October 15, 2026 18:56
@wpfleger96
wpfleger96 marked this pull request as draft October 15, 2026 18:59
@wpfleger96
wpfleger96 force-pushed the duncan/core-memory-cache branch 3 times, most recently from 356f70b to ce878d8 Compare October 15, 2026 19:48
@wpfleger96
wpfleger96 marked this pull request as ready for review October 15, 2026 20:09

@kalvinnchau kalvinnchau 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.

🤖 Approved. Both prior findings are resolved; no new actionable defects found. Native validation remains unverified, and one unchanged test timed out in the full local suite. Recheck reconnect ordering after resolving the merge conflicts.

@wpfleger96
wpfleger96 force-pushed the duncan/core-memory-cache branch from 7986724 to 5a7e595 Compare October 15, 2026 20:40
Duncan added 8 commits October 15, 2026 16:55
Claude Code, Codex and Goose each read core memory from the relay when a
session or turn started, and Goose kept its own five-minute copy. The
agents service now holds one copy per community and agent and keeps it
current on connect, socket recovery, memory writes through the agent
handle, and the end of each run, so plugins read it with `agents.core()`
and no relay request once this device has read it.

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
A start waiting on its first read now answers with what a later write kept. Leaving a community with device-data purge forgets its cached core memory, on disk and in memory, and no held read restores it. The browser fake relay answers the owner's memory read, and its local agent uses a real curve point.

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
The purge test asserted before the held refresh finished, and the rejoin's connection swap discarded the late read on its own, so it passed without the forget() writer fence. refresh() now settles when done so the test awaits it on the same connection. The page-wide cache set holds caches weakly, since nothing tears a cache down.

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
The cache now asks for core alone instead of picking it out of the full listing, which fails once an agent's memory passes the listing caps.

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
Goose no longer reads core itself; the host cache's partial-listing tests cover not treating a partial miss as no core memory.

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
The cache saved each agent's decrypted core memory to localStorage, where anyone reading web storage or its backups could recover it without the owner's key, against the documented RAM-only promise. A restart now starts empty and reads core again on connect.

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
The cache-level privacy tests built the cache without storage, which the old cache also tolerated silently, so they could not catch persistence returning. This drives the service as the app wires it, with working storage.

Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
@wpfleger96
wpfleger96 force-pushed the duncan/core-memory-cache branch from 5a7e595 to b1b6343 Compare October 15, 2026 20:56
@wpfleger96
wpfleger96 merged commit 2bcd187 into main Oct 15, 2026
35 checks passed
@wpfleger96
wpfleger96 deleted the duncan/core-memory-cache branch October 15, 2026 21:10
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.

2 participants