Skip to content

fix(agents): recover from invalid compaction summaries - #119137

Merged
vincentkoc merged 1 commit into
mainfrom
qa-b3-compaction-output-recovery-20260804
Aug 4, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
qa-b3-compaction-output-recovery-20260804

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Parent coverage work: #119033

What Problem This Solves

Fixes an issue where automatic context recovery could accept an empty,
whitespace-only, or reasoning-only compaction summary. In the embedded default
runtime, the caller-owned recovery path also invoked public manual compaction,
so it did not use the bounded invalid-summary retry already expected by
automatic recovery.

Branch summarization had the same invalid-output acceptance bug and could begin
navigation mutation without a usable summary.

Why This Change Was Made

The shared compaction producer now returns a typed
InvalidSummaryOutputError when the model returns no usable summary text.
Branch summarization validates the same invariant before mutating navigation
state.

Automatic session compaction owns exactly one retry for that typed error. A
private internal session entrypoint carries the same policy into caller-owned
default overflow, budget, and timeout recovery without rerunning hooks, locks,
preflight, lifecycle, or persistence. Public/manual compaction remains
one-shot. Provider errors, extension-owned compaction, and safeguard policy are
unchanged.

The two QA scenarios exercise the real built embedded runtime and retain sole
primary ownership of:

  • session-memory.compaction-empty-response-recovery
  • session-memory.compaction-reasoning-only-recovery

User Impact

Default automatic recovery now retries one unusable summary and continues with
durable compacted context. If the second summary is still invalid, recovery
fails visibly without persisting a compaction. Manual compaction and unrelated
provider failures keep their existing behavior.

Release-note context: automatic compaction now recovers from one empty or
reasoning-only summary. No CHANGELOG.md change is included.

Evidence

Exact signed head: 688b35ebd02587b05cd4ca1ea3fa5271d8338256

  • Focused Vitest: 10 files, 499 tests passed.
  • Supported changed gate passed under Node v26.4.0, including typecheck,
    lint, API-surface, dead-export, and import-cycle checks.
  • Targeted formatting and git diff --check passed.
  • OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build passed.
  • Built dist/index.js QA passed 2/2:
    • compaction-empty-response-recovery
    • compaction-reasoning-only-recovery
  • Each scenario recorded two ordered summary requests, one persisted
    compaction, and one persisted final answer.
  • Exact QA evidence records the signed head and one unique primary owner for
    each accepted coverage ID.
  • Fresh Sol/high exact-head review reported no actionable findings and judged
    the owner-boundary fix ready to publish.
  • TruffleHog, signature, privacy, and YAML catalog checks passed.

Retained artifacts:
.artifacts/qa-b3-compaction-output-recovery-688b35ebd02-20260804/

Scope And Drift

  • Whole PR product/runtime delta: +96/-29.
  • Whole PR test/QA delta: +1297/-40.
  • Final owner-boundary repair delta: product +30/-5, test/harness
    +133/-89.
  • No public API, plugin SDK, config, protocol, SQLite schema, or compatibility
    surface was added.
  • Current main at publication is
    c3f148f6b772bc96d24c5619bf9f78f80733a67c.
  • The only overlapping path is a test harness where current main removed
    obsolete plugin-metadata mocks and this branch adds compaction-route mocks.
    The changes are independent, and git merge-tree --write-tree origin/main HEAD completed without conflict.

The prior d85722b30cb2e4325a3f2f65aae34ef6447c00e9 proof is superseded by the
exact-head evidence above.

@vincentkoc vincentkoc self-assigned this Aug 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: qa-lab size: L maintainer Maintainer-authored PR labels Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 7:35 AM ET / 11:35 UTC.

ClawSweeper review

What this changes

The PR rejects empty, whitespace-only, and reasoning-only compaction summaries, retries one invalid automatic summary, and adds regression plus built-runtime QA coverage.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The prior P1 blocker is resolved at the updated head: invalid summaries are rejected before persistence, and caller-owned default recovery now reaches the bounded automatic retry. No new blocking defect was found; this maintainer-authored, protected PR should remain open for normal exact-head review.

