mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Resolve token budgets from each step's active model (#41162)
## Why Model settings can change between steps in the same turn. Token-budget defaults, context-window limits, and model-visible guidance need to stay aligned with the model captured for each step. ## What changed - Preserve the turn's original token-budget preferences and resolve model-owned defaults when each `StepContext` is created. - Use the step's model to determine context-window availability and token-budget guidance, while keeping explicit user settings unchanged. - Emit one-time replacement or removal notices when context-window guidance changes, including compatibility with previously persisted world-state snapshots. - Add `ModelInfo::usable_context_window()` to distinguish reserved-headroom capacity from the resolved context window and auto-compaction limit. ## Testing - Cover mid-turn model switches with model defaults, explicit settings, config reloads, missing context windows, and missing destination guidance. - Cover unchanged, replaced, removed, blank, and legacy guidance transitions. GitOrigin-RevId: 91100a9f3625bef8a79ecd158eb028051c309eee
This commit is contained in:
1 parent
bce96bcb43
commit
8228e9b867
13 files changed
+434
-65
No files matched your search
@@ -3319,6 +3319,11 @@ impl Session {
|
||||
// Capture once before asynchronous planning; all request consumers
|
||||
// retain this immutable settings version even if the turn is updated.
|
||||
let settings = turn_context.current_settings.load_full();
|
||||
let token_budget = token_budget::resolve_token_budget(
|
||||
turn_context.configured_token_budget.as_ref(),
|
||||
turn_context.use_model_token_budget_defaults,
|
||||
settings.model_info.as_ref(),
|
||||
);
|
||||
let session_telemetry = settings.telemetry(&turn_context.session_telemetry);
|
||||
// Keep selections fixed for the turn while allowing their startup work to finish.
|
||||
let environments = turn_context.environments.refresh_readiness();
|
||||
@@ -3402,6 +3407,7 @@ impl Session {
|
||||
.await??;
|
||||
Ok(Arc::new(StepContext {
|
||||
settings,
|
||||
token_budget,
|
||||
session_telemetry,
|
||||
turn: turn_context,
|
||||
environments,
|
||||
|
||||
Reference in new issue
Block a user