mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve model providers when reloading v2 agents (#36906)
## Why Reloading an unloaded v2 agent could inherit the model provider from the agent that triggered the reload, even though the worker's model was restored from its persisted thread state. ## What changed - Restore both the model and model provider from the stored thread when reloading a v2 agent. - Return an invalid-request error if the stored provider is no longer present in the configured provider map. ## Testing Extend the v2 agent reload test to trigger the reload with a different sender provider and verify that the worker retains its stored provider. GitOrigin-RevId: 6401d9f0d1c116e9954e3bd193d016f04da5f223
This commit is contained in:
1 parent
d98eb72e18
commit
d1f14e31a7
2 files changed
+39
-1
No files matched your search
@@ -269,6 +269,7 @@ impl AgentControl {
|
||||
})
|
||||
.await?;
|
||||
let stored_model = stored_thread.model.clone();
|
||||
let stored_model_provider = stored_thread.model_provider.clone();
|
||||
let stored_source = stored_thread.source.clone();
|
||||
let stored_parent_thread_id = stored_thread.parent_thread_id;
|
||||
let history = load_agent_model_context(&state, thread_id, stored_thread.history_mode)
|
||||
@@ -324,6 +325,18 @@ impl AgentControl {
|
||||
if let Some(model) = stored_model {
|
||||
config.model = Some(model);
|
||||
}
|
||||
if config.model_provider_id != stored_model_provider {
|
||||
config.model_provider = config
|
||||
.model_providers
|
||||
.get(&stored_model_provider)
|
||||
.cloned()
|
||||
.ok_or_else(|| {
|
||||
CodexErr::InvalidRequest(format!(
|
||||
"Model provider `{stored_model_provider}` not found"
|
||||
))
|
||||
})?;
|
||||
config.model_provider_id = stored_model_provider;
|
||||
}
|
||||
let residency_slot = self
|
||||
.reserve_v2_residency_slot(&state, &config, Some(thread_id))
|
||||
.await?;
|
||||
|
||||
Reference in new issue
Block a user