Skip to content

Rectify Codex Code-Mode delivery-bound immunity with bounded summary#4302

Merged
Trecek merged 5 commits into
developfrom
codex-code-mode-truncates-open-kitchen-to-10k-despite-54-5k/4300
Jul 20, 2026
Merged

Rectify Codex Code-Mode delivery-bound immunity with bounded summary#4302
Trecek merged 5 commits into
developfrom
codex-code-mode-truncates-open-kitchen-to-10k-despite-54-5k/4300

Conversation

@Trecek

@Trecek Trecek commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

The open_kitchen MCP response exceeded Codex code-mode's 10,000-token transport bound because response-budget enforcement used a static exemption ceiling without accounting for backend delivery limits. This change makes delivery-bound handling backend-aware, emits bounded inline spill summaries with nested metadata, caps projections to the effective transport bound, restores exemption ordering, and adds real-payload fitness and regression coverage.

Requirements

Conflict Resolution Decisions

Implementation Plan

Plan files:

  • /home/talon/projects/autoskillit-runs/remediation-20260720-080955-202344/.autoskillit/temp/rectify/rectify_codex_code_mode_delivery_bound_2026-07-20_081500.md
  • /home/talon/projects/autoskillit-runs/remediation-20260720-080955-202344/.autoskillit/temp/make-plan/codex_code_mode_delivery_bound_remediation_plan_2026-07-20_095535.md

Closes #4300

🤖 Generated with Claude Code via AutoSkillit

Token Usage Summary

Step Model count uncached output cache_read peak_ctx turns cache_write time
rectify* opus[1m] 1 18 4.0k 1.1M 131.6k 115 13.1k 17m 42s
dry_walkthrough* fable 2 35.9k 68.2k 1.9M 144.4k 91 279.7k 20m 18s
implement* MiniMax-M3 2 436.9k 45.8k 17.6M 94.6k 316 0 38m 16s
retry_worktree* MiniMax-M3 1 157.6k 17.5k 11.8M 0 172 0 21m 42s
audit_impl* fable 2 66.2k 36.9k 2.1M 183.1k 91 228.6k 26m 6s
make_plan* fable 1 83.3k 76.0k 7.0M 251.5k 86 405.2k 18m 4s
prepare_pr* MiniMax-M3 1 52.2k 3.8k 180.7k 0 16 0 1m 50s
compose_pr* MiniMax-M3 1 37.7k 2.4k 215.6k 0 13 0 1m 28s
Total 869.7k 254.6k 41.9M 251.5k 926.6k 2h 25m

* Step used a non-Anthropic provider; caching behavior may differ.

Token Efficiency

Step LoC Changed cache_read/LoC cache_write/LoC output/LoC
rectify 0
dry_walkthrough 0
implement 819 21485.4 0.0 55.9
retry_worktree 465 25275.5 0.0 37.7
audit_impl 0
make_plan 0
prepare_pr 0
compose_pr 0
Total 1284 32664.4 721.7 198.3

Model Usage Breakdown

Model steps uncached output cache_read cache_write time
opus[1m] 1 18 4.0k 1.1M 13.1k 17m 42s
fable 3 185.3k 181.1k 11.1M 913.5k 1h 4m
MiniMax-M3 4 684.4k 69.5k 29.7M 0 1h 3m

Trecek and others added 5 commits July 20, 2026 09:08
…apabilities.effective_delivery_token_limit

Resolves #4300. Code-mode models (gpt-5.6-sol) bypass the tool_output_token_limit
ceiling via model-declared max_output_tokens, so the server-side response
backstop must apply each backend's worst-case operative bound at response
time rather than rely on the static exemption ceiling.

Changes:
- Add effective_delivery_token_limit field to BackendCapabilities (46_500 for
  Claude Code, 10_000 for Codex).
- Add resolve_effective_delivery_bound() canonical accessor in
  execution/backends/_delivery_bounds.py.
- Add effective_delivery_token_limit parameter to enforce_response_budget()
  that gates both the exempted-within-ceiling and non-exempted under-budget
  early-return paths. Spill-and-project produces a bounded projection with
  reason="delivery_bound" via the existing _autoskillit_response_spill envelope.
- Wire delivery-bound extraction through both call sites: track_response_size
  decorator and shape_execution_response.
