mirror of
https://github.com/openai/codex.git
synced 2026-11-09 00:39:32 +00:00
Avoid duplicate reasoning effort updates during turn recovery (#44276)
## Why Recovering a suspended turn can append a duplicate reasoning effort update when history already ends with a matching trusted update but the runtime has not established its effort pin. ## What changed Reuse a matching harness-authored `ConfigurationUpdate` at the end of history even when the runtime effort pin is unset. ## Testing Add a regression test that suspends and recovers a turn without WebSocket prewarming, then verifies the recovered request contains exactly one effort update and retains `high` reasoning effort. GitOrigin-RevId: 2e49073eb5e8d4fae39a8dc1d9d2b07f77802adb
This commit is contained in:
1 parent
1ac689cc7d
commit
f5c5d9b2b0
2 files changed
+131
-24
No files matched your search
@@ -37,31 +37,36 @@ impl Session {
|
||||
.reasoning_effort_pin
|
||||
.pin(&settings.model_info.slug, effort.clone());
|
||||
}
|
||||
let established_effort =
|
||||
state
|
||||
.history
|
||||
.annotated_items()
|
||||
.iter()
|
||||
.rev()
|
||||
.find_map(|envelope| {
|
||||
if !envelope
|
||||
.metadata
|
||||
.as_ref()
|
||||
.is_some_and(|metadata| metadata.harness_authored_configuration)
|
||||
{
|
||||
return None;
|
||||
let latest_override = state
|
||||
.history
|
||||
.annotated_items()
|
||||
.iter()
|
||||
.rev()
|
||||
.enumerate()
|
||||
.find_map(|(index, envelope)| {
|
||||
if !envelope
|
||||
.metadata
|
||||
.as_ref()
|
||||
.is_some_and(|metadata| metadata.harness_authored_configuration)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
match &envelope.item {
|
||||
ResponseItem::ConfigurationUpdate { reasoning } => {
|
||||
Some((index, &reasoning.effort))
|
||||
}
|
||||
match &envelope.item {
|
||||
ResponseItem::ConfigurationUpdate { reasoning } => {
|
||||
Some(&reasoning.effort)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
});
|
||||
state
|
||||
.reasoning_effort_pin
|
||||
.get(&settings.model_info.slug)
|
||||
.is_some_and(|pinned| established_effort.unwrap_or(&pinned) == &effort)
|
||||
_ => None,
|
||||
}
|
||||
});
|
||||
// Recovery adds no user message. Reuse a matching trusted tail update even
|
||||
// before this runtime establishes its pin, rather than append adjacent updates.
|
||||
latest_override.is_some_and(|(index, established)| index == 0 && established == &effort)
|
||||
|| state
|
||||
.reasoning_effort_pin
|
||||
.get(&settings.model_info.slug)
|
||||
.is_some_and(|pinned| {
|
||||
latest_override.map_or(&pinned, |(_, established)| established) == &effort
|
||||
})
|
||||
};
|
||||
if should_skip {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user