Skip to content

Bound Codex-Session Context Intake (#4280)#4281

Merged
Trecek merged 7 commits into
developfrom
impl-codex-context-intake-20260717-203218
Jul 18, 2026
Merged

Bound Codex-Session Context Intake (#4280)#4281
Trecek merged 7 commits into
developfrom
impl-codex-context-intake-20260717-203218

Conversation

@Trecek

@Trecek Trecek commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Codex-backend sessions (gpt-5.6-sol, code_mode_only) repeatedly exhaust their context window through aggressive file intake because upstream Codex removed its read-chunking guidance and honors model-declared max_output_tokens unclamped. This plan bounds Codex context intake on four fronts:

  1. Numeric intake-discipline instructions — a new CODEX_INTAKE_DISCIPLINE_DIGEST constant carrying the issue's numeric rules (at most 2 files per exec command; never read a file end-to-end; never pass max_output_tokens above 10000; open at most 2 files after a directory listing; AGENTS.md package tables are an index) plus the sub-agent spawn rules (fresh context via explicit fork_turns "none"). The digest is injected into every fresh-launch Codex delivery surface through the existing prompt-injector chain and developer_instructions composition points. Claude Code sessions never receive it.
  2. AGENTS.md section 5 edit — the root package-table preamble is rewritten to state the table is an index, not required reading.
  3. Per-repo output-ceiling documentationdocs/configuration.md and ADR-0005 document the two lower-ceiling launch paths for non-autoskillit repos, capping casual reads at ~40 KB.
  4. Codex-cli upgrade tracking — a CODEX_LIMITS_LAST_VERIFIED_VERSION = (0, 144, 1) pin and doctor Check 39 (codex_limits_verified) that WARNs when the installed CLI is newer than the pin.

Requirements

REQ-RD-001: Codex sessions must receive a numeric instruction limiting file reads to at most 2 files per exec command.
REQ-RD-002: Codex sessions must be instructed to never read a file end-to-end, using ranged reads (rg -n with context, or sed -n ranges of at most 250 lines) instead.
REQ-RD-003: Codex sessions must be instructed to never pass max_output_tokens above 10000.
REQ-RD-004: Codex sessions must be instructed to open at most 2 of the files returned by a preceding directory listing.
REQ-RD-005: The AGENTS.md package table must be documented as an index rather than required reading, with per-package AGENTS.md consulted only for packages being modified.
REQ-SUB-001: Codex sessions must be instructed to spawn sub-agents with fresh context rather than fork_turns:"all".
REQ-SUB-002: Sub-agent spawn instructions must require an explicit narrow brief per sub-agent and specify that only a summary is returned to the parent.
REQ-CFG-001: A lower-ceiling launch path (per-project CODEX_HOME, or a -c tool_output_token_limit=N override) must be documented for non-autoskillit repos.
REQ-CFG-002: The documented per-repo ceiling must cap casual reads at approximately 40KB of output, down from the ~218KB produced by the autoskillit-sized default.
REQ-DEP-001: The codex-cli upgrade path must be tracked to capture the larger upstream gpt-5.6-sol context window (372,000 tokens vs. 258,400 tokens in the cli 0.144.1 registry).
REQ-DEP-002: Autoskillit's derived constants (CODEX_TOOL_OUTPUT_TOKEN_LIMIT, the auto-compact sentinel) must be verified consistent with the upstream registry after any codex-cli upgrade.

Closes #4280

Implementation Plan

Plan file: /home/talon/projects/generic_automation_mcp/.autoskillit/temp/make-plan/codex_context_intake_plan_2026-07-17_183300.md

🤖 Generated with Claude Code via AutoSkillit

Trecek and others added 4 commits July 17, 2026 20:37
…urfaces

Introduce CODEX_INTAKE_DISCIPLINE_DIGEST with numeric read rules and
sub-agent spawn discipline. Wire through the injector chain and all four
Codex delivery surfaces (skill, food-truck, interactive, agent TOMLs)
plus build_resume_cmd prepend. Claude Code surfaces explicitly excluded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ck 39

Rewrite AGENTS.md §5 preamble to mark the package table as an index.
Add per-repo Codex output ceiling guidance to configuration.md and
ADR-0005. Add CODEX_LIMITS_LAST_VERIFIED_VERSION pin and doctor
Check 39 (codex_limits_verified) with extracted version-parse helper.
Update stale doctor check counts in docs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…elivery guarantees

T1-T2: intake digest content pins and TOML safety guard.
T3: fresh headless and food-truck include intake digest.
T4: interactive and agent-TOML two-digest composition.
T5: interactive developer_instructions exact-string assertions.
T6: Claude backend negative delivery guarantee.
T7: doctor codex_limits_verified (4 cases: warn, ok, between-pins, skip).
T8: ADR-0005 per-repo ceiling and upgrade tracking ratchets.
T9: AGENTS.md package table marked as index.
T10: injector chain registry and backend-conditional tests.
T11: resume cmd prepend pin + Claude negative guard.
T12: doctor count ratchet bumped to 47, backend registry exports updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fix cross-package import in _doctor_runtime.py (import via execution/,
not execution/backends/_codex_config). Bump codex.py line limit
exemption (1210->1212), doctor __init__.py limit (253->257), and
type_constants symbol count ratchet (110->112).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@Trecek Trecek left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AutoSkillit PR Review — Verdict: approved_with_comments

Comment thread src/autoskillit/cli/doctor/_doctor_runtime.py Outdated
Comment thread src/autoskillit/execution/backends/codex.py Outdated
Comment thread docs/decisions/0005-output-budget-protocol.md Outdated

@Trecek Trecek left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AutoSkillit review: warning-only findings detected. See inline comments — no blocking changes required.

Trecek and others added 3 commits July 17, 2026 22:38
…CodexVersionResult NamedTuple

Addresses reviewer finding: the tuple[int,int,int] | str union used a bare
string as the skip-reason sentinel with no static safety net for future call
sites. CodexVersionResult(parsed, skip_reason) makes misuse unrepresentable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… eliminate dual-mechanism drift

The digest-pair ordering (OUTPUT_DISCIPLINE_DIGEST + CODEX_INTAKE_DISCIPLINE_DIGEST)
was encoded independently in both _CODEX_DISCIPLINE_SUFFIX (codex.py) and the
injector chain sequence (_claude_prompt.py). Adds codex_discipline_suffix() to
_claude_prompt.py as the single source of truth and has codex.py import it,
eliminating the silent drift risk.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The forward obligation cited 'Verification 6 in the implementation plan' but
no implementation plan is committed and issue #4280 contains no verification
sections, making the gating criterion untraceable. Replaced with an inline
description of the operative constraint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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