Skip to content

Fit over-budget views without weakening required content protection - #49

Merged
Brian Krabach (bkrabach) merged 1 commit into
mainfrom
codex/fit-soft-recent-context
Oct 9, 2026
Merged

Brian Krabach (bkrabach) merged 1 commit into
mainfrom
codex/fit-soft-recent-context

Conversation

@bkrabach

@bkrabach Brian Krabach (bkrabach) commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Dense recent history can leave a request over budget even after the last compaction level, because historical machine reminders still receive percentage-based recency protection. A synthetic retained request fails at 17,123 estimated tokens against a 10,000-token budget on the previous source.

After the normal ladder, add one budget-fit pass that relaxes only the recent-message fraction. The existing protection logic continues to preserve current required injections, first/latest human prompts, loaded-tool metadata, and protected tool-result groups. Requests already within budget do not take this pass. Required content that cannot fit still fails, with failed-retention state rolled back and canonical history unchanged.

Validation in owned DTU dtu-unified-public-readiness-20261008, using synthetic state and no credentials:

  • New regression: 1 failed / 3 passed before the change; all 4 pass after it.
  • Complete context-module suite: 231 passed, 1 existing expected failure.
  • Tests cover dense historical reminders, byte-preserved requirements, tool-pair integrity, loaded-tool state, stable subsequent views, and rollback on an oversized required floor.

This addresses a reproduced defect discovered while investigating a spark-1 local context failure. The production event reported 854,567 estimated tokens after compaction against an 853,104 effective budget; its saved diagnostics do not provide an exact retained-content breakdown. This PR is not a claim of end-to-end recovery of that conversation. Live state has not been edited or retried; integrated runtime qualification is complete as described below; actual-session recovery remains separate.

Integrated qualification in the same owned DTU:

  • 29 request-retention, measured-compaction, and real OpenAI-provider/context/streaming-loop tests passed with no skips.
  • Joint dense-history regression: old context source fails before dispatch; candidate passes and sends exactly one request. Required content and the canonical history prefix remain intact.
  • Impossible required-content case remains blocked with zero transport calls. Both joint tests pass on the candidate.
  • Streaming source dd916499344671e0209d4951bc025777e3e891fd; OpenAI provider main 89ad2ee72e3e1d5ffdd30eb940d8608a68c99b26; Core 2.0.1, OpenAI SDK 3.28.0. In-memory transport only, no provider credentials or network generation.

@bkrabach
Brian Krabach (bkrabach) marked this pull request as ready for review October 9, 2026 23:10
@bkrabach
Brian Krabach (bkrabach) merged commit db64136 into main Oct 9, 2026
4 checks passed
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