- Update ADR-0005: per-repo ceiling guidance now documents that the
  server-side backstop enforces the bound for code-mode, not the advisory
  digest. Move code-mode bypass from Accepted Gaps to Resolved.

Tests:
- Backend-aware delivery bound resolution across BACKEND_REGISTRY.
- Exempted payload above Codex code-mode bound spills, not passed through.
- Bundled recipe payload fits or spills per backend.
- Non-exempted oversized payload within response_max_bytes but above delivery
  bound routes to spill-and-project.
- CODEX_INTAKE_DISCIPLINE_DIGEST numeric max_output_tokens rule must match the
  Codex effective delivery bound (regression guard).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…reat zero as no-op

- Move src/autoskillit/execution/backends/_delivery_bounds.py to
  src/autoskillit/core/_delivery_bounds.py — the function operates on
  BackendCapabilities (IL-0), and server-layer consumers cannot import
  from execution/backends per REQ-IMP-007 / REQ-ARCH-001.
- Re-export through autoskillit.core.__init__.pyi.
- Treat effective_delivery_token_limit <= 0 as "not configured" so
  pre-existing BackendCapabilities instances with the field default do
  not trigger the spill path (test mocks rely on this).
- Mirror the new "delivery_bound" reason in the hook-formatter
  _RESPONSE_SPILL_REASONS frozenset.
- Register _delivery_bounds in MODULE_CASCADE_CORE; bump core/ file
  budget to 25; add the field to the locked-name test set; add a
  docstring citation for the conformance coverage test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ms set

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ing, projection cap

Replace the generic projection in _spill_for_delivery_bound with a bounded
inline summary that preserves the operational fields (success, kitchen,
version, ingredients_table, orchestration_rules, stop_step_semantics,
errors, suggestions) verbatim when they fit, truncates content to fit the
bound, drops diagram when content alone exceeds the bound, and uniformly
projects oversized preserved values before reaching the minimal rung.
Delete the broken truncation fallback (dead store + malformed
_finalize_envelope call that flattened metadata and raised
_ProjectionNonconvergentError). Add a reason kwarg to _plain_spill_envelope
so delivery-bound plain-text spills are labeled "delivery_bound".

Restore the exemption-ceiling-first ordering in enforce_response_budget:
ceiling check dominates, delivery-bound spill applies only within the
ceiling, exemption event is the pass-through.

Cap the non-exempted projection target at
min(response_max_bytes, effective_delivery_token_limit * 4) so the rendered
projection is structurally guaranteed to fit the transport bound.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…g, projection cap

Tighten test_exempted_payload_spills_when_over_delivery_bound to assert
delivery_bound_spill=True, success=True preserved, and reason strictly
"delivery_bound" (not the 3-member set).

Add six new tests in tests/server/test_response_backstop.py:
- test_delivery_bound_summary_preserves_operational_fields (T1)
- test_delivery_bound_summary_small_bound_no_exception (T2 REQ-026 guard)
- test_delivery_bound_summary_drops_diagram_when_needed (T3)
- test_over_ceiling_payload_fails_even_when_over_delivery_bound (T4 ordering)
- test_non_exempted_projection_capped_at_delivery_bound (T5 REQ-023)
- test_delivery_bound_summary_projects_oversized_preserved_fields (T9 rung-4)

Rebuild _full_open_kitchen_payload in tests/contracts/test_delivery_bound_fitness.py
on real bundled recipes via load_and_validate +
build_open_kitchen_recipe_payload (the production routing-field injector)
mirroring tests/recipe/test_bundled_recipes_all_truthy.py overrides; isolate
via monkeypatch.chdir(tmp_path). Tighten the fit-or-spill assertion to
require delivery_bound_spill=True and reason "delivery_bound".

Resize the non-exempted overflow payload in Test 1.4 to 60 keys of 5,000
chars (~300 KB) so it exceeds every backend's bound and
response_max_bytes; add the self-check that the payload exceeds the bound
and that the spill envelope is produced.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Trecek
Trecek added this pull request to the merge queue Jul 20, 2026
Merged via the queue into develop with commit f4c0190 Jul 20, 2026
3 checks passed
@Trecek
Trecek deleted the codex-code-mode-truncates-open-kitchen-to-10k-despite-54-5k/4300 branch July 20, 2026 19:27
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