Repository navigation
fix(memory): flush agent memory into the configured workspace on rooted sessions - #162142
leapdragon wants to merge 1 commit into
Conversation
…ed sessions
Sessions with a session root or spawned workspace run with `workspaceDir`
set to that override, and the pre-compaction memory flush inherited it: the
flush created and guarded `<root>/memory/<date>.md`, the model wrote to the
agent's `memory/<date>.md` as its bootstrap files describe, and every write
was refused ("Memory flush writes are restricted to memory/<date>.md").
Flushes that did land went where the memory index never looks.
Carry the configured workspace on the followup run as
`bootstrapWorkspaceDir` (set only when it differs from `workspaceDir`, the
same split the embedded runner keeps for bootstrap identity) and let the
memory flush target and run in it, so the guarded path is the agent's
memory file.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThe PR carries the configured agent workspace into rooted-session memory flushes and uses it to prepare the daily note and initialize the harness. Review scores
Merge readiness⛔ Blocked before merge - 5 items remain The workspace bug remains on current main, and this PR contains useful work. The prior P1 finding remains unresolved on the unchanged head: file preparation and actual model execution still use different workspaces. Priority: P1 Before merge
Findings
Agent review detailsHow this fits togetherBefore compaction, OpenClaw runs a private maintenance turn over the conversation to save durable notes. Those notes belong in the configured agent workspace, even when the ordinary session executes in a project directory. flowchart TD
A[Rooted session] --> B[Conversation nearing compaction]
C[Configured agent workspace] --> D[Memory flush preparation]
B --> D
D --> E[Private maintenance turn]
E --> F[Restricted append tool]
F --> G[Daily memory note]
Technical reviewBest possible solution: Use one configured workspace for file-based flush preparation, candidate execution and append containment, while retaining the source session's transcript and security policy. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the mismatch for a rooted session whose configured and execution workspaces differ. The canonical report provides a threshold-based Gateway reproduction; no runtime reproduction was executed in this read-only review. Is this the best way to solve the issue? No, the proposed direction is appropriate but incomplete: changing harness preparation does not change the embedded candidate's workspace. The repair must reach the final write boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 888ddd5deab4. Merge-risk optionsMaintainer options:
SecurityNone. EvidenceWhat I checked:
PR surfaceSource +12, Tests +47. Total +59 across 5 files. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 7, 2026, 6:23 PM ET / 22:23 UTC (Revision 2). |
What Problem This Solves
A dashboard session created with a session root (
sessions.createwithroot, or a worktree session) runs withworkspaceDirset to that root:resolveIngressWorkspaceOverrideForSessionRunreturns the managedspawnedCwd, and the whole turn executes there. The pre-compaction memory flush inherited that override, so on such a session it created and guarded<root>/memory/<date>.mdinstead of the agent'smemory/<date>.md.The model, whose bootstrap files (AGENTS.md, MEMORY.md) describe the workspace
memory/directory, wrote there and was refused on every attempt:When the flush did land, it landed in
projects/job-hunter/memory/2026-09-30.md, which the memory index never scans and the next session never loads. Seen on 2026.9.4 with a session rooted at a project subdirectory of the workspace;mainpasses the samerun.workspaceDirto the flush.Why This Change Was Made
Agent memory belongs to the configured workspace:
runEmbeddedAgentalready keeps bootstrap identity there (bootstrapWorkspaceDir: canonicalWorkspaceinrun-orchestrator.ts) while execution stays in the override. The flush is the write side of that same identity, so it should target the same directory.FollowupRun.rungainsbootstrapWorkspaceDir, set inexecutePreparedReplyRunto the configured workspace (context.skillsWorkspaceDir) only when it differs from the run'sworkspaceDir. Runs in the canonical workspace carry nothing new.runMemoryFlushIfNeededresolvesmemoryWorkspaceDir = bootstrapWorkspaceDir ?? workspaceDirand uses it forensureMemoryFlushTargetFileand for the flush run'sharness.workspaceDir. The append-only write guard derives its allowed path from that workspace, so the model'smemory/<date>.md(relative or absolute) now resolves to the agent's memory file. The detached source-transcript view keeps the run'sworkspaceDir.Spawned sessions with their own
spawnedWorkspaceDirget the same treatment: their flush persists into the agent workspace that bootstrap reads, rather than a spawn directory.User Impact
Memory flushes on rooted and worktree sessions write the agent's
memory/<date>.md, wherememory indexand the next session's bootstrap find them. Sessions running in the configured workspace are unchanged.Evidence
agent-runner-memory.test.ts: a flush for a run whoseworkspaceDiris a task subdirectory withbootstrapWorkspaceDirset completes, hands the harness the configured workspace, createsmemory/2023-11-14.mdthere, and creates nomemory/under the task directory.get-reply-run.media-only.test.ts: a session withspawnedCwdcarriesworkspaceDir= cwd andbootstrapWorkspaceDir= configured workspace; a session without an override carries nobootstrapWorkspaceDir.🤖 Generated with Claude Code