Skip to content

fix(agent): keep replies deliverable when compaction fails - #94854

Closed
extrasmall0 wants to merge 4 commits into
openclaw:mainfrom
extrasmall0:fix/post-success-compaction-delivery
Closed

extrasmall0 wants to merge 4 commits into
openclaw:mainfrom
extrasmall0:fix/post-success-compaction-delivery

Conversation

@extrasmall0

@extrasmall0 extrasmall0 commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • keep post-turn CLI compaction failures from failing the whole turn after the reply transcript was already persisted
  • log the compaction failure and continue into normal delivery
  • add coverage for a persisted CLI reply where compaction throws before delivery

Real behavior proof

Behavior or issue addressed: A CLI-backed turn can persist the assistant reply and then hit a post-turn compaction error. After this patch, that compaction error is logged and delivery still runs instead of surfacing the whole turn as unavailable.

Real environment tested: Local OpenClaw checkout on macOS arm64 with Node v24.13.0, using the patched agent-command.ts and focused agent command test shard.

Exact steps or command run after this patch: node scripts/run-vitest.mjs src/agents/agent-command.live-model-switch.test.ts --maxWorkers=1

Evidence after fix: Terminal capture from the local OpenClaw checkout after applying this patch:

$ node scripts/run-vitest.mjs src/agents/agent-command.live-model-switch.test.ts --maxWorkers=1
[test] starting test/vitest/vitest.agents.config.ts

 RUN  v4.1.7 /Users/little_shuai/.openclaw/agents/coo/workspace/projects/opensource-workshop/repos/openclaw

 Test Files  1 passed (1)
      Tests  59 passed (59)
   Start at  00:28:00
   Duration  8.61s (transform 4.42s, setup 183ms, import 63ms, tests 8.28s, environment 0ms)

[test] passed 1 Vitest shard in 11.03s

Observed result after fix: The focused shard includes the new post-success compaction failure case. It confirms the CLI transcript is persisted, compaction throws Summarization failed: Connection error, deliverAgentCommandResult still runs once, and the lifecycle reaches end instead of rethrowing the compaction error.

What was not tested: I did not stage a live provider/network failure that forces Codex compaction to fail on demand; this proof uses the existing agent command harness to force that post-persistence failure path deterministically.

Testing

  • node scripts/run-vitest.mjs src/agents/agent-command.live-model-switch.test.ts --maxWorkers=1

Fixes #94688

@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: this PR targets a real post-turn compaction delivery bug, but #94928 is the safer open canonical landing path and this branch's custom text-only deliverability gate misses non-text replies.

Canonical path: Land #94928 or an equivalent shared outbound-payload-gated lifecycle fix, then close the overlapping compaction-failure PRs after one canonical fix merges.

So I’m closing this here and keeping the remaining discussion on #94928.

Review details

Best possible solution:

Land #94928 or an equivalent shared outbound-payload-gated lifecycle fix, then close the overlapping compaction-failure PRs after one canonical fix merges.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection gives a high-confidence path: persist a CLI reply transcript, make runCliTurnCompactionLifecycle throw, and current main reaches the post-turn error catch before pending final delivery or deliverAgentCommandResult.

Is this the best way to solve the issue?

No. A lifecycle-owner exception is the right layer, but this branch is not the best fix because it reimplements deliverability as a text-only predicate instead of using the shared outbound payload projection used by #94928.

Security review:

Security review cleared: The diff only changes agent runtime error handling and focused tests; it does not touch dependencies, workflows, secrets, permissions, package metadata, or code download/execution surfaces.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • openperf: Authored the open canonical PR for the same linked issue and has prior merged history in src/agents/agent-command.ts for live model switch and fallback behavior. (role: canonical sibling implementer and prior agent-command contributor; confidence: high; commits: e85004a14428, cda040b4e5f7, 17f086c02180; files: src/agents/agent-command.ts, src/agents/agent-command.compaction-rotation.test.ts, src/agents/agent-command.live-model-switch.test.ts)
  • joshavant: Merged recent work surfacing native Codex compaction failures in the affected compaction helper area. (role: adjacent Codex compaction contributor; confidence: high; commits: b8e9ab9385c0; files: src/agents/command/cli-compaction.ts, extensions/codex/src/app-server/compact.ts)
  • lin-hongkuan: Current-main blame for the affected agent-command.ts, cli-compaction.ts, and outbound payload lines points to a recent area-wide commit. (role: recent area committer; confidence: medium; commits: 67118d5ab912; files: src/agents/agent-command.ts, src/agents/command/cli-compaction.ts, src/infra/outbound/payloads.ts)
  • steipete: Recent history shows work around outbound payload helpers and documentation in the shared deliverability area used by the safer fix shape. (role: adjacent outbound projection contributor; confidence: medium; commits: ffc6bc0be0b2, 1e7510ae103e; files: src/infra/outbound/payloads.ts)

Codex review notes: model internal, reasoning high; reviewed against d1b917120a47.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 19, 2026
@extrasmall0

extrasmall0 commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed the test-types failure in 64c2950.

The test helper now gives the CLI payload fixtures an explicit payload shape, so the empty-result fixture no longer narrows payloads to never[] before the error-only and reasoning-only cases assign their payloads.

Validation:
pnpm check:test-types

@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jun 26, 2026
@steipete steipete closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex/OpenAI fixed session can generate the reply successfully, then fail in post-turn compaction and surface the whole turn as UNAVAILABLE

2 participants