Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/api/transform/__tests__/responses-api-input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,28 @@ describe("convertToResponsesApiInput", () => {
}),
)
})

it("should not replay Anthropic thinking blocks as assistant-visible text", () => {
const messages: Anthropic.Messages.MessageParam[] = [
{
role: "assistant",
content: [
{ type: "thinking", thinking: "SECRET_CHAIN_OF_THOUGHT", signature: "sig-1" } as any,
{ type: "text", text: "visible answer" },
],
},
]

const result = convertToResponsesApiInput(messages)

expect(result).toEqual([
{
type: "message",
role: "assistant",
content: [{ type: "output_text", text: "visible answer" }],
},
])
})
})

describe("multi-turn conversations", () => {
Expand Down
13 changes: 5 additions & 8 deletions src/api/transform/responses-api-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,11 @@ export function convertToResponsesApiInput(messages: Anthropic.Messages.MessageP
})
break
case "thinking":
// Include reasoning if it has content
if ((part as any).thinking && (part as any).thinking.trim().length > 0) {
input.push({
type: "message",
role: "assistant",
content: [{ type: "output_text", text: `[Thinking] ${(part as any).thinking}` }],
})
}
// Anthropic thinking blocks represent hidden reasoning. The
// Responses API input format does not have a compatible hidden
// reasoning representation for these persisted blocks, so replaying
// them as normal assistant-visible text changes conversation
// semantics. Skip them instead of flattening them into output_text.
break
}
}
Expand Down
Loading