Skip to content

fix(compaction): retain audited facts when summaries exceed cap - #128968

Merged
roboclaw-bot merged 2 commits into
mainfrom
fix/compaction-retain-audited-facts
Aug 25, 2026
Merged

roboclaw-bot merged 2 commits into
mainfrom
fix/compaction-retain-audited-facts

Conversation

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Closes #125641

AI-assisted by RoboClaw (Codex).

What Problem This Solves

Fixes an issue where identifier-dense sessions could repeatedly fail compaction when an otherwise valid structured summary exceeded the 16K persisted-summary cap. Prefix truncation removed the trailing pending-ask and exact-identifier sections, so the post-budget quality guard rejected the result and left the session growing.

Why This Change Was Made

The safeguard now plans truncation at the structured-summary owner boundary. When the quality guard is enabled, finalization reserves all required headings, pending-user-ask content/evidence, and strict source identifiers before distributing the remaining body budget across lower-priority prose and optional split-turn/suffix context. Malformed output still follows the existing corrective retry, and compaction remains fail-closed when the mandatory retained facts themselves cannot fit.

The generic agent-core 16K cap, configured compaction-provider behavior, and quality-disabled behavior are unchanged.

Production delta: +186/-13 lines. The added surface is the deterministic retention planner and shared latest-ask evidence calculation needed to make the post-budget audit contract enforceable; test delta is +106/-5.

User Impact

Large sessions with dense paths, URLs, hashes, or IDs can compact successfully without disabling strict identifier preservation. OpenClaw still refuses to persist a summary when the required retained facts are intrinsically larger than the artifact cap.

Evidence

  • Before: the focused current-main regression reproduced two generation attempts followed by { cancel: true } after the valid tail was truncated.
  • pnpm test src/agents/agent-hooks/compaction-safeguard.test.ts — 131 passed.
  • pnpm check:changed -- src/agents/agent-hooks/compaction-safeguard-quality.ts src/agents/agent-hooks/compaction-safeguard.ts src/agents/agent-hooks/compaction-safeguard.test.ts — passed all selected core/core-test guards, format, lint, and typecheck lanes.
  • Post-rebase focused proof: pnpm test src/agents/agent-hooks/compaction-safeguard.test.ts -t "audit-required tail sections|reserves split-turn ask evidence" — 3 passed.
  • git diff --check origin/main...HEAD — passed.
  • Fresh Codex autoreview against origin/main — clean, no accepted/actionable findings.

Regression coverage proves first-attempt success for feasible audited facts, fail-closed behavior when one required identifier exceeds 16K, and split-turn ask/identifier reservation before optional split context.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review August 25, 2026 02:15
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 25, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. 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 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 10:52 PM ET / August 25, 2026, 02:52 UTC.

ClawSweeper review

What this changes

The PR makes safeguard-mode compaction reserve required headings, pending-ask evidence, and strict identifiers inside the 16K persisted-summary budget.

Regression provenance

