You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(context): degrade the prompt visibly instead of failing the cycle (#1438) (#1440)
* wip(context): uniform degradation ladder for prompt cap overflow (#1438)
Work-in-progress snapshot committed by the operator after the agent's
session was terminated by a gateway 504. Not reviewed, not test-run.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(context): make the ladder's degradation visible, fair, and correctly named
Four defects in the WIP snapshot:
- Both degradation warnings used %-style placeholders while the project
logs through loguru, so the alert emitted its own format string:
"starved=%s shortfall=%d cap=%d". An alert that carries no data reads
the same as one that never fired.
- The rung recorded on the non-strict path was "uniform_trim", but that
branch line-trims and then drops whole sections in iteration order. It
is now "line_trim": prompt_fit_rung must not count a positional
mechanism and the ladder as one thing.
- The budget was a flat available//n, so a 50-char section reserved the
same allowance as a 40,000-char one and the slack was unusable. Budgets
are now water-filled: an entry shorter than its share keeps everything
and the remainder is redistributed. The allocation is keyed on length,
not order — permuting the entries permutes the budgets identically.
- A trimmed entry was cut with no marker, so the loss was visible only in
our log and not in the artifact the model reads. Each trimmed entry now
carries "[trimmed N chars]" inside its own budget.
Tests: _fair_budgets is pinned against permutation (the property a
tail-slice implementation fails while still "fitting"), two over-budget
entries of very different length are asserted to receive the same
allowance, and the trim note is asserted to name the loss.
Corrects one assertion rather than the code: the subagent test required
the whole returned prompt under the cap, but #1379 appends the operator
charter after the fit, deliberately outside it. The test now bounds the
capped portion and pins the charter tail explicitly.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments