Repository navigation
fix(agents): retain internal session writer fence - #169876
ethanhawkes-gif wants to merge 2 commits into
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. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR retains the admitted session writer fence in ambient context and inherits it when persisting a settled-turn fallback. Example: The internal-session fixture uses runId skill-workshop-review:internal-fallback-success and removes the explicit finalization fence.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this PR contains distinct writer-custody work and has an unresolved same-author companion PR; no definite introduced correctness defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe embedded runner coordinates admitted session writers, provider attempts, and post-tool finalization; fallback text passes through the transcript accessor into SQLite. flowchart TD
A[Run admission] --> B[Session writer claim]
B --> C[Session prompt state]
C --> D[Attempt dispatch]
D --> E[Settled turn finalization]
C --> E
E --> F[Transcript append owner]
F --> G[SQLite transcript]
Technical reviewBest possible solution: Preserve the original writer through a reproduced failing production turn while retaining exact-session matching and live-admission checks. Do we have a high-confidence way to reproduce the issue? No high-confidence production reproduction is established: current main explicitly propagates the fence, while the added fixture removes it before calling finalization. Is this the best way to solve the issue? Using the existing transcript owner is appropriately narrow, but the evidence does not establish that additional ambient propagation fixes the linked CLI failure. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b4c87c27b3bf. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Ambient writer authority changes require final-effect validation, although source inspection found no concrete authorization bypass. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +24, Tests +265. Total +289 across 3 files. Added test files: 0. View PR surface stats
Review metrics
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 13, 2026, 2:17 PM ET / 18:17 UTC (Revision 2). |
8791144 to
8331892
Compare
Summary
OpenClaw internal-session and CLI-backed turns that reach settled-turn fallback can currently lose the transcript after otherwise successful tool work, forcing fallback or retry. This server-side change requires no client update and adds only scoped context propagation; it does not add a new write or retry path.
Implementation:
src/agents/embedded-agent-runner/run/session-prompt-state.ts: retains the admitted session writer fence during post-attempt transcript worksrc/agents/embedded-agent-runner/run/settled-turn-finalization.ts: re-inherits that fence after fallback target resolution and preserves fail-closed rejection when the writer is genuinely replacedsrc/agents/internal-session-effects.test.ts: adds paired persistence and genuine-replacement rejection coverageWhat Problem This Solves
Internal-session admission can establish a committed writer fence (the lifecycle/run identity allowed to persist that session), but
withSessionWriterContextdid not keep that durable fence ambient for post-attempt work (session-prompt-state.ts:210).persistSettledToolFallbackTranscriptmay then resolve a fresh target without the admitted fence (settled-turn-finalization.ts:582-617) and reopen persistence as an unfenced writer. That produces a falseSessionTranscriptWriterClaimReboundErroreven though the admitted writer was not replaced.Evidence
After rebasing onto current
upstream/main:npx vitest run src/agents/internal-session-effects.test.tsThe SQLite-backed pair covers successful settled-turn fallback persistence and cleanup, plus rejection after a genuine writer replacement.
pnpm exec oxlint src/agents/embedded-agent-runner/run/session-prompt-state.ts src/agents/embedded-agent-runner/run/settled-turn-finalization.ts src/agents/internal-session-effects.test.tsFixes #164215