Possible regression — probable (reproduction; reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for normal merge validation. The latest commit addresses the prior split-turn suffix-pressure finding, and current main still uses prefix truncation that can remove audited tail facts; no new discrete correctness defect was found.

Priority: P2
Reviewed head: c7accc6bad69dc98af8b630db52b1ad2882aeed3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The follow-up commit resolves the prior blocking case with focused owner-boundary regression coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal compaction change is covered by focused regression evidence in the PR body; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal compaction change is covered by focused regression evidence in the PR body; the external-contributor proof gate does not apply.
Evidence reviewed 4 items Current-main behavior: Current main caps the summary body with prefix truncation before adding a tail-capped suffix, so it has no structured reservation for audit-required tail sections.
Fix owner boundary: The branch introduces a retention plan at the summary-budget owner and wires it into safeguard finalization only when the quality guard is enabled.
Regression coverage: Focused tests cover a tail-heavy structured body, infeasible required facts, and the split-turn suffix case raised in the previous review cycle.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/agents/agent-hooks/compaction-safeguard.test.ts -t "audit-required tail sections|reserves split-turn ask evidence"

Result: PASS (completed)

pnpm test src/agents/agent-hooks/compaction-safeguard.test.ts -t "audit-required tail sections|reserves split-turn ask evidence"runner@runnervm76f27:/tmp/clawsw
eeper-live-proof-128968-eimgX1/target$ pnpm test src/agents/agent-hooks/compaction-safeguard.test.ts -t "audit-required tail sections|reserves split-turn ask ev
idence"
pnpm test src/agents/agent-hooks/compaction-safeguard.test.ts -t "audit-required tail sections|reserves split-turn ask evidence"
$ node --import tsx scripts/test-projects.mts src/agents/agent-hooks/compaction-safeguard.test.ts -t 'audit-required tail sections|reserves split-turn ask evide
nce'
[test] starting test/vitest/vitest.agents-support.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128968-eimgX1/target

 ✓  agents-support  src/agents/agent-hooks/compaction-safeguard.test.ts (133 tests | 130 skipped) 28ms

 Test Files  1 passed (1)
      Tests  3 passed | 130 skipped (133)
   Start at  02:53:16
   Duration  11.03s (transform 8.79s, setup 775ms, import 9.95s, tests 28ms, environment 0ms)

[test] passed 1 Vitest shard in 15.88s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128968-eimgX1/target$ pnpm test src/agents/agent-hooks/compaction-safeguard.test.ts -t "audit-required tail sec
tions|reserves split-turn ask evidence"
$ node --import tsx scripts/test-projects.mts src/agents/agent-hooks/compaction-safeguard.test.ts -t 'audit-required tail sections|reserves split-turn ask evide
nce'





























Assertions:

  • PASS expect_output: passed

How this fits together

Compaction converts session history into a bounded summary for future agent turns. The safeguard audits required sections, current asks, and identifiers before persisting the summary or failing closed.

flowchart LR
  A[Session history] --> B[Compaction generator]
  B --> C[Structured summary]
  C --> D[Retention budget planner]
  D --> E[Quality audit]
  E -->|accepted| F[Persisted session summary]
  E -->|rejected| G[Retry or fail closed]
Loading

Before merge

  • Resolve merge risk (P1) - The bug fix adds 226 net production lines in a persisted session-summary path; exact-head validation should confirm this owner-boundary planner remains the smallest coherent form.
  • Complete next step (P2) - This open PR already owns the narrow repair; only ordinary exact-head validation remains.
Agent review details

Security

None.

PR surface

Source +226, Tests +181. Total +407 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 240 14 +226
Tests 1 186 5 +181
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 426 19 +407

Review metrics

Metric Value Why it matters
Production versus tests production +226/-14, tests +186/-5 The production growth implements structured budget retention, while the added tests cover normal, infeasible, and split-turn budget outcomes.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #125641
Summary: This PR is the concrete candidate repair for the canonical identifier and pending-ask truncation report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Validate the exact branch head (recommended)
    Merge after the focused compaction regression and required exact-head checks complete successfully.

Technical review

Best possible solution:

Retain the single budget-owner retention planner, with its feasible, infeasible, and split-turn regressions, then merge after exact-head checks pass.

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

Yes, source provides a high-confidence path: current main prefix-caps the structured body before its required tail facts, while the focused regression fixtures model that overflow. This read-only review did not execute the test.

Is this the best way to solve the issue?

Yes. Reserving audited facts at the summary-budget owner is more maintainable than relying on retries after final truncation, and the follow-up commit covers the prior split-turn suffix gap.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal compaction change is covered by focused regression evidence in the PR body; the external-contributor proof gate does not apply.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs a bounded compaction failure that can leave affected sessions unable to compact.
  • merge-risk: 🚨 session-state: The patch changes how persisted session summaries are budgeted and retained.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal compaction change is covered by focused regression evidence in the PR body; the external-contributor proof gate does not apply.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current-main blame attributes both the budget owner and split-turn finalization path to this history. (role: recent area contributor; confidence: medium; commits: 6fe4e11a786b; files: src/agents/agent-hooks/compaction-safeguard.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the required checks complete against c7accc6.

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 (1 earlier review cycle)
  • reviewed 2026-08-25T02:21:57.976Z sha 0b02858 :: found issues before merge. :: [P1] Keep split-turn audit facts out of the tail-capped suffix

@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. 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 25, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Exact-head CI and real behavior proof

PR head c7accc6bad69dc98af8b630db52b1ad2882aeed3 remains unchanged.

  • Exact-head CI: 233/233 checks are terminal: 183 successful, 49 intentionally skipped, 1 neutral, and 0 failed/cancelled/timed out.
  • ClawSweeper: reviewed this exact head with no actionable findings. Its remaining rank-up move was exact-head validation, which is now complete.
  • Real Anthropic proof: workflow run 32816636441, focused job 97706902528.
    • Trusted workflow SHA: a833ca972b551bb8ac2045909fb1b8cf3f0a0929.
    • Proof SHA: ce107a314d251681345fd12d76d02c55f86e308f, descended directly from PR head via proof-only commit 66f91063260760f935455124c402107207947f96.
    • Flow exercised: real anthropic/claude-sonnet-4-6 embedded turns and safeguard compaction → production 16K retention finalizer with a deterministic oversized Decisions body → SQLite persistence → real post-compaction continuation.
    • Evidence: provider summary generated; finalized summary length 16000; truncation marker present; required headings ordered; latest ask retained; exact identifier retained; reopened SQLite summary matched; live follow-up returned the recall marker.
    • Result: 2/2 focused live tests passed.
  • Local proof-branch validation: changed-file formatting, guards, dead-code scan, core test typecheck, lint, and fresh autoreview all passed.

The temporary proof branch changes only test code; the production PR branch was not modified by this live proof.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

/clownfish automerge

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

/clownfish stop

@roboclaw-bot
roboclaw-bot merged commit 97cd06b into main Aug 25, 2026
233 checks passed
@roboclaw-bot
roboclaw-bot deleted the fix/compaction-retain-audited-facts branch August 25, 2026 10:44
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

@openclaw-clownfish openclaw-clownfish Bot added the clownfish Tracked by Clownfish automation label Aug 25, 2026
@openclaw-clownfish

Copy link
Copy Markdown
Contributor

Got it. Clownfish is floating this back to human review. 🐠

I kept the regular clownfish label on it and paused the automation current until a maintainer calls me back in.

@openclaw-clownfish openclaw-clownfish Bot added clownfish:automerge Maintainer opted this Clownfish PR into bounded ClawSweeper-reviewed automerge clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge labels Aug 25, 2026
@openclaw-clownfish

Copy link
Copy Markdown
Contributor

Clownfish is on the reef for this PR. 🐠

I tagged clownfish:automerge and sent ClawSweeper over this exact head. If the sweep finds rough coral, failing checks, or needs-human, I will take another bounded repair lap and ask for a fresh review.

A maintainer can call /clownfish stop any time and I will drift this back to human review.

VACInc added a commit that referenced this pull request Aug 26, 2026
…ited identifiers

Two safeguard defects made auto-compaction fail closed on tool-heavy sessions:

1. When the prepared window held only tool calls/results, the safeguard replaced it
   with sessionManager.getBranch() — the whole branch from root. Since #112988 made
   /new a reset entry inside the same transcript, that branch spans every reset and
   prior compaction (3,565 messages / 5.2 MB on the reporting session), so one
   compaction became dozens of sequential model calls until the 900s watchdog fired
   ("Compaction timed out"). The #78390 reason for that fallback (preparation
   omitting custom messages) is handled by core projectSessionEntryMessage now.
   Summarize only the prepared window; decide "nothing to summarize" from the
   boundary-scoped context (buildSessionContext), never the raw branch. Delete the
   fallback and its sessions_send replay sanitizers, which only existed for it.

2. #122824 moved the identifier oracle to the messages before the recent-turns split,
   so audited identifiers can live only in preserved turns that are capped at 600
   chars/message and 8K per section. The deterministic restore added in #128968 ran
   only when the artifact exceeded 16K chars; an under-budget body that omits an
   identifier still failed the audit (missing_identifiers -> guard_blocked). Run the
   retention plan whenever a strict identifier is missing from the body, and only
   emit the truncation marker when body text was actually trimmed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…claw#128968)

* fix(compaction): retain audited facts under summary cap

* fix(compaction): retain bounded ask context

---------

Co-authored-by: roboclaw-bot <[email protected]>
VACInc added a commit that referenced this pull request Aug 26, 2026
…ited identifiers (#129423)

* fix(compaction): restore omitted source identifiers

* fix: log ChatGPT stream termination reasons

* fix(compaction): summarize the prepared window and always restore audited identifiers

Two safeguard defects made auto-compaction fail closed on tool-heavy sessions:

1. When the prepared window held only tool calls/results, the safeguard replaced it
   with sessionManager.getBranch() — the whole branch from root. Since #112988 made
   /new a reset entry inside the same transcript, that branch spans every reset and
   prior compaction (3,565 messages / 5.2 MB on the reporting session), so one
   compaction became dozens of sequential model calls until the 900s watchdog fired
   ("Compaction timed out"). The #78390 reason for that fallback (preparation
   omitting custom messages) is handled by core projectSessionEntryMessage now.
   Summarize only the prepared window; decide "nothing to summarize" from the
   boundary-scoped context (buildSessionContext), never the raw branch. Delete the
   fallback and its sessions_send replay sanitizers, which only existed for it.

2. #122824 moved the identifier oracle to the messages before the recent-turns split,
   so audited identifiers can live only in preserved turns that are capped at 600
   chars/message and 8K per section. The deterministic restore added in #128968 ran
   only when the artifact exceeded 16K chars; an under-budget body that omits an
   identifier still failed the audit (missing_identifiers -> guard_blocked). Run the
   retention plan whenever a strict identifier is missing from the body, and only
   emit the truncation marker when body text was actually trimmed.

* fix(compaction): fund audit sections first and cap the identifier list

The retention plan protected the model-written "## Pending user asks" and
"## Exact identifiers" sections verbatim. Each re-distill fed the previous
summary back, so the identifier list only grew: on the reporting session it was
13,568 of a 13,953-char summary, every other section an empty heading, and the
next compaction cancelled with "required quality facts exceed finalized artifact
budget" because the protected content alone passed the 16K cap.

Protect only what the audit requires (headings, bounded latest-ask context, the
audited identifiers). Fund the two audit-bearing sections first so an oversized
earlier section cannot starve them, but cap each at 25% of the content budget;
the remainder is split across decisions, TODOs, and constraints.

* fix(ai): log only structured ChatGPT stream termination facts

projectProviderError keeps provider message/body text after credential
redaction, so logging errorMessage could persist prompt- or response-derived
content. Log timing, stop classification, the error class name, and the
projection's structured errorCode/errorType instead, and cover a provider
failure whose message must not reach the transport log.

* fix(ai): classify ChatGPT stream termination locally

Provider error code/type fields are provider-controlled text, so the transport
warning logs a fixed local failure category (timeout, caller-abort,
provider-failure, transport) plus timing instead. The failed-response test
feeds hostile code/type/message values and asserts none reach the log.

* fix(compaction): recover omitted conversation from the boundary-scoped range

Replace the deleted whole-branch fallback with the bounded safety net it was
meant to be: when the prepared window holds no real conversation, project the
branch entries the preparation covered — after the last reset/compaction
boundary, before firstKeptEntryId — through the core context builder and
summarize that range if it contains conversation the preparation dropped. It
can never reach behind a boundary, so it cannot re-read the whole session.

* fix(compaction): make the audit-section cap hard even when the summary fits

Two holes let the identifier snowball survive the 25% share cap: a summary
that still fit the 16K budget skipped the retention plan entirely, so a
13.9K identifier dump was fed unchanged into the next re-distill; and the
surplus loop handed unused budget back to the protected sections whenever
the optional sections were empty — exactly the degraded shape in production.
Rebuild whenever an audit section exceeds its cap, and return surplus to the
optional sections only.

Also classify a direct non-OK HTTP reply (CodexApiError) as a provider
failure in the stream-termination diagnostic, with a direct-400 test that
keeps provider text out of the log.

---------

Co-authored-by: VACInc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…ited identifiers (openclaw#129423)

* fix(compaction): restore omitted source identifiers

* fix: log ChatGPT stream termination reasons

* fix(compaction): summarize the prepared window and always restore audited identifiers

Two safeguard defects made auto-compaction fail closed on tool-heavy sessions:

1. When the prepared window held only tool calls/results, the safeguard replaced it
   with sessionManager.getBranch() — the whole branch from root. Since openclaw#112988 made
   /new a reset entry inside the same transcript, that branch spans every reset and
   prior compaction (3,565 messages / 5.2 MB on the reporting session), so one
   compaction became dozens of sequential model calls until the 900s watchdog fired
   ("Compaction timed out"). The openclaw#78390 reason for that fallback (preparation
   omitting custom messages) is handled by core projectSessionEntryMessage now.
   Summarize only the prepared window; decide "nothing to summarize" from the
   boundary-scoped context (buildSessionContext), never the raw branch. Delete the
   fallback and its sessions_send replay sanitizers, which only existed for it.

2. openclaw#122824 moved the identifier oracle to the messages before the recent-turns split,
   so audited identifiers can live only in preserved turns that are capped at 600
   chars/message and 8K per section. The deterministic restore added in openclaw#128968 ran
   only when the artifact exceeded 16K chars; an under-budget body that omits an
   identifier still failed the audit (missing_identifiers -> guard_blocked). Run the
   retention plan whenever a strict identifier is missing from the body, and only
   emit the truncation marker when body text was actually trimmed.

* fix(compaction): fund audit sections first and cap the identifier list

The retention plan protected the model-written "## Pending user asks" and
"## Exact identifiers" sections verbatim. Each re-distill fed the previous
summary back, so the identifier list only grew: on the reporting session it was
13,568 of a 13,953-char summary, every other section an empty heading, and the
next compaction cancelled with "required quality facts exceed finalized artifact
budget" because the protected content alone passed the 16K cap.

Protect only what the audit requires (headings, bounded latest-ask context, the
audited identifiers). Fund the two audit-bearing sections first so an oversized
earlier section cannot starve them, but cap each at 25% of the content budget;
the remainder is split across decisions, TODOs, and constraints.

* fix(ai): log only structured ChatGPT stream termination facts

projectProviderError keeps provider message/body text after credential
redaction, so logging errorMessage could persist prompt- or response-derived
content. Log timing, stop classification, the error class name, and the
projection's structured errorCode/errorType instead, and cover a provider
failure whose message must not reach the transport log.

* fix(ai): classify ChatGPT stream termination locally

Provider error code/type fields are provider-controlled text, so the transport
warning logs a fixed local failure category (timeout, caller-abort,
provider-failure, transport) plus timing instead. The failed-response test
feeds hostile code/type/message values and asserts none reach the log.

* fix(compaction): recover omitted conversation from the boundary-scoped range

Replace the deleted whole-branch fallback with the bounded safety net it was
meant to be: when the prepared window holds no real conversation, project the
branch entries the preparation covered — after the last reset/compaction
boundary, before firstKeptEntryId — through the core context builder and
summarize that range if it contains conversation the preparation dropped. It
can never reach behind a boundary, so it cannot re-read the whole session.

* fix(compaction): make the audit-section cap hard even when the summary fits

Two holes let the identifier snowball survive the 25% share cap: a summary
that still fit the 16K budget skipped the retention plan entirely, so a
13.9K identifier dump was fed unchanged into the next re-distill; and the
surplus loop handed unused budget back to the protected sections whenever
the optional sections were empty — exactly the degraded shape in production.
Rebuild whenever an audit section exceeds its cap, and return surplus to the
optional sections only.

Also classify a direct non-OK HTTP reply (CodexApiError) as a provider
failure in the stream-termination diagnostic, with a direct-400 test that
keeps provider text out of the log.

---------

Co-authored-by: VACInc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge clownfish:automerge Maintainer opted this Clownfish PR into bounded ClawSweeper-reviewed automerge clownfish Tracked by Clownfish automation maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant