@@ -22,6 +22,26 @@ export const FORWARD_HEADERS = [
2222 "x-responsesapi-include-timing-metrics" ,
2323] ;
2424
25+ function sanitizeReasoningInputContent ( body : unknown ) : unknown {
26+ if ( ! body || typeof body !== "object" || Array . isArray ( body ) ) return body ;
27+ const raw = body as Record < string , unknown > ;
28+ if ( ! Array . isArray ( raw . input ) ) return body ;
29+
30+ let changed = false ;
31+ const input = raw . input . map ( item => {
32+ if ( ! item || typeof item !== "object" || Array . isArray ( item ) ) return item ;
33+ const rec = item as Record < string , unknown > ;
34+ if ( rec . type !== "reasoning" || ! Array . isArray ( rec . content ) || rec . content . length === 0 ) return item ;
35+ changed = true ;
36+ // Routed models can produce raw `reasoning_text` output items. Codex echoes those in later
37+ // native GPT requests, but ChatGPT's Responses backend accepts reasoning input only with empty
38+ // `content`; keep summaries/ids and drop the raw content so native passthrough does not 400.
39+ return { ...rec , content : [ ] } ;
40+ } ) ;
41+
42+ return changed ? { ...raw , input } : body ;
43+ }
44+
2545export function createResponsesPassthroughAdapter ( provider : OcxProviderConfig ) : ProviderAdapter & { passthrough : true } {
2646 return {
2747 name : "openai-responses" ,
@@ -49,7 +69,7 @@ export function createResponsesPassthroughAdapter(provider: OcxProviderConfig):
4969 url,
5070 method : "POST" ,
5171 headers,
52- body : JSON . stringify ( parsed . _rawBody ) ,
72+ body : JSON . stringify ( sanitizeReasoningInputContent ( parsed . _rawBody ) ) ,
5373 } ;
5474 } ,
5575
0 commit comments