Skip to content

fix(context): bound full-compaction retention by token capacity - #454

Draft
zhengdaqi wants to merge 3 commits into
codex/convergence-v24r12-boundary-signal-accountingfrom
codex/convergence-v24r13-capacity-aware-compaction
Draft

fix(context): bound full-compaction retention by token capacity#454
zhengdaqi wants to merge 3 commits into
codex/convergence-v24r12-boundary-signal-accountingfrom
codex/convergence-v24r13-capacity-aware-compaction

Conversation

@zhengdaqi

Copy link
Copy Markdown
Collaborator

Summary

V24R12 Case 09 showed that full summarization could succeed while the proposed post-compact request remained blocking. The planner selected a 35% tail by message count and then retained up to eight protected frames independently, so a few large tool-result frames could exceed the intended exact-retention share.

This stacked draft changes full compaction to share one token budget across the exact tail and protected prefix. Older protected frames that do not fit are summarized rather than silently dropped, tool call/result pairs remain atomic, and the newest complete frame is retained for the existing post-compact fail-closed evaluator.

Do not merge this PR, or the preceding convergence stack, until the fresh Case 09 product Gate passes with completion proof and a substantive validated report.

Changes

  • Compute the existing keepTailRatio against estimated canonical-message tokens instead of message count.
  • Select newest atomic tail frames first, then eligible protected prefix frames only within the remaining aggregate budget.
  • Include protected frames that do not fit in the same summary request.
  • Preserve the existing boundary/summary/retained/attachment/hook ordering and tool-pair integrity.
  • Add uneven protected-frame and oversized-newest-frame counterexamples.
  • Document the Core-only design boundary and preserved-session replay evidence.

QA & Evidence

  • Red counterexample: V24R12 passed 9 existing context tests and failed only the new aggregate-retention assertion. Artifact: .omo/evidence/20260727-v24r13-capacity-aware-compaction/QA.md.
  • Focused context: build plus 11/11 context/compaction tests passed. This covers aggregate budgeting, summary inclusion, pair integrity, newest-frame retention, and no-summarizable behavior.
  • Preserved Case 09 shape: the same content-silent replay reduced exact retention from 42,098 tokens (47.69%) to 27,232 tokens (30.85%) against a 30,897-token target. Projected post-message tokens fell from 42,157 to 27,291; both partitions retained exact tool pairs. Artifact: .omo/evidence/20260727-v24r13-capacity-aware-compaction/preserved-session-comparison.md.
  • Focused controls: 95/95 passed across AgentLoop, Progress Lease, real local Gateway, O1/router observation, and Legal Coverage.
  • Full repository: npm test rebuilt the project and passed 313/313 tests with zero failures, skips, or cancellations.
  • Patch hygiene: git diff --check passed; dependency lockfiles were unchanged.

Risks & Residuals

  • The newest atomic frame is deliberately retained even when it alone exceeds the target; the unchanged post-compact evaluator remains responsible for rejecting a still-blocking request.
  • Local QA proves context shape and composition, not real-model summary fidelity or end-to-end legal completion.
  • A fresh immutable Gateway/O1 campaign must run paired smoke, Case 05, and Case 09. V25 and the 85-case campaign remain blocked until Case 09 passes in full.

Stack

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.

1 participant