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

Merged
merged 45 commits into from
May 13, 2025
Merged

Add A2A server #1537

merged 45 commits into from
May 13, 2025

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.

Copy link

github-actions bot commented Apr 18, 2025

Docs Preview

commit: 50941c0
Preview URL: https://249ec82b-pydantic-ai-previews.pydantic.workers.dev

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.

self.description = description
self.provider = provider
self.skills = skills or []
# NOTE: For now, I don't think there's any reason to support any other input/output modes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would other input/output modes be necessary for multi-modal inputs/outputs? If so, you might want to not emphasize that as a value prop in the docs (it currently lists "- Rich Communication: Support for multimodal content exchange (text, structured data, files)" as something the protocol "facilitates").

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this input/output modes are not necessary for it.

Comment on lines 58 to 64
#### Worker

The `Worker` is responsible for both scheduling tasks and executing them.

#### Worker

The `Worker` is the component that defines how the task is executed.
Copy link
Contributor

Choose a reason for hiding this comment

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

please fix

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess need to mention broker or something

@Kludex Kludex enabled auto-merge (squash) May 13, 2025 10:17
@Kludex Kludex merged commit f86b702 into main May 13, 2025
17 checks passed
@Kludex Kludex deleted the a2a branch May 13, 2025 10:19
@codefromthecrypt
Copy link

@Kludex thanks for developing this. I noticed "Opinions A2A" in your desc and had similar sentiments when I looked at the protocol and the various SDK examples. I felt it is a protocol for defining state machines but with a lot of flexibility about the transitions seems heavy lifting for most, resulting in framework dependence in all likelihood.

I think what you've done is hide the incidental complexity under a .to_a2a() wrapper. so for example users neither need to make an executor, nor make state machine decisions just to define and use an agent.

Considering this, I'm still curious as to how much interop can occur due to the same thing, though on the other hand notice a lot of samples (and some "examples" in the new SDK).

If you end up with any examples of interop with the pydantic a2a, please ping. Also, if you have any summary comments that feel different than your initial let me know, too.

Meanwhile, I'm also quite interested in ACP which feels at a glance simpler to grok, so hope you have an example of that at some point.

@codefromthecrypt
Copy link

ps the new SDK for A2A exists, but it isn't published and I didn't see any pinging of others about it on related issues. my playground has been using git for the package https://github.com/google/A2A/tree/main/a2a-python-sdk

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