Skip to content

OpenAI Responses API fails when using built-in tools and reasoning at same time #2870

@DouweM

Description

@DouweM

Initial Checks

Description

I expect you'd get a similar error message to #2861, as described in https://community.openai.com/t/how-to-solve-badrequesterror-400-item-rs-of-type-reasoning-was-provided-without-its-required-following-item-error-in-responses-api/1151686.

The underlying cause is that we are not currently parsing and sending back built-in tool calls and results:

for item in response.output:
if isinstance(item, responses.ResponseReasoningItem):
signature = item.encrypted_content
for summary in item.summary:
# We use the same id for all summaries so that we can merge them on the round trip.
# We only need to store the signature once.
items.append(
ThinkingPart(
content=summary.text,
id=item.id,
signature=signature,
provider_name=self.system if signature else None,
)
)
signature = None
# NOTE: We don't currently handle the raw CoT from gpt-oss `reasoning_text`: https://cookbook.openai.com/articles/gpt-oss/handle-raw-cot
# If you need this, please file an issue.
elif isinstance(item, responses.ResponseOutputMessage):
for content in item.content:
if isinstance(content, responses.ResponseOutputText): # pragma: no branch
items.append(TextPart(content.text))
elif isinstance(item, responses.ResponseFunctionToolCall):
items.append(
ToolCallPart(item.name, item.arguments, tool_call_id=_combine_tool_call_ids(item.call_id, item.id))
)

elif isinstance(item, BuiltinToolCallPart | BuiltinToolReturnPart):
# We don't currently track built-in tool calls from OpenAI
pass

Specifically, we're not handling these types of output:

        ResponseFileSearchToolCall,
        ResponseFunctionWebSearch,
        ResponseComputerToolCall,
        ImageGenerationCall,
        ResponseCodeInterpreterToolCall,
        LocalShellCall,
        McpCall,
        McpListTools,
        McpApprovalRequest,
        ResponseCustomToolCall,

(Not of all of them are relevant to built-in tools)

Example Code

Python, Pydantic AI & LLM client version

`main`

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions