Skip to content

feat: AG-UI adapter #2044

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

stevenh
Copy link
Contributor

@stevenh stevenh commented Jun 20, 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/issues/5

Copy link
Contributor

hyperlint-ai bot commented Jun 20, 2025

PR Change Summary

Introduced the AG-UI adapter for integration with the AG-UI protocol, including comprehensive examples for various features.

  • Added AG-UI adapter documentation to facilitate integration with PydanticAI agents.
  • Included detailed examples demonstrating the AG-UI protocol features.
  • Provided prerequisites and setup instructions for running the integration.

Added Files

  • adapter_ag_ui/README.md
  • adapter_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 branch 5 times, most recently from 56fedd1 to 4f9ff50 Compare June 20, 2025 16:32
@DouweM DouweM self-assigned this Jun 20, 2025
@stevenh stevenh force-pushed the feat/ag-ui-adapter branch 7 times, most recently from 9487756 to 1dee214 Compare June 20, 2025 21:55
@stevenh stevenh force-pushed the feat/ag-ui-adapter branch 3 times, most recently from 6fcf59f to 90137ff Compare June 21, 2025 18:54
@stevenh stevenh marked this pull request as ready for review June 21, 2025 22:04
@stevenh
Copy link
Contributor Author

stevenh commented Jun 21, 2025

Ready for review @DouweM, I think I've matched all your standards. The one question is do I need to update to support 3.9? The code currently makes use of match statement which is more elegant way of checking against multiple types. Given 3.9 is 5 years old and EOL in just a few months, might be nice to keep this and just mark as 3.10+, let me know.

I'm hoping we can get some simplification in if we can get ag-ui-protocol/ag-ui#49 merged in time.

There is still the outstanding issue mixing AG-UI and PydanticAI tools in a single run due to no easy way to add PydanticAI tools to the history, have asked the AG-UI team about that here.

I've left TODO's in the code where there's a decision to be made or a future change I could envisage.

@stevenh stevenh force-pushed the feat/ag-ui-adapter branch from 8ea3901 to 131d793 Compare June 22, 2025 16:41
@stevenh
Copy link
Contributor Author

stevenh commented Jun 23, 2025

Quick update, I think I've figured out a way to workaround the local tool calls not being in the history using message snapshots. The fun part is testing as TestModel can't replicate that flow, so looking to expand it's capabilities to cover that.

I'll discuss with @NathanTarbert what the best approach for handling this moving forward when we sync, I might have missed something in their spec which can already achieve it without a full snapshot.

@stevenh stevenh force-pushed the feat/ag-ui-adapter branch 8 times, most recently from 4524407 to 2b5cc15 Compare June 24, 2025 15:13
@stevenh stevenh force-pushed the feat/ag-ui-adapter branch 2 times, most recently from ec3979d to cfefcd6 Compare June 24, 2025 17:23
stevenh added 6 commits June 25, 2025 09:23
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.
@stevenh stevenh force-pushed the feat/ag-ui-adapter branch from fb81b76 to bc9e92a Compare June 25, 2025 08:29
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.

PydanticAI support
2 participants