-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
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
Following this example to implement the AG-UI protocol:
agent = Agent('openai:gpt-5')
app = FastAPI()
@app.post('/')
async def run_agent(request: Request) -> Response:
accept = request.headers.get('accept', SSE_CONTENT_TYPE)
try:
run_input = AGUIAdapter.build_run_input(await request.body()) #
except ValidationError as e:
return Response(
content=json.dumps(e.json()),
media_type='application/json',
status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
)
adapter = AGUIAdapter(agent=agent, run_input=run_input, accept=accept)
event_stream = adapter.run_stream() #
sse_event_stream = adapter.encode_stream(event_stream)
return StreamingResponse(sse_event_stream, media_type=accept)
If I pass system_prompt directly to the agent or if I use the decorator like this, the agent is executed without the system_prompt:
@agent.system_prompt
def get_agent_instructions(ctx: RunContext[str]) -> str:
print('----LOADING PROMPT----') # this is not printed
return 'Be fun!'
Instead if I use the instructions parameter, agent return a compliant response with the prompt.
Is it possible that AGUIAdapter does not consider system_prompt parameter during execution?
Thanks.