mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
Preserve allocated response item IDs in requests (#60977)
## Why Providers can echo a bare reserved prefix or return an opaque item ID. Request preparation previously stripped these IDs when they lacked an underscore prefix, even if they carried allocation metadata. ## What changed - Keep response item IDs with allocation metadata when preparing requests. - Add `ResponseItemId::with_generation_prefix` to attach a request reservation's allocation while preserving the exact wire ID and recording a matching item-kind prefix and provider suffix. GitOrigin-RevId: 3249c2669aca11ee5facbd8a246016490a29a4f4
This commit is contained in:
committed by
copyberry
parent
0702ebed4d
commit
cbd4944092
@@ -1317,7 +1317,11 @@ impl ModelClient {
|
||||
|
||||
fn prepare_response_items_for_request(&self, input: &mut [ResponseItem]) {
|
||||
for item in input {
|
||||
if item.id().is_some_and(|id| !id.is_prefixed()) {
|
||||
// A provider can echo a bare reserved prefix or return an opaque ID.
|
||||
if item
|
||||
.id()
|
||||
.is_some_and(|id| id.allocation().is_none() && !id.is_prefixed())
|
||||
{
|
||||
item.set_id(/*new_id*/ None);
|
||||
}
|
||||
if !self.state.content_item_kinds_enabled {
|
||||
@@ -2744,9 +2748,10 @@ fn map_response_stream(
|
||||
let routing_affinity = api_stream.routing_affinity.take();
|
||||
let upstream_request_id = api_stream.upstream_request_id.take();
|
||||
let interrupt = api_stream.interrupt.take();
|
||||
let events = crate::model_request::intercept_stream(Box::pin(api_stream), interceptors);
|
||||
let mut stream = map_response_events(
|
||||
upstream_request_id,
|
||||
crate::model_request::intercept_stream(Box::pin(api_stream), interceptors),
|
||||
events,
|
||||
session_telemetry,
|
||||
inference_trace_attempt,
|
||||
client,
|
||||
|
||||
Reference in New Issue
Block a user