{ id: "my-project-echo-skill" name
: "Echo Tool", description: "Echos the input given", tags: ["echo", "repeater"], examples: ["I will see this echoed back to me"], inputModes: ["text"], outputModes: ["text"] }
import google_a2a from google_a2a.common.types import AgentSkill
defmain(): skill = AgentSkill( id="my-project-echo-skill", name="Echo Tool", description="Echos the input given", tags=["echo", "repeater"], examples=["I will see this echoed back to me"], inputModes=["text"], outputModes=["text"], ) print(skill)
if __name__ == "__main__": main()
如果遇到模块错误,请尝试以下方式:
from common.types import AgentSkill
# 相同的代码
测试运行
让我们运行一下:
uv run my-project
输出应该类似于这样:
id='my-project-echo-skill' name='Echo Tool' description='Echos the input given' tags=['echo', 'repeater'] examples=['I will see this echoed back to me'
] inputModes=['text'] outputModes=['text']
INFO:root:id='my-project-echo-skill' name='Echo Tool' description='Echos the input given' tags=['echo', 'repeater'] examples=['I will see this echoed back to me'] inputModes=['text'] outputModes=['text'] INFO:root:name='Echo Agent' description='This agent echos the input given' url='http://localhost:10002/' provider=None version='0.1.0'
documentationUrl=None capabilities=AgentCapabilities(streaming=False, pushNotifications=False, stateTransitionHistory=False) authentication=None defaultInputModes=['text'] defaultOutputModes=['text'] skills=[AgentSkill(id='my-project-echo-skill', name='Echo Tool', description='Echos the input given', tags=['echo', 'repeater'], examples=['I will see this echoed back to me'], inputModes=['text'], outputModes=['text'])]
INFO:root:id='my-project-echo-skill' name='Echo Tool' description='Echos the input given' tags=['echo', 'repeater'] examples=['I will see this echoed back to me'] inputModes=['text'] outputModes=['text'] INFO:root:name='Echo Agent' description='This agent echos the input given' url='http://localhost:10002/' provider=None version='0.1.0' documentationUrl=None capabilities=AgentCapabilities(streaming=False, pushNotifications=False, stateTransitionHistory=False) authentication=None defaultInputModes=['text'] defaultOutputModes=['text'] skills=[AgentSkill(id='my-project-echo-skill', name='Echo Tool', description='Echos the input given', tags=['echo', 'repeater'], examples=['I will see this echoed back to me'], inputModes=['text'], outputModes=['text'])] INFO: Started server process [582] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://localhost:10002 (Press CTRL+C to quit)
# 这应该已经在您的终端中运行 $ uv run my-project INFO: Started server process [20538] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://localhost:10002 (Press CTRL+C to quit)
在同一目录中打开一个新终端:
source
.venv/bin/activate uv run google-a2a-cli --agent http://localhost:10002
# 如果出错,请尝试这个(确保.venv/lib/python3.13/site-packages中有一个hosts目录): uv run python -m hosts.cli --agent http://localhost:10002
git clone git@github.com:google/A2A.git cd samples/python/hosts/cli uv run . --agent [url-of-your-a2a-server]
然后您可以通过输入并按Enter键向服务器发送消息:
========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit): Hello!
如果一切正常,您将在响应中看到:
$ uv run python -m hosts.cli --agent http://localhost:10002 ======= Agent Card ======== {"name":"Echo Agent","description":"This agent echos the input given","url":"http://localhost:10002/","version":"0.1.0","capabilities":{"streaming":false,"pushNotifications":false,"stateTransitionHistory":false},"defaultInputModes":["text"],"defaultOutputModes":["text"],"skills":[{"id":"my-project-echo-skill",
"name":"Echo Tool","description":"Echos the input given","tags":["echo","repeater"],"examples":["I will see this echoed back to me"],"inputModes":["text"],"outputModes":["text"]}]} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit): hello Select a file path to attach? (press enter to skip):
{"jsonrpc":"2.0","id":"5b3b74b7ea80495daff4047ee48a6c48","result":{"id":"740f1e21465b4ee2af4af7b8c6cacad5","sessionId":"7fbd065264cb4d6c91ed96909589fc35","status":{"state":"completed","message":{"role":"agent","parts":[{"type":"text","text":"on_send_task received: hello"}]},"timestamp":"2025-05-03T22:18:41.649600"},"artifacts":[{"parts":[{"type":"text","text":"on_send_task received: hello"}],"index":0}],"history":[{"role":"user","parts":[{"type":"text","text":"hello"}]}]}} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit):
$ uv run python -m hosts.cli --agent http://localhost:10002 ======= Agent Card ======== {"name":"Echo Agent","description":"This agent echos the input given","url":"http://localhost:10002/","version":"0.1.0","capabilities":{"streaming":true,"pushNotifications":false,"stateTransitionHistory":false},"defaultInputModes":["text"],
"defaultOutputModes":["text"],"skills":[{"id":"my-project-echo-skill","name":"Echo Tool","description":"Echos the input given","tags":["echo","repeater"],"examples":["I will see this echoed back to me"],"inputModes":["text"],"outputModes":["text"]}]} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit): Streaming? Select a file path to attach? (press enter to skip): stream event => {"jsonrpc":"2.0","id":"c6f21c0b7e5e497caaca4a692aaefd7a","result":{"id":"d7218dd3c122477c89d62e7d897fea0b","status":{"state":"working","message":{"role":"agent","parts":[{"type":"text","text":"Streaming?: one"}]},"timestamp":"2025-05-03T22:22:31.354656"},"final":false}} stream event => {"jsonrpc":"2.0","id":"c6f21c0b7e5e497caaca4a692aaefd7a","result":{"id":"d7218dd3c122477c89d62e7d897fea0b","status":{"state":"working","message":{"role":"agent","parts":[{"type":"text","text":"Streaming?: two"}]},"timestamp":"2025-05-03T22:22:31.354684"},"final":false}} stream event => {"jsonrpc":"2.0","id":"c6f21c0b7e5e497caaca4a692aaefd7a","result":{"id":
"d7218dd3c122477c89d62e7d897fea0b","status":{"state":"completed","message":{"role":"agent","parts":[{"type":"text","text":"Streaming?: three"}]},"timestamp":"2025-05-03T22:22:31.354698"},"final":true}} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit):
uv run python -m hosts.cli --agent http://localhost:10002 ======= Agent Card ======== {"name":"Echo Agent","description":"This agent echos the input given","url":"http://localhost:10002/","version":"0.1.0","capabilities":{"streaming":true,"pushNotifications":false,"stateTransitionHistory":false},"defaultInputModes":["text"],"defaultOutputModes":["text"],"skills"
:[{"id":"my-project-echo-skill","name":"Echo Tool","description":"Echos the input given","tags":["echo","repeater"],"examples":["I will see this echoed back to me"],"inputModes":["text"],"outputModes":["text"]}]} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit): Streaming? Select a file path to attach? (press enter to skip): stream event => {"jsonrpc":"2.0","id":"18357b72fc5841ef8e8ede073b91ac48","result":{"id":"b02f6989e72f44818560778d39fcef18","status":{"state":"working","message":{"role":"agent","parts":[{"type":"text","text":"Streaming?: one"}]},"timestamp":"2025-05-04T09:18:18.235994"},"final":false}} stream event => {"jsonrpc":"2.0","id":"18357b72fc5841ef8e8ede073b91ac48","result":{"id":"b02f6989e72f44818560778d39fcef18","status":{"state":"working","message":{"role":"agent","parts":[{"type":"text","text":"Streaming?: two"}]},"timestamp":"2025-05-04T09:18:18.236021"},"final":false}} stream event => {"jsonrpc":"2.0","id":"18357b72fc5841ef8e8ede073b91ac48","result":{"id":"b02f6989e72f44818560778d39fcef18","status":{
"state":"working","message":{"role":"agent","parts":[{"type":"text","text":"Streaming?: three"}]},"timestamp":"2025-05-04T09:18:18.236033"},"final":false}} stream event => {"jsonrpc":"2.0","id":"18357b72fc5841ef8e8ede073b91ac48","result":{"id":"b02f6989e72f44818560778d39fcef18","status":{"state":"input-required","message":{"role":"agent","parts":[{"type":"text","text":"Would you like more messages? (Y/N)"}]},"timestamp":"2025-05-04T09:18:18.236044"},"final":true}} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit): N Select a file path to attach? (press enter to skip): stream event => {"jsonrpc":"2.0","id":"86ce510ba68b4797a5b68061c8c4780b","result":{"id":"64e51665dc354d2da7c31bcc45abc8f9","status":{"state":"completed","message":{"role":"agent","parts":[{"type":"text","text":"All done!"}]},"timestamp":"2025-05-04T09:22:24.598749"},"final":true}} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit):
======= Agent Card ======== {"name":"Echo Agent","description":"This agent echos the input given","url":"http://localhost:10002/","version":"0.1.0","capabilities":{"streaming":false,"pushNotifications":false,"stateTransitionHistory":false},"defaultInputModes":["text"],"defaultOutputModes":["text"],"skills":[{"id":"my-project-echo-skill","name"
:"Echo Tool","description":"Echos the input given","tags":["echo","repeater"],"examples":["I will see this echoed back to me"],"inputModes":["text"],"outputModes":["text"]}]} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit): hey Select a file path to attach? (press enter to skip):
{"jsonrpc":"2.0","id":"eca7ecf4d6da4a65a4ff99ab0954b957","result":{"id":"62636e021ac0483bb31d40c1473796fa","sessionId":"438927e3540f459389f3d3cb216dd945","status":{"state":"completed","message":{"role":"agent","parts":[{"type":"text","text":"\nOkay, the user just said \"hey\". That's a pretty open-ended greeting. I need to respond in a friendly and welcoming way. Maybe start with a greeting like \"Hi there!\" to keep it casual. Then, ask how I can assist them. Since they didn't specify a topic, I should keep the response general but inviting. Let me make sure the tone is positive and approachable. Also, check if there's any specific context I should consider, but since there's no prior conversation, it's safe to assume they just want to start a new interaction. Alright, time to put that together.\n\n\nHi there! How can I assist you today? 😊"}]},"timestamp":"2025-05-04T10:01:55.068049"},"artifacts":[{"parts":[{"type":"text","text":"\nOkay, the user just said \"hey\". That's a pretty open-ended greeting. I need to respond in a friendly and welcoming way. Maybe start with a greeting like \"Hi there!\" to keep it casual. Then, ask how I can assist them. Since they didn't specify a topic, I should keep the response general but inviting. Let me make sure the tone is positive and approachable. Also, check if there's any specific context I should consider, but since there's no prior conversation, it's safe to assume they just want to start a new interaction. Alright, time to put that together.\n\n\nHi there! How can I assist you today? 😊"}],"index":0}],"history":[{"role":"user","parts":[{"type":"text","text":"hey"}]}]}} ========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit):
恭喜!您现在拥有一个使用AI模型生成响应的A2A服务器!
目前有关 A2A的实现都很简陋,包括官方的,其他的一些参考如下:
Name
Author
Description
Stars
a2ajava
@vishalmysore
A pure Java implementation of Google's A2A protocol for Spring Boot applications, featuring both client and server implementations
Stars
legion-a2a
@TheRaLabs
A TypeScript implementation of the A2A protocol with a focus on modularity and extensibility
Stars
trpc-a2a-go
@trpc-group
Go A2A implementation by the tRPC team featuring full client/server support, in-memory task management, streaming responses, session management, multiple auth methods (JWT, API Key, OAuth2), and comprehensive examples
Stars
jira-a2a
@tuannvm
The Jira A2A system is a DevOps workflow automation platform using the tRPC-A2A-Go framework. It consists of independent Go agents that communicate via A2A messages.
Stars
a2a-go
@a2aserver
A Go library for building A2A servers, with example implementations
Stars
a2a-rs
@EmilLindfors
An idiomatic Rust implementation following hexagonal architecture principles
Stars
a2a_min
@pcingola
A minimalistic Python SDK for A2A communication
Stars
a2adotnet
@azixaka
A C#/.NET implementation of the A2A protocol
Stars
nestjs-a2a
@thestupd
A module for integrating the A2A protocol into NestJS applications
Stars
python-a2a
@themanojdesai
An easy-to-use Python library for implementing the A2A protocol
Stars
Aira
@IhateCreatingUserNames2
An A2A network implementation for hosting, registering, discovering, and interacting with agents
Stars
Cognisphere
@IhateCreatingUserNames2
An AI agent development framework built on Google's ADK, facilitating agent creation potentially for A2A networks
Stars
a2a-server
@chrishayuk
A lightweight A2A python implementation
Stars
a2a-cli
@chrishayuk
A command-line client for the A2A
Stars
A2A Test Suit
@robert-at-pretension-io
A2A Test Suite
Stars
Grasp
@adcentury
A Self-hosted Browser Using Agent with built-in MCP and A2A support
Stars
swissknife
@daltonnyx
A multi-agent chat application with MCP support, aiming to expose agents via the A2A protocol and connect to remote A2A agents as a client
Stars
artinet-sdk
@the-artinet-project
A JS/TS SDK for the Agent2Agent Protocol with a focus on developer experience and comprehensive features
Stars
一些社区的案例:
Name
Author
Description
Stars
a2a-agent-coder
@sing1ee
A Coder Agent implementation with A2A Server and Client
Stars
agentic-trading
@kweinmeister
A sample application demonstrating Google ADK and A2A interoperability for trading automation
Stars
python-a2a-tutorial
@sing1ee
A comprehensive tutorial for implementing A2A in Python with practical examples