Keep only the latest adjacent reasoning effort update in requests (#55293)

## Why

Turn recovery and retries after a server overload can leave consecutive reasoning effort updates in history when settings change without an intervening message. Requests should use the latest update in each consecutive run.

## What changed

Coalesce adjacent `configuration_update` items when building Responses requests with reasoning effort overrides enabled, retaining the latest update. Preserve saved history and updates separated by other input items.

## Testing

Extend integration coverage for recovery with unchanged or changed effort, retries after a server overload, and WebSocket continuation and replay after coalescing. Verify that requests retain the latest adjacent update while saved history keeps all updates.

GitOrigin-RevId: bcf97db4c93dac5f466bd276176ac9d238329ecd
This commit is contained in:
felixxia-oai
2026-10-19 14:34:11 +00:00
committed by copyberry
parent 4e7b9e285b
commit 7c073196a1
2 changed files with 199 additions and 21 deletions
+12
View File
@@ -968,6 +968,18 @@ impl ModelClient {
// Unsupported models and disabled overrides must also accept saved history.
// Filter only the request copy; persisted history remains unchanged.
input.retain(|item| !matches!(item, ResponseItem::ConfigurationUpdate { .. }));
} else {
input.dedup_by(|next, previous| {
if matches!(next, ResponseItem::ConfigurationUpdate { .. })
&& matches!(previous, ResponseItem::ConfigurationUpdate { .. })
{
// Keep the latest update; dedup_by removes `next`.
std::mem::swap(previous, next);
true
} else {
false
}
});
}
let is_openai = self.state.provider.info().is_openai();
// These prompt-only items are rebuilt on every request. Hash their visible payloads