Skip to content

How to use Agent.to_ag_ui in stdio mode #2400

@RahulDas-dev

Description

@RahulDas-dev

Question

Hi, I'm looking for a way to emit events in stdio mode for Pydantic agents. Specifically, I'd like to capture events such as:

  • PartStartEvent
  • TextMessageStartEvent
  • TextMessageContentEvent
  • ToolCallStartEvent
  • ToolCallEndEvent
  • and Other Events

I've explored using to_ag_ui, but it doesn't seem to support stdio mode. I came across a potential solution in issue #1995, and #2382 which can help me a to implement the same with help of Custom Event Emitter Class.

Before diving into a custom implementation, I'd like to know:

  • Are there any better approaches to achieve this?
  • Does Pydantic AI have plans to introduce built-in event emitters for accessing streaming data in console and UI integrations?

Any guidance or insights would be greatly appreciated.

Here is my custome Event Emiter Class
https://github.com/RahulDas-dev/Pydantic_developer_agent/blob/main/lib/event_sys/bus.py

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions