Skip to content

feat: AG-UI adapter (toolsets) #2101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: toolsets
Choose a base branch
from

Conversation

stevenh
Copy link
Contributor

@stevenh stevenh commented Jun 30, 2025

AG-UI adapter enabling integration with the AG-UI protocol via the Agent.to_ag_ui() method.

This includes examples for all features in the AG-UI dojo.

Fixes: ag-ui-protocol/ag-ui#5

stevenh added 10 commits June 30, 2025 21:26
AG-UI adapter enabling integration with the AG-UI protocol via
the Agent.to_ag_ui() method.

This includes a full example for all features in the AG-UI dojo.

Fixes: ag-ui-protocol/ag-ui/issues/5
Move pydantic_ai_ag_ui to pydantic_ai_slim as ag_ui, updating references
and documentation accordingly.
Refactor to_ag_ui so it now returns a ASGI compatible server based off
starlette. This makes it easier for users setup apps with minimal code.

Fix some invalid references missed in the package refactor for cli and
examples.

Made enums, and exceptions private to the package, so they are not
exposed in the public API.
Eliminate the use of match statement and dataclass(kw_only=True) to
ensure compatibility with Python 3.9.

Remove duplicate import of starlette outside try block, causing tests to
fail when it's not installed.
Disable the deprecation warning for model_fields in Mistral.
Remove invalid no cover comment from Mistral model flagged by
strict-no-cover check.
Add support for the new tool call returns and thinking parts to the
AG UI adapter. This eliminates the need to build a message snapshot
while sill providing the necessary information for the UI.
Allow the agent path to be specified when using to_ag_ui.
Reduce the log level for the request done message in the AG-UI adapter
to debug level.
Add missing `from __future__ import annotations` imports to ensure
ensure that only relevant type annotations are processed at runtime.

Fix incorrect import of `dataclass` in `args.py`.
Copy link
Contributor

hyperlint-ai bot commented Jun 30, 2025

PR Change Summary

Implemented the AG-UI adapter for seamless integration with the AG-UI protocol, enhancing user interaction capabilities for PydanticAI agents.

  • Added comprehensive documentation for the AG-UI adapter and its features.
  • Introduced examples demonstrating the integration of PydanticAI agents with the AG-UI protocol.
  • Updated installation instructions to include AG-UI dependencies.

Modified Files

  • docs/install.md

Added Files

  • docs/ag-ui.md
  • docs/api/ag_ui.md
  • examples/pydantic_ai_ag_ui_examples/README.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@stevenh stevenh force-pushed the feat/ag-ui-adapter-toolset branch from ae3a968 to caddcc0 Compare July 1, 2025 12:21
Switch from additional tools to the new toolset system.
@stevenh stevenh force-pushed the feat/ag-ui-adapter-toolset branch from caddcc0 to 6671164 Compare July 1, 2025 12:35
@DouweM DouweM self-assigned this Jul 1, 2025
@dorukgezici
Copy link
Contributor

dorukgezici commented Jul 2, 2025

Hey! I know this is still a draft, but have been following the development of ag-ui support since I wish to build my MVP with pydantic-ai & ag-ui. Did a test run today on this branch, dropping my findings in case they are helpful:

  • If there are mcp_servers defined in the agent, .to_ag_ui() doesn't handle running the servers, so any request errors out
  • I noticed if the model is trying to chain tool calls, it errors out with a similar error to this even when parallel_tool_calls is disabled:
    pydantic_ai.exceptions.ModelHTTPError: status_code: 400, model_name: gpt-4.1-mini, body: {'message': "Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'tool_calls'.", 'type': 'invalid_request_error', 'param': 'messages.[13].role', 'code': None}

@stevenh
Copy link
Contributor Author

stevenh commented Jul 3, 2025

Great info, keep it coming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants