Observed since 20 Oct, 16:25 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
A lightweight bridge between PocketFlow and the Agent2Agent protocol
A2AFlow combines the minimalist approach of PocketFlow with Google's Agent2Agent (A2A) protocol, creating a powerful yet lightweight framework for building interoperable AI agents.
# Install UV if you don't have it already
pip install uv
# Install A2AFlow
uv sync
pip install a2aflow
# Clone the repository
git clone https://github.com/your-username/A2AFlow.git
cd A2AFlow
# Using UV (recommended)
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv sync --group dev --group docs
# Using Pip
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e ".[dev,docs]"
from a2aflow import A2ANode, A2AFlow, A2AServer
# 1. Define your agent node
class QuestionAnswerNode(A2ANode):
def exec(self, query):
return f"The answer to '{query}' is 42!"
# 2. Create a flow with A2A capabilities
qa_node = QuestionAnswerNode()
flow = A2AFlow(
start=qa_node,
capabilities={"streaming": True, "pushNotifications": False},
skills=[{"id": "qa_skill", "name": "Question answering"}]
)
# 3. Start the A2A server
server = A2AServer(
flow=flow,
host="localhost",
port=10000
)
server.start()
from a2aflow import A2AClient
# Connect to an A2A server
client = A2AClient(url="http://localhost:10000")
# Send a task and get response
response = await client.send_task("What is the meaning of life?")
print(response["result"]["status"]["message"]["parts"][0]["text"])
# Output: The answer to 'What is the meaning of life?' is 42!
from a2aflow import AsyncA2ANode, A2AFlow, A2AServer
import asyncio
class StreamingNode(AsyncA2ANode):
async def exec_async(self, query):
for i in range(5):
yield f"Processing step {i+1}..."
await asyncio.sleep(0.5)
yield f"Final answer: {query} → Completed!"
# Create and start server with streaming capabilities
flow = A2AFlow(start=StreamingNode(), capabilities={"streaming": True})
server = A2AServer(flow, host="localhost", port=10000)
server.start()
from a2aflow import A2ANode, A2AFlow, A2AServer
class ConversationNode(A2ANode):
def prep(self, shared):
# Initialize conversation history
if "history" not in shared:
shared["history"] = []
# Get query and pass history for context
query = self._get_user_query(shared.get("a2a_request", {}).get("params", {}))
return {"query": query, "history": shared["history"]}
def exec(self, inputs):
query, history = inputs["query"], inputs["history"]
# Simple response based on history length
if not history:
response = f"Hello! You said: {query}"
else:
response = f"You've sent {len(history)+1} messages. Most recent: {query}"
return response
def post(self, shared, prep_res, exec_res):
# Update conversation history
shared["history"].append({"query": prep_res["query"], "response": exec_res})
return "default"
# Create and start conversation agent
flow = A2AFlow(start=ConversationNode())
server = A2AServer(flow, host="localhost", port=10000)
server.start()
For more detailed documentation, examples, and tutorials, visit our documentation site.
A2AFlow supports all the design patterns from PocketFlow:
Plus A2A-specific patterns:
A2AFlow implements the full A2A protocol specification:
We welcome contributions! Please see CONTRIBUTING.md for details on how to get started.
We recommend using UV for development:
# Clone the repository
git clone https://github.com/your-username/A2AFlow.git
cd A2AFlow
# Create and activate a virtual environment
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies including development and documentation groups
uv sync --group dev --group docs
# Run tests
pytest
This project is licensed under the MIT License - see the LICENSE file for details.
A2AFlow is built on two amazing projects:
Special thanks to all contributors to both projects.
Built with ❤️ by ClosedLoop and the community
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.1 | 14 Apr 2025 | 10 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 16:25 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:dc9e10aa28c05ededb8d189285454ba4e00be157bd3fb5076d4a71a2b91c28e8