-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Feature requestNew feature requestNew feature request
Description
Description
I've been trying to get some stuff to work with AG-UI and run into some annoying issues when trying to get more complex patterns to work with the ag_ui
classes and methods exposed.
Here are some suggestions for things I think the module is currently lacking:
- Parsing and holding the state: I can't see a clean way to use the current
AGUIApp
class orhandle_ag_ui_request
/run_ag_ui
methods to:- convert an incoming request into data that pydantic_ai agents can natively handle without writing my own tedious methods which are extremely close to the methods in the
ag_ui
module - allow multiple agents to do things relating to an incoming request and have access to the events/messages that have been sent by other agents. (This potentially raises some design questions about the
AGUIApp
class having a singleagent
attribute.) - expose/handle the shared state data object (e.g.
AgentState
patterns) more cleanly - allow for some more interesting tool handling (I'm imagining being able to filter/alter the tools that are exposed)
- convert an incoming request into data that pydantic_ai agents can natively handle without writing my own tedious methods which are extremely close to the methods in the
- Better error handling: My
AGUIApp
falls over due to errors all the time because I can't intercept the way thehandle_ag_ui_request
/run_ag_ui
methods deal with an error- this might be a skill issue, but it's been a headache for me. I am having it fall over despite defining a retry_client a la
retries
- should there be a
ag_ui
method that can consume an arbitraryAsyncIterator[str]
stream and interpret it as an agent output?
- this might be a skill issue, but it's been a headache for me. I am having it fall over despite defining a retry_client a la
- Methods for emitting events without tools: This seems to be a common issue for a lot of people using the AG-UI framework (take this for example) and not one I feel pydantic_ai has a clean solution for yet.
- I think adding something that allows a really simple way to emit an event without it being a tool would be very useful
- Support agents with structured outputs: this greatly impedes plugging agents into AGUIApps in creative ways.
- There are ways around this and I've already litigated this issue here, but I think it should still be mentioned in this laundry list of ideas
- Make it easier to return data in tool calls to front end client: It's a bit clunky getting your agent to sync up the results of tool calls with frontend actions at the moment.
- this is another one that might just be a skill issue, but something I've found challenging presently is an agent rendering a large table of data to the frontend without that dataset living in my agents context window in subsequent requests. It may be that the docs just need some good examples (e.g. I've been pointed to this repo which I'm in the process of working through) for me to wrap my head around how this is supposed to work. But are we sure this is the pattern we want for simple frontend actions?
- There are work arounds (e.g.
AgentState
patterns, etc), but I haven't found any patterns that are particularly nice to use yet. - Upon doing a little bit more reading, it seems most of what I'm asking for is answered in this bit of doco: https://ai.pydantic.dev/ag-ui/#events so perhaps this point is moot!
- More explicit control of actions between events:
run_ag_ui
elegantly handles the basics, but perhaps it would be useful to have somewith LifecycleEvent(...) as le:
context management to begin/end event streams.
I hope I haven't overstepped here by making all of these suggestions and I want to conclude by saying that I've been so impressed with what this library has allowed me to do and I owe the main contributors a huge debt of gratitude for all the hard work they've put in!
References
- Pydantic AI AG-UI Docs
- AG-UI Protocol docs
ag_ui
moduleAgentState
pattern- CrewAI custom
copilotkit_emit_message
method: Looking at the Issues and Discord of CopilotKit, this comes up a lot in user related issues - ag_ui module not working with structured
output_type
#3011 : A previous issue I raised aboutoutput_type
causing problems - pydantic-ai x ag-ui demo that I was pointed to
Metadata
Metadata
Assignees
Labels
Feature requestNew feature requestNew feature request