Skip to content

fix(compaction): complete quality defect list + degraded fallback on final audit failure - #3

Closed
amittell wants to merge 10000 commits into
mainfrom
fix/compaction-quality-feedback-truncation
Closed

amittell wants to merge 10000 commits into
mainfrom
fix/compaction-quality-feedback-truncation

Conversation

@amittell

Copy link
Copy Markdown
Owner

Fixes two compaction-safeguard quality-guard failure modes (dogfood tickets openclaw#721 + openclaw#722), observed 2026-08-23 on a ~413k-token session: Compaction safeguard finalized summary failed quality checks. -> cancel, leaving the session permanently uncompactionable at 100% context.

1. Corrective feedback was truncated at 4000 chars

On audit failure the reasons string (incl. missing_identifiers:<full list>, up to 12 extracted identifiers) was fed back via wrapUntrustedInstructionBlock, which hard-caps at 4000 chars. Identifier-dense sessions got an incomplete defect list; retries failed the same audit; run cancelled.

  • The missing sections/identifiers defect list is now emitted as a plain structured list in the regeneration instructions (one line each, same 12-identifier cap, no 4K truncation).
  • Operator-provided custom text still flows through the untrusted wrapper unchanged (identifiers are session-derived and already in the summarization prompt input — no widened trust surface).

2. No fallback on final failure

Final-attempt audit failure now falls back to buildStructuredFallbackSummary (re-distilled from the previous summary) and proceeds with a degraded producerLosses marker + warn log, instead of cancel: true. The genuinely unrecoverable path (LLM call throws on retry) still cancels.

Tests

  • Regression: >4000-char missing-identifiers reasons list appears complete in corrective instructions; operator text still wrapped/truncated as before.
  • Final-attempt audit failure -> non-cancel result with degraded loss marked; earlier attempts still retry; generation throw on attempt>0 still cancels.
  • Existing cancel-reason test cases updated/extended, not orphaned.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.