Skip to content

Commit e4aebaf

Browse files
committed
Removed change in documentation
1 parent 8ff4db7 commit e4aebaf

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

docs/models/openai.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ agent = Agent(model)
9999
```
100100

101101
## OpenAI Responses API
102-
### Tips for JSON Schema compatibility
103-
104-
Strict Structured Outputs prefer flat object schemas without combinators. If your tool or output schema contains `allOf`/`oneOf`, consider flattening `allOf` ahead of time. See the Tools documentation section "Flattening allOf for provider compatibility" for a sample prepare hook.
105-
106102

107103
Pydantic AI also supports OpenAI's [Responses API](https://platform.openai.com/docs/api-reference/responses) through the
108104

docs/tools.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -357,30 +357,6 @@ print(test_model.last_model_request_parameters.function_tools)
357357
_(This example is complete, it can be run "as is")_
358358

359359

360-
### Flattening allOf for provider compatibility
361-
362-
Some providers (especially when using strict Structured Outputs) reject JSON Schema combinators like `allOf/oneOf`.
363-
If your tool parameter schema includes `allOf`, you can flatten it before sending to the model using a prepare hook.
364-
365-
Example prepare hook that flattens `allOf`:
366-
367-
```python
368-
from pydantic_ai import Agent
369-
from pydantic_ai.tools import RunContext, ToolDefinition
370-
from pydantic_ai._json_schema import flatten_allof
371-
372-
async def flatten_prepare(ctx: RunContext[None], tool: ToolDefinition) -> ToolDefinition:
373-
tool.parameters_json_schema = flatten_allof(tool.parameters_json_schema)
374-
return tool
375-
376-
# Register your tools normally, then pass `prepare_tools=flatten_prepare` to Agent if you want to apply globally.
377-
agent = Agent('openai:gpt-4o', prepare_tools=lambda ctx, tools: [
378-
await flatten_prepare(ctx, t) or t for t in tools
379-
])
380-
```
381-
382-
Alternatively, you can construct tools with a flattened schema at source (e.g., for MCP-exposed tools) using `Tool.from_schema`.
383-
384360
## See Also
385361

386362
For more tool features and integrations, see:

0 commit comments

Comments
 (0)