Skip to content

Commit 22f1256

Browse files
authored
core: raise token budget message limits (#29970)
## 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.
1 parent cef5444 commit 22f1256

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

codex-rs/core/config.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,12 +2889,12 @@
28892889
},
28902890
"guidance_message": {
28912891
"description": "Guidance appended to the context-window metadata in a developer message.",
2892-
"maxLength": 1000,
2892+
"maxLength": 2000,
28932893
"type": "string"
28942894
},
28952895
"reminder_message_template": {
28962896
"description": "Reminder template. `{n_remaining}` is replaced with the tokens remaining before auto-compaction.",
2897-
"maxLength": 1000,
2897+
"maxLength": 2000,
28982898
"minLength": 1,
28992899
"type": "string"
29002900
},

codex-rs/core/src/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,8 @@ pub(crate) const DEFAULT_TOKEN_BUDGET_REMINDER_MESSAGE_TEMPLATE: &str = concat!(
10881088
"Your context window is nearly exhausted (only {n_remaining} tokens remaining) and will be automatically reset for you soon. ",
10891089
"Once reset, message items in current context window will be cleared in the new window, but notes and history items will be persistent across windows."
10901090
);
1091-
const TOKEN_BUDGET_REMINDER_MESSAGE_TEMPLATE_MAX_BYTES: usize = 1000;
1092-
const TOKEN_BUDGET_GUIDANCE_MESSAGE_MAX_BYTES: usize = 1000;
1091+
const TOKEN_BUDGET_REMINDER_MESSAGE_TEMPLATE_MAX_BYTES: usize = 2000;
1092+
const TOKEN_BUDGET_GUIDANCE_MESSAGE_MAX_BYTES: usize = 2000;
10931093

10941094
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
10951095
pub struct TokenBudgetConfig {

codex-rs/features/src/feature_configs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ pub struct TokenBudgetConfigToml {
8686
/// Reminder template. `{n_remaining}` is replaced with the tokens remaining before
8787
/// auto-compaction.
8888
#[serde(skip_serializing_if = "Option::is_none")]
89-
#[schemars(length(min = 1, max = 1000))]
89+
#[schemars(length(min = 1, max = 2000))]
9090
pub reminder_message_template: Option<String>,
9191
/// Guidance appended to the context-window metadata in a developer message.
9292
#[serde(skip_serializing_if = "Option::is_none")]
93-
#[schemars(length(max = 1000))]
93+
#[schemars(length(max = 2000))]
9494
pub guidance_message: Option<String>,
9595
}
9696

0 commit comments

Comments
 (0)