Track context windows per agent (#37347)

## Why

Forked subagents can inherit a parent's compacted history, but their context-window metadata needs to identify the child and start a distinct window lineage.

## What changed

- Always identify context windows by agent name and remove the `features.token_budget.mode` setting.
- Persist the agent path in world state and emit context-window metadata as a standalone developer message when the identity changes.
- Reset inherited compaction metadata to the forked subagent's initial context window and restore that window in session state.

## Testing

Extend the full-history subagent test to verify parent and child world-state snapshots, agent identities, distinct window IDs, and the reset child checkpoint.

GitOrigin-RevId: 6584201e57b3d2fba0ce626b89a8b3b0b3c752db
This commit is contained in:
Boyang Niu authored and copyberry committed 2026-08-07 01:05:33 +00:00
1 parent 270d93268c
commit 69b6152c17
15 files changed
+195 -111

No files matched your search

-2
View File
@@ -272,7 +272,6 @@ mod tests {
config.multi_agent_v2.subagent_developer_instructions =
Some("Locked subagent developer instructions.".to_string());
config.token_budget = Some(crate::config::TokenBudgetConfig {
mode: codex_features::TokenBudgetMode::Thread,
reminder_threshold_tokens: Some(16_000),
reminder_message_template: "Locked reminder: {n_remaining} tokens.".to_string(),
guidance_message: Some("Locked context-window guidance.".to_string()),
@@ -372,7 +371,6 @@ mod tests {
features.token_budget,
Some(FeatureToml::Config(TokenBudgetConfigToml {
enabled: Some(true),
mode: Some(codex_features::TokenBudgetMode::Thread),
reminder_threshold_tokens: Some(16_000),
reminder_message_template: Some(
"Locked reminder: {n_remaining} tokens.".to_string()