Skip to content

core: raise token budget message limits - #29970

Merged
bolinfest merged 1 commit into
mainfrom
pr29970
Jun 25, 2026
Merged

core: raise token budget message limits#29970
bolinfest merged 1 commit into
mainfrom
pr29970

Conversation

@bolinfest

@bolinfest bolinfest commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Why

Token-budget reminder and guidance messages can require more than 1,000 bytes to provide useful model-facing instructions. At the same time, these strings are injected into model-visible context, so their size must remain tightly bounded in response to the P0 context-growth concern. A 2,000-byte runtime cap provides additional room without allowing the substantially larger context growth of a 4 KiB limit.

What changed

  • raises the runtime byte limits for token-budget reminder templates and guidance messages from 1,000 to 2,000
  • raises the corresponding JSON Schema maxLength values to 2,000
  • regenerates codex-rs/core/config.schema.json

Testing

  • just test -p codex-features
  • just test -p codex-core load_config_resolves_token_budget_config load_config_rejects_invalid_token_budget_reminder_template

The full codex-core test run completed 2,858 tests successfully and encountered seven unrelated environment-sensitive failures involving Seatbelt/network environment assertions, MCP capability setup, and abort timing.

@bolinfest
bolinfest requested a review from a team as a code owner June 25, 2026 03:15
@bolinfest
bolinfest requested a review from rka-oai June 25, 2026 03:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7ae783bff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/config/mod.rs Outdated
Comment on lines +1091 to +1092
const TOKEN_BUDGET_REMINDER_MESSAGE_TEMPLATE_MAX_BYTES: usize = 4096;
const TOKEN_BUDGET_GUIDANCE_MESSAGE_MAX_BYTES: usize = 4096;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P0 Badge Cap token-budget messages below 1k tokens

When token_budget is enabled and a config supplies a near-4096-byte ASCII reminder or guidance string, these constants allow that entire value to be injected as one developer-context fragment via TokenBudgetReminder or ContextWindowGuidance, so a single new context item can cross 1k tokens. The repo review rule requires any newly crossable >1k-token context item to be highlighted as P0 for manual review; keep the hard cap below that threshold or add token-based truncation before injection.

AGENTS.md reference: AGENTS.md:L91-L100

Useful? React with 👍 / 👎.

Comment on lines +89 to +93
#[schemars(length(min = 1, max = 4096))]
pub reminder_message_template: Option<String>,
/// Guidance appended to the context-window metadata in a developer message.
#[serde(skip_serializing_if = "Option::is_none")]
#[schemars(length(max = 1000))]
#[schemars(length(max = 4096))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Align schema length with loader byte limits

For non-ASCII token-budget messages in the newly allowed 1001–4096 character range, this generated maxLength says the config is valid, but resolve_token_budget_config still enforces the same value with String::len() bytes and rejects it once UTF-8 encoding exceeds 4096 bytes. That makes schema-validated configs fail at startup for values such as a 3000-character guidance string containing two-byte characters; either enforce character counts in the loader or keep the schema/documentation byte-based for this config-loading surface.

AGENTS.md reference: AGENTS.md:L102-L110

Useful? React with 👍 / 👎.

@bolinfest

Copy link
Copy Markdown
Collaborator Author

Discussed offline and decided 2,000 bytes is reasonable in this case.

@bolinfest
bolinfest enabled auto-merge (squash) June 25, 2026 04:48
@bolinfest
bolinfest merged commit 22f1256 into main Jun 25, 2026
47 of 62 checks passed
@bolinfest
bolinfest deleted the pr29970 branch June 25, 2026 05:05
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants