Make token budget context identity configurable (#36970)

## What changed

- Add a `features.token_budget.mode` setting with `thread` and `name` values.
- Default context-window metadata to the thread ID while allowing configurations to retain the agent name.
- Preserve the selected identity mode when applying model token-budget defaults and replaying locked configuration.

## Testing

- Cover configuration parsing and both identity formats in token-budget context messages.

GitOrigin-RevId: f6e6d2c49e09e70c0352e803bb65784ef77e5bee
This commit is contained in:
Boyang Niu authored and copyberry committed 2026-08-04 20:48:40 +00:00
1 parent 720c9d68e1
commit c607da9f37
11 files changed
+102 -12

No files matched your search

+9
View File
@@ -609,6 +609,7 @@ async fn load_config_resolves_token_budget_config() -> std::io::Result<()> {
r#"
[features.token_budget]
enabled = true
mode = "thread"
reminder_threshold_tokens = 16000
reminder_message_template = "Custom reminder: {n_remaining} tokens."
guidance_message = "Preserve important state before compaction."
@@ -616,6 +617,7 @@ auto_compact_fallback_prompt = " Write notes immediately. "
auto_compact_fallback_buffer_tokens = 8000
"#,
TokenBudgetConfig {
mode: TokenBudgetMode::Thread,
reminder_threshold_tokens: Some(16_000),
reminder_message_template: "Custom reminder: {n_remaining} tokens.".to_string(),
guidance_message: Some("Preserve important state before compaction.".to_string()),
@@ -623,6 +625,13 @@ auto_compact_fallback_buffer_tokens = 8000
auto_compact_fallback_buffer_tokens: Some(8_000),
},
),
(
"[features.token_budget]\nenabled = true\nmode = \"name\"\n",
TokenBudgetConfig {
mode: TokenBudgetMode::Name,
..TokenBudgetConfig::default()
},
),
] {
let codex_home = tempdir()?;
let config_toml = toml::from_str(config_toml).expect("TOML should deserialize");