Skip to content

Callback/Middleware for responses on run_ag_ui #2398

@ChuckJonas

Description

@ChuckJonas

Description

The new run_ag_ui() and handle_ag_ui_request() methods solve the issues around configuring agents per request (TY!), but there is currently no easy way to access the agents output after the run completes.

We can't await the run and access all_messages() as we need to start the response event stream immediately.

One solution might be to add middleware or a callback that could be registered to receive messages as they are generated (or just called when done).

References

https://bb687e8b-pydantic-ai-previews.pydantic.workers.dev/ag-ui/#design
https://ai.pydantic.dev/message-history/#accessing-messages-from-results

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions