@@ -7,12 +7,28 @@ export const OpenAIReasoningEfforts = ReasoningEfforts.filter(
77)
88export type OpenAIReasoningEffort = ( typeof OpenAIReasoningEfforts ) [ number ]
99
10+ // Mirrors OpenAI's `ResponseIncludable` union from the official SDK. Keep this
11+ // in lockstep with `openai-node/src/resources/responses/responses.ts`.
12+ export const OpenAIResponseIncludables = [
13+ "file_search_call.results" ,
14+ "web_search_call.results" ,
15+ "web_search_call.action.sources" ,
16+ "message.input_image.image_url" ,
17+ "computer_call_output.output.image_url" ,
18+ "code_interpreter_call.outputs" ,
19+ "reasoning.encrypted_content" ,
20+ "message.output_text.logprobs" ,
21+ ] as const
22+ export type OpenAIResponseIncludable = ( typeof OpenAIResponseIncludables ) [ number ]
23+
1024const REASONING_EFFORTS = new Set < string > ( ReasoningEfforts )
1125const OPENAI_REASONING_EFFORTS = new Set < string > ( OpenAIReasoningEfforts )
1226const TEXT_VERBOSITY = new Set < string > ( [ "low" , "medium" , "high" ] )
27+ const INCLUDABLES = new Set < string > ( OpenAIResponseIncludables )
1328
1429export const OpenAIReasoningEffort = Schema . Literals ( OpenAIReasoningEfforts )
1530export const OpenAITextVerbosity = TextVerbosity
31+ export const OpenAIResponseIncludable = Schema . Literals ( OpenAIResponseIncludables )
1632
1733const isAnyReasoningEffort = ( effort : unknown ) : effort is ReasoningEffort =>
1834 typeof effort === "string" && REASONING_EFFORTS . has ( effort )
@@ -35,12 +51,20 @@ export const reasoningEffort = (request: LLMRequest): ReasoningEffort | undefine
3551 return isAnyReasoningEffort ( value ) ? value : undefined
3652}
3753
38- export const reasoningSummary = ( request : LLMRequest ) : "auto" | undefined => {
39- return options ( request ) ?. reasoningSummary === "auto" ? "auto" : undefined
40- }
54+ export const reasoningSummary = ( request : LLMRequest ) : "auto" | undefined =>
55+ options ( request ) ?. reasoningSummary === "auto" ? "auto" : undefined
4156
42- export const encryptedReasoning = ( request : LLMRequest ) =>
43- options ( request ) ?. includeEncryptedReasoning === true ? true : undefined
57+ // Resolve the OpenAI Responses `include` field. Filters out unknown
58+ // includable values defensively so a typo in upstream config drops the
59+ // invalid entry instead of poisoning the wire body. An empty array (either
60+ // passed directly or produced by filtering) is treated as "no include" and
61+ // returns undefined so the request body omits the field entirely.
62+ export const include = ( request : LLMRequest ) : ReadonlyArray < OpenAIResponseIncludable > | undefined => {
63+ const value = options ( request ) ?. include
64+ if ( ! Array . isArray ( value ) ) return undefined
65+ const filtered = value . filter ( ( entry ) : entry is OpenAIResponseIncludable => INCLUDABLES . has ( entry ) )
66+ return filtered . length > 0 ? filtered : undefined
67+ }
4468
4569export const promptCacheKey = ( request : LLMRequest ) => {
4670 const value = options ( request ) ?. promptCacheKey
0 commit comments