Priority: P1
Reviewed head: 688b35ebd02587b05cd4ca1ea3fa5271d8338256

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repaired lifecycle boundary and broad focused coverage are coherent, with body-recorded built-runtime evidence supporting normal merge-quality confidence.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate; its body records exact-head built-runtime QA, though the retained artifact was not available for independent inspection.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate; its body records exact-head built-runtime QA, though the retained artifact was not available for independent inspection.
Evidence reviewed 6 items Current-main defect: Current main accepts an empty joined text result as a successful compaction summary.
Exact-head owner-boundary repair: The PR routes default non-manual embedded recovery to the private automatic entrypoint, whose core path retries only InvalidSummaryOutputError once before any compaction append.
Regression coverage: Exact-head tests cover automatic recovery, caller-owned recovery, manual one-shot behavior, terminal second-invalid behavior, cancellation, provider errors, and embedded overflow/budget/timeout routing.
Findings None None.
Security None None.

How this fits together

Agent sessions compact older context after overflow or budget pressure, persist the resulting summary, and then resume the agent run. The embedded runner selects the compaction entrypoint, while the session owner controls persistence and retry policy.

flowchart LR
A[Context overflow or budget trigger] --> B[Embedded session runner]
B --> C[Automatic compaction owner]
C --> D[Model summary response]
D --> E{Usable visible text?}
E -->|No, first attempt| F[One bounded retry]
F --> D
E -->|Yes| G[Persist compacted context]
G --> H[Resume agent run]
Loading

Before merge

  • Complete next step (P2) - No mechanical repair remains; this protected maintainer PR awaits routine exact-head review.
Agent review details

Security

None.

PR surface

Source +201, Tests +813, Other +310. Total +1324 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 10 235 34 +201
Tests 10 848 35 +813
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 310 0 +310
Total 22 1393 69 +1324

Review metrics

Metric Value Why it matters
Production versus test/QA delta production +96/-29; tests/QA +1297/-40 The production growth establishes the bounded retry owner boundary; most added code is targeted regression and built-runtime QA proof.

Stored data model

Persistent data-model change detected: serialized state: extensions/qa-lab/src/providers/mock-openai/mock-openai-responses-websocket.test.ts, serialized state: extensions/qa-lab/src/scenario-catalog-compaction.test.ts, serialized state: extensions/qa-lab/src/suite-runtime-agent-session.test.ts, serialized state: qa/scenarios/runtime/compaction-empty-response-recovery.yaml, serialized state: qa/scenarios/runtime/compaction-reasoning-only-recovery.yaml, serialized state: src/agents/sessions/agent-session-compaction.ts, and 5 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Merge the exact-head owner-boundary repair after normal maintainer review, retaining shared producer validation, the one automatic retry, and both built-runtime QA scenarios.

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

Yes—source provides a high-confidence built-runtime path: force an overflow, return one invalid summary, and assert the second summary plus persisted final response; it was not executed in this read-only review.

Is this the best way to solve the issue?

Yes. Validating at the shared producer and applying one retry only at the automatic session owner avoids persisting bad state while preserving manual and provider-error behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate; its body records exact-head built-runtime QA, though the retained artifact was not available for independent inspection.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 availability: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Automatic default-path context recovery can otherwise persist unusable context and interrupt an active agent workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate; its body records exact-head built-runtime QA, though the retained artifact was not available for independent inspection.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Current producer and embedded caller lines trace to this contributor's recent merged compaction work, and the exact head continues that owner-boundary repair. (role: recent area contributor; confidence: high; commits: d8caec4de5cc, 688b35ebd025; files: packages/agent-core/src/harness/compaction/compaction.ts, src/agents/embedded-agent-runner/compaction-session-execution.ts, src/agents/sessions/agent-session-compaction.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-04T07:07:53.105Z sha 5e9e3a9 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T08:02:55.203Z sha 8972341 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T08:15:09.817Z sha 8972341 :: found issues before merge. :: [P1] Retry rejected summaries on the default compaction path
  • reviewed 2026-08-04T08:30:56.532Z sha d85722b :: found issues before merge. :: [P1] Retry rejected summaries on the default compaction path
  • reviewed 2026-08-04T09:40:18.341Z sha d85722b :: found issues before merge. :: [P1] Retry rejected summaries on the default compaction path

