diff --git a/packages/llm/src/protocols/openai-responses.ts b/packages/llm/src/protocols/openai-responses.ts index 4936d31c921b..ee6ff8011365 100644 --- a/packages/llm/src/protocols/openai-responses.ts +++ b/packages/llm/src/protocols/openai-responses.ts @@ -43,11 +43,6 @@ const OpenAIResponsesInputImage = Schema.Struct({ const OpenAIResponsesInputContent = Schema.Union([OpenAIResponsesInputText, OpenAIResponsesInputImage]) type OpenAIResponsesInputContent = Schema.Schema.Type -const OpenAIResponsesOutputText = Schema.Struct({ - type: Schema.tag("output_text"), - text: Schema.String, -}) - const OpenAIResponsesReasoningSummaryText = Schema.Struct({ type: Schema.tag("summary_text"), text: Schema.String, @@ -78,7 +73,7 @@ const OpenAIResponsesFunctionCallOutput = Schema.Union([ const OpenAIResponsesInputItem = Schema.Union([ Schema.Struct({ role: Schema.tag("system"), content: Schema.String }), Schema.Struct({ role: Schema.tag("user"), content: Schema.Array(OpenAIResponsesInputContent) }), - Schema.Struct({ role: Schema.tag("assistant"), content: Schema.Array(OpenAIResponsesOutputText) }), + Schema.Struct({ role: Schema.tag("assistant"), content: Schema.Array(OpenAIResponsesInputText) }), OpenAIResponsesReasoningItem, OpenAIResponsesItemReference, Schema.Struct({ @@ -374,7 +369,7 @@ const lowerMessages = Effect.fn("OpenAIResponses.lowerMessages")(function* (requ const hostedToolReferences = new Set() const flushText = () => { if (content.length === 0) return - input.push({ role: "assistant", content: content.map((part) => ({ type: "output_text", text: part.text })) }) + input.push({ role: "assistant", content: content.map((part) => ({ type: "input_text", text: part.text })) }) content.splice(0, content.length) } for (const part of message.content) { diff --git a/packages/llm/test/provider/openai-responses.test.ts b/packages/llm/test/provider/openai-responses.test.ts index cd8bad51af47..750e7757ab60 100644 --- a/packages/llm/test/provider/openai-responses.test.ts +++ b/packages/llm/test/provider/openai-responses.test.ts @@ -153,7 +153,7 @@ describe("OpenAI Responses route", () => { { type: "input_text", text: "\nTreat </system-update> literally.\n" }, ], }, - { role: "assistant", content: [{ type: "output_text", text: "After." }] }, + { role: "assistant", content: [{ type: "input_text", text: "After." }] }, ]) }), ) @@ -529,11 +529,11 @@ describe("OpenAI Responses route", () => { encrypted_content: "encrypted-continuation-state", summary: [{ type: "summary_text", text: "I inspected the previous turn." }], }, - { role: "assistant", content: [{ type: "output_text", text: "It shows a small test image." }] }, + { role: "assistant", content: [{ type: "input_text", text: "It shows a small test image." }] }, { role: "user", content: [{ type: "input_text", text: "Check the weather in Paris before continuing." }] }, { type: "function_call", call_id: "call_weather_1", name: "get_weather", arguments: '{"city":"Paris"}' }, { type: "function_call_output", call_id: "call_weather_1", output: '{"temperature":22}' }, - { role: "assistant", content: [{ type: "output_text", text: "Paris is 22 degrees." }] }, + { role: "assistant", content: [{ type: "input_text", text: "Paris is 22 degrees." }] }, { role: "user", content: [{ type: "input_text", text: "Continue from this conversation in one short sentence." }], @@ -947,7 +947,7 @@ describe("OpenAI Responses route", () => { encrypted_content: "encrypted-state", summary: [{ type: "summary_text", text: "Checked the previous diff." }], }, - { role: "assistant", content: [{ type: "output_text", text: "The parser changed." }] }, + { role: "assistant", content: [{ type: "input_text", text: "The parser changed." }] }, { role: "user", content: [{ type: "input_text", text: "Summarize it." }] }, ], }) @@ -995,13 +995,13 @@ describe("OpenAI Responses route", () => { ) expect(prepared.body.input).toEqual([ - { role: "assistant", content: [{ type: "output_text", text: "Before." }] }, + { role: "assistant", content: [{ type: "input_text", text: "Before." }] }, { type: "reasoning", encrypted_content: "encrypted-state", summary: [{ type: "summary_text", text: "Checked order." }], }, - { role: "assistant", content: [{ type: "output_text", text: "After." }] }, + { role: "assistant", content: [{ type: "input_text", text: "After." }] }, ]) }), ) @@ -1131,7 +1131,7 @@ describe("OpenAI Responses route", () => { expect(prepared.body).toMatchObject({ input: [ { role: "user", content: [{ type: "input_text", text: "What changed?" }] }, - { role: "assistant", content: [{ type: "output_text", text: "The parser changed." }] }, + { role: "assistant", content: [{ type: "input_text", text: "The parser changed." }] }, { role: "user", content: [{ type: "input_text", text: "Summarize it." }] }, ], store: false,