Repository navigation
Conversation
|
🦞👀 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. |
|
Moving this to draft: CI is red on the change itself, not on infrastructure, and two of the failures show my model of the gate is incomplete. The first is one of the two tests I rewrote. It still returns The second is a test I did not touch. A session entry arrives with eight keys where it expected six, so the flush now runs somewhere it previously did not and mutates session state a neighbouring test depends on. That is real blast radius beyond the two backends this was aimed at, and it is the kind of thing the original exclusion was keeping simple. The live A/B in the description still stands — on a real gateway, lifting the gate does let the flush run on I do not have a local test run for this repo, so iterating here would be guesswork against CI. Leaving it in draft rather than pushing speculative fixes. The evidence and the reproduction in the description are the parts I would keep; #137613 still needs the ownership decision either way. |
|
Codex review: needs real behavior proof before merge. What this changesEnable file-based memory flushes for CLI-backed sessions, re-arm them with persisted transcript-byte checkpoints, and carry restricted write targets through CLI dispatch. Example: A claude-cli conversation crosses the configured flush threshold and later grows by 256 KiB.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain This PR addresses a current CLI memory-flush gap, but the newly enabled dispatch loses source conversation restrictions and still needs an owner decision on recurring maintenance. Priority: P2 Decision needed
Before merge
Findings
Tests
Agent review detailsHow this fits togetherReply maintenance reads session accounting, prepares a detached memory run, and dispatches it through the selected runtime; CLI tools reach filesystem operations through a host-issued loopback MCP grant. flowchart TD
A[Conversation turn] --> B[Preflight maintenance]
B --> C[Flush eligibility and byte checkpoint]
C --> D[Detached memory run]
D --> E[CLI backend dispatch]
E --> F[Loopback MCP grant]
F --> G[Gateway tool policy]
G --> H[Append-only memory writer]
Technical reviewBest possible solution: Keep native compaction ownership, preserve source policy through the existing CLI grant path, and ship recurring flushes only with an accepted cadence and verified persistence behavior. Do we have a high-confidence way to reproduce the issue? Current main explicitly excludes CLI sessions before flush eligibility, and the supplied live comparison supports that path; no target code was executed during this review. Is this the best way to solve the issue? The separate checkpoint and existing append-only writer fit the problem, but enabling CLI dispatch must preserve the source conversation's policy rather than resolving tools under a detached identity alone. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6091f622fe4d. Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: The new maintenance route drops source conversation restrictions before constructing its filesystem tool grant. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +213, Tests +330. Total +543 across 18 files. Added test files: 2. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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:
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 (18 earlier review cycles; latest 8 shown)
Reviewed November 9, 2026, 6:56 PM ET / 23:56 UTC (Revision 19). |
|
Rebuilt against a local checkout, so this is now verified rather than reasoned about. The defect the first cut had. Removing the CLI condition outright let the flush run on sessions with no transcript size, where the compaction watermark is still the only anchor available. Two of my rewritten tests and one I had not touched caught it: The second was The fix. The exclusion now lifts exactly where Tests. Locally, with Three tests encoded the old exclusion and now assert the new contract. Two keep skipping, with names that say why (no transcript anchor). The third asserts the flush runs on the byte guard while compaction ownership stays with the backend — that half is unchanged, and Still the maintainer's call. Those three tests are the current intent, and changing them is the decision this PR is asking for. What has changed is that the shape is now narrow enough to state precisely: the flush becomes available to CLI sessions that have a transcript to anchor on, and to nothing else. |
|
Exact-head proof, replacing the earlier A/B that predated the Built this branch from source and ran real turns against it: Three real {"isCli": true, "transcriptByteSize": 846, "cliRearmBucket": 0,
"storedBucket": null, "storedKind": null, "storedCompactionCount": null,
"cliAlreadyFlushed": false, "forceByBytes": true}
The persisted state afterwards, read back from the session store: That covers the three things the last review asked about:
A completed flush also wrote to Local against this head: The probe was added to the local build only and is not in the diff. Test fixtures written during these runs were removed afterwards. |
Addressed: "Preserve the selected CLI runtime before enabling maintenance" (P1)Fixed in The finding was right, and it invalidates my earlier proof comment. I reported a successful CLI-session flush showing What the passthrough costsPer FixThe flush now opts into Restrictions are preserved, not widenedThe gate requires the run's tool state as a named allowlist. Rather than hand-write a second copy free to drift, this exports the set
Test
Verified the regression actually fails against the unfixed source: Known limitThe gate declines 🤖 Generated with Claude Code |
Also closed: old-entry upgrade coverage for the re-arm bucket
The current normalizer already omits it. What was missing was anything pinning that, so this adds the round trip through Verified it fails against the regression rather than merely passing — defaulting the field to That leaves one open merge-risk I flagged and have not resolved: the 256 KiB re-arm interval is a chosen constant, not a calibrated one. I have no measurement justifying 256 KiB over, say, 128 KiB or 512 KiB — it trades flush frequency against transcript growth between flushes, and I'd rather name that as a reviewer decision than defend a number I picked. Happy to change it or make it configurable if you have a preference. 🤖 Generated with Claude Code |
9abff67 to
bdc08f2
Compare
bdc08f2 to
10cef09
Compare
|
Repair pushed for the CLI memory-flush boundary findings (branch What changed
Evidence (vitest; no live CLI run)
Honest limits: no live restricted CLI run was possible in this sandbox (needs CLI subscription auth/API keys not available here), so the end-to-end "allowed append + rejected write inside one live CLI process" and "same live session suppression, then re-arm after reopening" remain unproven. The boundary is proven at the final tool-construction layer the live path executes. Still needs maintainer decision:
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
CLI backends were excluded from the pre-compaction memory flush because their compaction count never advances: a single flush would lock the compaction-cycle dedup for the rest of the session. Sessions on the claude-cli runtime therefore never saved durable memory before Claude's native auto-compaction. - Run the memory hook from preflight compaction for CLI sessions before returning to native compaction: reply and command turns reach the flush only through that hook, which CLI sessions never called. - Lift the CLI exclusion for file-arm flushes only; provider-owned tool plans and native compaction stay as before. - Re-arm CLI flushes on a transcript-byte window (256 KiB) persisted as memoryFlush.cliRearmBucket. Only a succeeded record suppresses; older rows without a bucket never suppress. - Dispatch the flush through the CLI backend with a read/append-only allowlist, and carry the host-minted memoryFlushWritePath through the CLI dispatch, the loopback grant and gateway tool resolution so the writer stays confined to the prepared target (memory triggers without one still fail closed). - Keep the private flush prompt out of the CLI dispatch transcript. - Move the flush threshold and the CLI byte-window rules into memory-flush-cycle.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
72e1205 to
c5aca63
Compare
|
Rewrote this branch on current Prior findings:
Still open for a maintainer: should CLI-backed sessions get recurring memory flushes, and is the fixed 256 KiB re-arm window acceptable? @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks for the careful work here and in #137613. I'm closing this PR without merging. On On current main ( |
Related: #137613
What Problem This Solves
Fixes: sessions on a CLI backend (for example
claude-cli) never save durable memory before Claude's native auto-compaction, because the pre-compaction memory flush is skipped for CLI runtimes.User Impact
User impact: CLI-backed agents now write their pre-compaction memory notes the same way embedded sessions do, re-arming every 256 KiB of transcript growth. Native compaction stays owned by the backend. Existing sessions need no migration; rows written before this change never suppress a flush.
Why This Change Was Made
Branch rewritten on current
main(the previous head was ~27k commits behind and conflicted with the memory-flush restructure).beforeCompactionhook, and preflight returned before calling it for CLI sessions. CLI sessions now run that hook before returning to native compaction (codex and other non-CLI native owners are unchanged).memoryFlush.cliRearmBucket; only asucceededrecord suppresses.read/writeallowlist, and the host-mintedmemoryFlushWritePathis carried through CLI dispatch → loopback grant → gateway tool resolution, so the writer stays append-only to the prepared target (a memory trigger without one still fails closed). Provider-owned tool plans keep the original skip.memory-flush-cycle.tssoagent-runner-memory.tsdoes not grow past its line cap.Evidence
Live run (OpenClaw 2026.11.2 with the equivalent change applied to the packaged dist,
claude-cliruntime, Claude Code 2.1.296,forceFlushTranscriptBytestemporarily set to 4096 for the run):Before the preflight-hook change, the same three turns produced no
trigger=memoryrun. The flush model chose not to write for that filler transcript, so this run shows the bounded grant but not an actual append; the append-only writer is covered by the existing writer tests.Tests:
agent-runner-memory.cli-flush.test.ts(flush through CLI dispatch with the bounded grant; flush from the preflight hook without compacting — fails without the hook change; same-window suppression; re-arm on a new window; failed records do not suppress),memory-flush-cycle.test.ts, session-shape round trips for the bucket (including bucket-free older rows), CLI dispatch and grant-context forwarding. 48 related test files / 538 tests pass;tsgo:core,tsgo:core:test, oxlint, oxfmt and the line-cap ratchet pass.Limits / decision needed: this still needs the maintainer call from the earlier review — recurring CLI memory maintenance at a fixed 256 KiB re-arm interval. Each re-arm costs one flush turn on the configured memory-flush model.
🤖 Generated with Claude Code