Skip to content

Add A2A server #1537

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 7 commits into
base: main
Choose a base branch
from
Draft

Add A2A server #1537

wants to merge 7 commits into from

Conversation

Kludex
Copy link
Member

@Kludex Kludex commented Apr 18, 2025

This PR implements the FastA2A - an easy way to serve an agent using the A2A protocol.

We need to make some decisions here.

High level decisions

  • Should this code live in Pydantic AI? I'm happy to move it away - it may be better.
  • Currently there's a client in the A2A repository, but I didn't like their work. Also, they didn't publish on PyPI...
  • On MCP there's an inspector client which makes life easier. This protocol still doesn't have such a thing. It makes the experience of developing A2A servers poor.

Low level decisions

  • Is the architecture right? Something feels a bit odd regarding the worker/runner, and the fact that I need to pass the agent on the FastA2A. Something is wrong here.

Checklist

  • Tests
  • Documentation

Opinions A2A

Honestly, after developing this, I'm not sure if the protocol will thrive. It seems the specification was written in a hurry, it misses a lot of examples, and it doesn't specify how the workflows should be.

To be more concrete, let's say we want to send a task. It's (supposedly) the simplest workflow. When you send a task, you have some options:

  1. You can execute the agent, and either send a "complete", "failed" or "input-required" response.
  2. You can schedule a task on the background, and send back the task id and a status "submitted".

How do we choose? Thinking about the best HTTP practices, ideally, we should send back an id, and run the task in the background... And that's what I did. That's more complicated tho, and also, is it really necessary? I can't make a simple developer-facing code without making this decision, because it implies in infrastructure changes.

In any case, I've developed this incomplete PR, which I hope we can discuss and refine in the next days.

from .applications import FastA2A
from .schema import Skill

__all__ = ['FastA2A', 'Skill']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add the other classes here.

Copy link

github-actions bot commented Apr 18, 2025

Docs Preview

commit: 068a9ac
Preview URL: https://87ecd93a-pydantic-ai-previews.pydantic.workers.dev

main.py Outdated
from pydantic_ai.a2a import FastA2A

agent = Agent(name='Potato Agent')
app = FastA2A(agent)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
app = FastA2A(agent)
app = FastA2A.from_agent(agent)
app = FastA2A.from_graph(graph, get_first_node: Callable[[list[Message], BaseNode])

Copy link
Contributor

hyperlint-ai bot commented Apr 30, 2025

PR Change Summary

Implemented the FastA2A library to facilitate the development of A2A servers, enhancing interoperability between AI agents.

  • Introduced the FastA2A library for serving agents using the A2A protocol
  • Added comprehensive documentation for the A2A protocol and FastA2A usage
  • Outlined design components including TaskManager, Worker, and Runner

Added Files

  • docs/a2a.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.

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.

2 participants