Repository navigation
fix(agents): resolve effective runtime before preflight byte-guard compaction - #115284
Conversation
…mpaction (#108984) Co-authored-by: ATKasem <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 12:17 PM ET / 16:17 UTC. ClawSweeper reviewWhat this changesThis PR resolves the effective follow-up runtime before memory-flush and transcript-byte preflight checks, so CLI backends that own native compaction are not compacted or flushed by embedded-runtime maintenance when model policy routes a turn to them. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 5 items remain Keep this PR open for maintainer review: it targets the live session-continuity defect tracked by #108984, and it carries the protected Likely related people: Priority: P1 Review scores
Verification
How this fits togetherAgent runs can be routed from an embedded-capable provider to a CLI backend through model policy or a persisted runtime selection. Before an agent continues, the memory-maintenance layer may flush or compact the OpenClaw transcript; this change makes that layer defer when the resolved CLI backend owns its native transcript state. flowchart TD
A[Session and follow-up run] --> B[Resolve effective runtime]
C[Model policy and runtime pin] --> B
B --> D{CLI backend owns native compaction?}
D -- Yes --> E[Skip OpenClaw flush and byte compaction]
D -- No --> F[Evaluate transcript byte guard]
F --> G[Embedded compaction or memory flush]
E --> H[CLI backend preserves native transcript]
Decision needed
Why: Both PRs address the same user-visible session-state failure, but selecting one as the landing path and accepting the scope of the new ownership gate requires maintainer intent; the current protected label prevents automated cleanup. Before merge
Agent review detailsSecurityNone. PR surfaceSource -6, Tests +76. Total +70 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one canonical fix for #108984 that resolves the effective runtime once, honors Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction is included in this PR. The supplied regression tests make the policy-routed CLI path source-reproducible, but they do not demonstrate an after-fix real session. Is this the best way to solve the issue? Unclear: resolving the effective runtime and honoring native-compaction ownership is consistent with the reported failure and focused tests, but a direct current-main/source-contract comparison could not be completed after the read-only shell failed before file inspection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8d5a652ed838. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…mpaction (openclaw#108984) (openclaw#115284) Co-authored-by: ATKasem <[email protected]>
What Problem This Solves
Sessions whose provider is embedded-capable (e.g. Anthropic) but whose model policy routes the turn to a CLI backend (claude-cli) were still hit by OpenClaw's preflight byte-guard compaction and memory flush:
followupUsesCliRuntimechecked only the provider string and the persisted session runtime pin, never the effective resolved runtime. OpenClaw maintenance then compacted transcript state the CLI backend owns (#108984). The recently landed retirement oftruncateAfterCompaction(#115206) makes the byte guard armable bymaxActiveTranscriptBytesalone, widening exposure.Closes #108984. Supersedes #109096, whose approach and diagnosis this reimplements on current main with credit to @ATKasem (Co-authored-by on the commit).
Why This Change Was Made
runPreflightCompactionIfNeededandrunMemoryFlushIfNeeded(src/auto-reply/reply/agent-runner-memory.ts) now resolve the effective runtime once viaresolveFollowupAgentRuntimeId(model policy included) and gate on it twice:followupUsesCliRuntimeaccepts the resolved runtime alongside the persisted pin, and a newfollowupOwnsNativeCompactioncheck honorsresolveCliBackendConfig(...).ownsNativeCompactionas defense-in-depth — backends that persist resumable native transcripts stay the sole compaction owner. The oldfollowupUsesCodexRuntimehelper is absorbed into the already-resolved runtime id (one resolution instead of two, net −6 production lines).User Impact
claude-cli-routed sessions (and any CLI backend declaring
ownsNativeCompaction) are no longer compacted or memory-flushed by OpenClaw's embedded maintenance, regardless of how the routing was expressed (provider, persisted pin, or model policy). Embedded sessions keep the byte guard unchanged.Evidence
node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-memory.test.ts— 57 tests passed, including new SQLite-era regressions: policy-routed CLI session withmaxActiveTranscriptBytesset skips the byte guard; genuine embedded session still byte-guards.followupUsesCliRuntimeat the old lines 258-275 never resolving effective runtime; Codex skip already doing so).