Skip to content

fix(codexcli): honor project instruction byte budget - #3505

Closed
521Peter wants to merge 1 commit into
dyoshikawa:mainfrom
521Peter:fix/codex-project-doc-budget
Closed

521Peter wants to merge 1 commit into
dyoshikawa:mainfrom
521Peter:fix/codex-project-doc-budget

Conversation

@521Peter

@521Peter 521Peter commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3491.

The instruction-size warning always used 32,768 bytes, even when the project had explicitly changed project_doc_max_bytes. This produced repeated warnings for a 42 KB file with a 128 KB budget, and missed files exceeding a smaller configured budget.

This reads the top-level setting from the output root's .codex/config.toml when estimating the Codex project instruction budget. Non-negative safe integers (including zero) apply to both root files and nested chains. Missing, unreadable, malformed or unusable settings retain the default. The warning reports the actual byte limit used. The config is never modified.

This intentionally does not resolve Codex's full config hierarchy, profiles or project trust. The documentation now explains this local-estimate limitation and has been regenerated for the bundled docs. Global instructions and other targets keep their existing behavior.

Validation:

  • Before the fix: 5 new regression failures, 391 passing tests in rules-processor.test.ts.
  • After the fix, including additional boundary cases: all 398 processor tests pass.
  • CLI E2E regression passes: default-budget warning remains, then raising the local budget suppresses it without changing the TOML file.
  • pnpm check and pnpm build pass.
  • Full pnpm cicheck passes: 566 test files, 15,126 tests passing and 4 skipped, plus formatting, lint, types, generated-doc checks, spelling and secret scanning.

The first full test run, while other checks/build were running, hit the existing symlinked-directory watch timeout. The subsequent full pnpm cicheck passed; no watch code or timeout was changed.

AI assistance: implemented and tested with OpenAI Codex. Completed the repository's required review-pr review with separate code-quality and security reviewers; neither found actionable issues. At review time, External Contributor Policy passed, with Code Quality & Tests and Build binaries still running and no failing workflows.

@521Peter
521Peter marked this pull request as ready for review October 17, 2026 08:46

@dyoshikawa dyoshikawa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for picking this up, and sorry for the overlap. The same fix for #3491 landed on main in #3508 shortly after this PR was opened, so this branch now conflicts with main in rules-processor.ts and the Codex CLI note in file-formats.md, and rebasing it would mostly mean dropping its changes.

Main took a slightly different shape: the .codex/config.toml read lives in codexcli-rule.ts (readCodexcliProjectDocMaxBytes) and is wired into the processor through a per-tool readConfiguredBytes hook, instead of a toolTarget === "codexcli" branch inside the generic warnForInstructionBudget. That keeps tool-specific logic out of the processor.

One difference worth noting: this PR accepts project_doc_max_bytes = 0 and warns against a 0-byte budget, while main falls back to the 32 KiB default for 0. I'll look at how Codex itself treats 0 separately. Your e2e case (raising the budget suppresses the warning and leaves the config untouched) is a nice check too; I'll see whether main already covers it.

Given that, I don't think this can be merged as-is. Unless you see something here that #3508 misses, I'd lean toward closing it as superseded.

@521Peter

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review. I checked #3508 and agree that it covers #3491 while keeping the config reader tool-specific, so closing this as superseded makes sense. I will leave the zero-budget behavior to the separate follow-up you mentioned.

@521Peter 521Peter closed this Oct 18, 2026
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.

codexcli: AGENTS.md size warning ignores project_doc_max_bytes set in .codex/config.toml

2 participants