-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
good first issueGood for newcomersGood for newcomersquestionFurther information is requestedFurther information is requested
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
When switching from OpenAIChatModel to OpenAIResponseModel, I noticed that the input parameter is now mandatory when providing input dependencies to the run() function.
from pydantic import BaseModel
from pydantic_ai import Agent, RunContext
from pydantic_ai.models.openai import OpenAIChatModel, OpenAIResponsesModel
class Payload(BaseModel):
topic: str
sentences: int
payload = Payload(topic="artificial intelligence", sentences=3)
chat_model = OpenAIChatModel("gpt-5-mini")
chat_agent = Agent(chat_model, instructions="Generate an article.", deps_type=Payload)
@chat_agent.instructions
def chat_context(ctx: RunContext[Payload]) -> str:
return f"Topic: {ctx.deps.topic}\nSentences: {ctx.deps.sentences}"
resp_model = OpenAIResponsesModel("gpt-5-mini")
resp_agent = Agent(resp_model, instructions="Generate an article.", deps_type=Payload)
@resp_agent.instructions
def responses_context(ctx: RunContext[Payload]) -> str:
return f"Topic: {ctx.deps.topic}\nSentences: {ctx.deps.sentences}"
res1 = chat_agent.run_sync(deps=payload)
res2 = resp_agent.run_sync(deps=payload)In this case, the first example will run, while the second will throw an error indicating that I need to add the input to the run function.
Is this a limitation from the OpenaiAI Responses API or did the Pydantic team to change this behavior?
For many AI workflows that I build I provide the context of what needs to be done in the instructions, so that at runtime I only need to feed in the structured data. I don't need or want to add another prompt. Sure, I could do agent.run("", deps=payload), but I hope you can see that this feels a bit weird.
Example Code
Python, Pydantic AI & LLM client version
Python 3.12
PAI: 1.11.1
See example
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomersquestionFurther information is requestedFurther information is requested