Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 21, 2026, 11:21 PM ET / 03:21 UTC. Summary PR surface: Source +14, Tests +136. Total +150 across 2 files. Reproducibility: yes. Source inspection of current main shows transcript persistence succeeds, compaction is awaited, and final delivery is only reached afterwards; forcing Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one canonical lifecycle-owner fix that preserves generated reply delivery while keeping empty/no-reply compaction failures fatal, then close or supersede the sibling candidates after merge. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection of current main shows transcript persistence succeeds, compaction is awaited, and final delivery is only reached afterwards; forcing Is this the best way to solve the issue? Yes, contingent on maintainer acceptance of the behavior change. Keeping AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a1828110704f. Label changesLabel justifications:
Evidence reviewedPR surface: Source +14, Tests +136. Total +150 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
A CLI-backed turn persists its assistant reply to the live transcript, then runs post-turn compaction. A compaction throw (e.g. 'CLI transcript compaction failed: Summarization failed: Connection error.') escaped to the outer catch, which re-threw before delivery — discarding an already-generated reply and surfacing the turn as unavailable. Guard the post-turn compaction call: when a deliverable reply exists, warn and continue to delivery; otherwise keep the failure fatal so a no-reply turn is not reported as an empty success. Fixes openclaw#94688
c234de2 to
e85004a
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Summary
CLI transcript compaction failed for openai/gpt-5.4: Summarization failed: Connection error.. When that happens the whole turn is surfaced as a post-turn error and channel delivery is skipped, so a user-visible success is turned into a delivery/runtime failure after the fact — the already-generated reply is discarded unless the caller separately salvages it from the transcript.agentCommandInternal(src/agents/agent-command.ts), the post-runtryblock runs three steps in order, all before the outercatchthat re-throws: (1) persist the CLI turn transcript — wrapped in its own best-efforttry/catchthat only warns; (2)runCliTurnCompactionLifecycle— not guarded; itthrows on compaction failure (CLI transcript compaction failed …/CLI native harness compaction failed …); (3) persistpendingFinalDeliveryand calldeliverAgentCommandResult. Because compaction sits before delivery inside the sametry, a compaction throw jumps straight to the outercatch, which callsemitLifecyclePostTurnError(emitting a lifecycleerrorevent with the compaction message) and re-throws. Delivery never runs, and the reply that already exists inresult.payloadsand the transcript is dropped. The transcript-persistence step immediately above is deliberately best-effort, but the compaction step that follows it is not — and post-turn compaction is pure future-turn context maintenance, with no bearing on the validity of the reply just produced. That asymmetry is the bug.runCliTurnCompactionLifecyclecall is wrapped in atry/catchthat, on failure, checks whether the completed run produced deliverable assistant text (result.meta.finalAssistantVisibleTextor a non-error payload with text). If a reply exists, it logs and continues so the reply is delivered (mirroring the transcript-persistence guard directly above). If there is no deliverable reply, the compaction error is re-thrown and stays fatal — a no-reply turn whose only signal is a compaction failure must not be reported as an empty success with an oversized/uncompacted session. On the delivered pathsessionEntrykeeps its pre-compaction value, which is what the lifecycle returns for a no-op anyway. The guard covers throws from every compaction engine (context-engine summarization and native harness).agentCommandInternal), not in the compaction helper.runCliTurnCompactionLifecyclekeeps its honest throw-on-failure contract; the lifecycle owner — which owns turn ordering, the already-generated reply, and delivery — is the right place to decide that post-turn maintenance is non-fatal to delivery of an existing reply while remaining fatal for an empty turn.src/agents/agent-command.ts— wrap the post-turnrunCliTurnCompactionLifecyclecall in atry/catch; warn and proceed to delivery when a deliverable reply exists, otherwise re-throw. A comment records the invariant.src/agents/agent-command.compaction-rotation.test.ts— add two regression tests: (1) a compaction failure after a generated reply still delivers and the turn settles as lifecycleend(nevererror); (2) a compaction failure on a no-reply turn stays fatal and skips delivery.runCliTurnCompactionLifecycleand thecompactCliTranscript/ native-harness paths) is unchanged; it still throws to signal compaction failure. Only the turn-lifecycle owner now treats that failure as non-fatal to delivery.pendingFinalDeliverydurability, delivery, and the rotated-successor session bookkeeping are unchanged.Connection erroror to change retry/rotation behavior; that is upstream/transient and out of scope.docs/reference/config).extensions/*api/runtime-api, registry/loader).Reproduction
openai/gpt-5.4room brain) generates an assistant reply; the reply is written into the live transcript and exists inresult.payloads.Summarization failed: Connection error.), sorunCliTurnCompactionLifecyclethrowsCLI transcript compaction failed for openai/gpt-5.4: ….catch, which emits a lifecycleerrorevent and re-throws;deliverAgentCommandResultnever runs, so the already-generated reply is not delivered and the turn surfaces as unavailable.Real behavior proof
Behavior addressed (#94688): when a CLI-backed turn has already generated and persisted its reply, a subsequent post-turn compaction failure no longer reclassifies the turn as failed/unavailable; the reply is delivered and only compaction is skipped.
Real environment tested (Linux, Node 22 — Vitest against the production
agentCommandInternalpost-run path): the real turn-lifecycle code insrc/agents/agent-command.tsdriving transcript persistence, the post-turn compaction call, anddeliverAgentCommandResult, withrunCliTurnCompactionLifecyclemade to throw the exact reported error and the real delivery ordering exercised.Exact steps or command run after this patch:
pnpm test src/agents/agent-command.compaction-rotation.test.ts;pnpm tsgo:core;oxfmt --writeandnode scripts/run-oxlint.mjson the two changed files.Evidence after fix (Vitest output for the touched test file):
Observed result after fix: with the post-turn compaction lifecycle throwing
CLI transcript compaction failed for openai/gpt-5.5: Summarization failed: Connection error.after a generated reply,agentCommandresolves instead of rejecting,deliverAgentCommandResultis invoked exactly once,deliverySucceeded: true, and the lifecycle settles asend(nevererror). For a turn with no deliverable reply, the same compaction failure is re-thrown:agentCommandrejects and delivery is never called.What was not tested: the live gateway round-trip on the reporter's deployment with a real network
Connection errorduring compaction. The turn-lifecycle ordering, the reply-gated delivery path, and the no-reply fatal path are covered deterministically against the productionagentCommandInternal; an end-to-end gateway repro with a real transient summarization failure was not driven.Repro confirmation: the reply-present test fails on the unpatched tree (
agentCommandrejects with the exact error, delivery never reached) and passes with the fix (delivery reached). The no-reply test fails if the catch is left unconditional (the failure is swallowed into an empty success) and passes with the reply gate (failure stays fatal, no delivery). Both cover the production change.Risk / Mitigation
Post-turn CLI compaction failed … delivering reply without compaction: <error>), and compaction is retried on the next turn; the prior behavior already failed the whole turn instead of compacting, so this strictly improves delivery without removing any compaction that previously succeeded.sessionEntryon failure could skip a needed session-store update. Mitigation: on a compaction throw there is no successful compaction (no rotated session id, no recorded tokens) to persist; the lifecycle would have returned the same pre-compaction entry for a no-op, so no successful state is lost.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Fixes #94688