-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
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:
pydantic-ai/pydantic_ai_slim/pydantic_ai/models/openai.py
Lines 859 to 883 in e0f74c6
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)) | |
) |
pydantic-ai/pydantic_ai_slim/pydantic_ai/models/openai.py
Lines 1121 to 1123 in e0f74c6
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 workingSomething isn't working