@vincentkoc
vincentkoc force-pushed the qa-b3-compaction-output-recovery-20260804 branch from 5e9e3a9 to 8972341 Compare August 4, 2026 07:55
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 4, 2026
@vincentkoc
vincentkoc force-pushed the qa-b3-compaction-output-recovery-20260804 branch from 8972341 to d85722b Compare August 4, 2026 08:24
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 4, 2026
@vincentkoc
vincentkoc force-pushed the qa-b3-compaction-output-recovery-20260804 branch from d85722b to 688b35e Compare August 4, 2026 11:27
@vincentkoc
vincentkoc marked this pull request as ready for review August 4, 2026 11:29
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer disposition for exact signed head
688b35ebd02587b05cd4ca1ea3fa5271d8338256:

  • ClawSweeper's prior default-path P1 is resolved. Its current exact-head
    review reports no finding; the remaining P2 was routine maintainer review,
    completed with the repo-native review artifact.
  • Focused proof passed 499 tests. The supported changed gate, private-QA
    build, targeted formatting, dead-export, import-cycle, signature, privacy,
    and TruffleHog checks passed.
  • Built dist/index.js QA passed both recovery scenarios. Each recorded two
    ordered summary requests, one persisted compaction, and one final answer.
  • Required exact-head openclaw/ci-gate passed.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 119137 completed with unchanged
    prepared and remote heads and reused the passing hosted exact-head gates.
  • Current main is
    2a3a840aaf80dab40b0ba2bf9a02a5e2f5cc5015. The only overlapping path is a
    test harness: main removes obsolete plugin-metadata mocks while this PR adds
    compaction-route mocks. The edits are independent and merge-tree is clean,
    so preserving the reviewed signed head is preferable to a proof-invalidating
    rebase.
  • The automated stored-data-model metric is not a migration concern here:
    there is no SQLite, config, protocol, or persisted schema change.

All listed before-merge work is satisfied. Proceeding through the repo-native
squash path.

@vincentkoc
vincentkoc merged commit 6d88ec5 into main Aug 4, 2026
193 of 199 checks passed
@vincentkoc
vincentkoc deleted the qa-b3-compaction-output-recovery-20260804 branch August 4, 2026 11:43
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 4, 2026
…checkpoint

* origin/main: (46 commits)
  fix(agents): recover from invalid compaction summaries (#119137)
  fix(gateway): expose OAuth-backed tools to CLI agents (#119166)
  fix(plugins): preserve metadata reloads during models status (#119183)
  fix(test): bound direct gateway server runs (#119184)
  test(tui): prove command surfaces through PTY (#119165)
  fix(testbox): restore claims across path aliases (#119170)
  fix(message): preserve sends with incidental Telegram locations
  fix(perf): give each concurrency sample a full deadline (#119164)
  fix(testbox): remove changed-gate sync residue (#119163)
  fix(telegram): preserve later chunks after rejected sends
  fix(tui): block terminal controls in system messages (#118998)
  fix(auto-reply): suppress false no-reply fallback during continuations (#119154)
  fix(scripts): prevent gateway benchmarks from stalling on probes (#119063)
  test(channels): verify built sanitizer semantics (#119151)
  fix: prevent live updater from leaving Gateway offline indefinitely (#119116)
  test(qa): restore memory tools primary ownership (#119142)
  fix(agents): settle yielded fanout at harness boundary (#118703)
  fix(codex): cap compaction override warning cache via createDedupeCache (#101745)
  fix(daemon): skip unlabeled launchd plists (#119091)
  test(qa): repair QA catalog integrity (#119140)
  ...
vincentkoc added a commit that referenced this pull request Aug 4, 2026
…tial-gate

* origin/main:
  fix(agents): recover from invalid compaction summaries (#119137)
vincentkoc added a commit that referenced this pull request Aug 4, 2026
* origin/main: (208 commits)
  fix(telegram): route reactions to their originating forum topics
  test(gateway): isolate scheduled service timers (#119218)
  test(qa): cover Canvas agent and node controls (#119047)
  fix(cli): avoid repeated migration scans during local agent turns (#119051)
  fix(gateway): keep agents list on prepared model facts (#119208)
  fix(telegram): retry update offset persistence
  fix(ci): accept profiled partial Kova gates (#119121)
  fix(qqbot): keep channel API calls on the active account [AI] (#118575)
  fix(agents): recover from invalid compaction summaries (#119137)
  fix(gateway): expose OAuth-backed tools to CLI agents (#119166)
  fix(plugins): preserve metadata reloads during models status (#119183)
  fix(test): bound direct gateway server runs (#119184)
  test(tui): prove command surfaces through PTY (#119165)
  fix(testbox): restore claims across path aliases (#119170)
  fix(message): preserve sends with incidental Telegram locations
  fix(perf): give each concurrency sample a full deadline (#119164)
  fix(testbox): remove changed-gate sync residue (#119163)
  fix(telegram): preserve later chunks after rejected sends
  fix(tui): block terminal controls in system messages (#118998)
  fix(auto-reply): suppress false no-reply fallback during continuations (#119154)
  ...
vincentkoc added a commit that referenced this pull request Aug 4, 2026
* origin/main: (23 commits)
  chore(tui): add Gateway boundary PTY coverage (#119191)
  fix(telegram): route reactions to their originating forum topics
  test(gateway): isolate scheduled service timers (#119218)
  test(qa): cover Canvas agent and node controls (#119047)
  fix(cli): avoid repeated migration scans during local agent turns (#119051)
  fix(gateway): keep agents list on prepared model facts (#119208)
  fix(telegram): retry update offset persistence
  fix(ci): accept profiled partial Kova gates (#119121)
  fix(qqbot): keep channel API calls on the active account [AI] (#118575)
  fix(agents): recover from invalid compaction summaries (#119137)
  fix(gateway): expose OAuth-backed tools to CLI agents (#119166)
  fix(plugins): preserve metadata reloads during models status (#119183)
  fix(test): bound direct gateway server runs (#119184)
  test(tui): prove command surfaces through PTY (#119165)
  fix(testbox): restore claims across path aliases (#119170)
  fix(message): preserve sends with incidental Telegram locations
  fix(perf): give each concurrency sample a full deadline (#119164)
  fix(testbox): remove changed-gate sync residue (#119163)
  fix(telegram): preserve later chunks after rejected sends
  fix(tui): block terminal controls in system messages (#118998)
  ...
vincentkoc added a commit that referenced this pull request Aug 4, 2026
…time

* origin/main: (177 commits)
  fix(telegram): route reactions to their originating forum topics
  test(gateway): isolate scheduled service timers (#119218)
  test(qa): cover Canvas agent and node controls (#119047)
  fix(cli): avoid repeated migration scans during local agent turns (#119051)
  fix(gateway): keep agents list on prepared model facts (#119208)
  fix(telegram): retry update offset persistence
  fix(ci): accept profiled partial Kova gates (#119121)
  fix(qqbot): keep channel API calls on the active account [AI] (#118575)
  fix(agents): recover from invalid compaction summaries (#119137)
  fix(gateway): expose OAuth-backed tools to CLI agents (#119166)
  fix(plugins): preserve metadata reloads during models status (#119183)
  fix(test): bound direct gateway server runs (#119184)
  test(tui): prove command surfaces through PTY (#119165)
  fix(testbox): restore claims across path aliases (#119170)
  fix(message): preserve sends with incidental Telegram locations
  fix(perf): give each concurrency sample a full deadline (#119164)
  fix(testbox): remove changed-gate sync residue (#119163)
  fix(telegram): preserve later chunks after rejected sends
  fix(tui): block terminal controls in system messages (#118998)
  fix(auto-reply): suppress false no-reply fallback during continuations (#119154)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
* origin/main: (23 commits)
  chore(tui): add Gateway boundary PTY coverage (openclaw#119191)
  fix(telegram): route reactions to their originating forum topics
  test(gateway): isolate scheduled service timers (openclaw#119218)
  test(qa): cover Canvas agent and node controls (openclaw#119047)
  fix(cli): avoid repeated migration scans during local agent turns (openclaw#119051)
  fix(gateway): keep agents list on prepared model facts (openclaw#119208)
  fix(telegram): retry update offset persistence
  fix(ci): accept profiled partial Kova gates (openclaw#119121)
  fix(qqbot): keep channel API calls on the active account [AI] (openclaw#118575)
  fix(agents): recover from invalid compaction summaries (openclaw#119137)
  fix(gateway): expose OAuth-backed tools to CLI agents (openclaw#119166)
  fix(plugins): preserve metadata reloads during models status (openclaw#119183)
  fix(test): bound direct gateway server runs (openclaw#119184)
  test(tui): prove command surfaces through PTY (openclaw#119165)
  fix(testbox): restore claims across path aliases (openclaw#119170)
  fix(message): preserve sends with incidental Telegram locations
  fix(perf): give each concurrency sample a full deadline (openclaw#119164)
  fix(testbox): remove changed-gate sync residue (openclaw#119163)
  fix(telegram): preserve later chunks after rejected sends
  fix(tui): block terminal controls in system messages (openclaw#118998)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: qa-lab maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant