Getting Started with Agent Communication Protocol (ACP): Build a Weather Agent with Python

The ACP Communication Protocol is an open standard designed to enable smooth communication between artificial intelligence agents, applications and humans. Since artificial intelligence systems are often developed using various business frameworks and infrastructure, they may end up with isolated and incompatible, which limits their ability to cooperate. ACP treats this fragmentation by providing a unified comfortable applications programming interface:
- Multimedia communication
- Both simultaneous and non -simultaneous messages
- Agree in real time
- Supporting the interactions of the quiet and non -sexual agent
- Discovering agents, whether online or not connected
- Long -term tasks
In this tutorial, we will take our first steps with ACP by creating a basic server that provides weather in London and a simple customer who can interact with him.
Preparation of dependencies
Install libraries
pip install acp acp-sdk beeai-framework httpx
Create an ACP server
We will start preparing an ACP server, starting with creation agent file.
We will start importing the necessary libraries. To bring weather data in London, we will use the HTTPX
import asyncio
from collections.abc import AsyncGenerator
import httpx
from acp_sdk.models import Message, MessagePart
from acp_sdk.server import Context, RunYield, RunYieldResume, Server
server = Server()
Next, we will determine the simultaneous assistant function called Get_london_weather that recalls the current weather in London using an open meteo application programming interface. This function sends a request with London’s coordinates, return the coordinated weather summary, including temperature, wind speed, and weather symbol.
async def get_london_weather() -> str:
"""Fetch current London weather from the free Open‑Meteo API."""
params = {
"latitude": 51.5072, # London coordinates
"longitude": -0.1276,
"current_weather": True,
"timezone": "Europe/London"
}
url = "https://api.open-meteo.com/v1/forecast"
async with httpx.AsyncClient(timeout=10) as client:
resp = await client.get(url, params=params)
resp.raise_for_status()
cw = resp.json()["current_weather"]
return (
f"Weather in London: {cw['temperature']} °C, "
f"wind {cw['windspeed']} km/h, code {cw['weathercode']}."
)
This symbol defines an ACP agent using @server.agent () Decorarator. The London_weather_agement function deals with the messages received by the return first of an intellectual message, then brings in an unfinished weather in London using the Get_london_weather assistant (). Then the weather data is returned as a clear text message. Finally, Server.run () starts an ACP server and makes the agent available to deal with requests
@server.agent()
async def london_weather_agent(
input: list[Message], context: Context
) -> AsyncGenerator[RunYield, RunYieldResume]:
"""Returns current London weather."""
for _ in input:
yield {"thought": "Fetching London weather..."}
weather = await get_london_weather()
yield Message(
role="agent",
parts=[MessagePart(content=weather, content_type="text/plain")]
)
server.run()
Run the server
Next, we will run the Agent.Py file to start the server. Once it is run, the ACP agent will be available to deal with requests in http: // Localhost: 8000
To check that your agent is running, open a new station and implement the following Curl order:
curl http://localhost:8000/agents
If everything is working properly, you will receive your JSON response menu, which confirms that it is available and ready to deal with requests.
{
"agents": [
{
"name": "london_weather_agent",
"description": "Returns current London weather.",
"metadata": {
"annotations": null,
"documentation": null,
"license": null,
"programming_language": null,
"natural_languages": null,
"framework": null,
"capabilities": null,
"domains": null,
"tags": null,
"created_at": null,
"updated_at": null,
"author": null,
"contributors": null,
"links": null,
"dependencies": null,
"recommended_models": null
},
"input_content_types": [
"*/*"
],
"output_content_types": [
"*/*"
]
}
]
}
Create an ACP customer
We will now create an ACP customer (Client.py) To interact with our servant.
This client text program uses ACP SDK to call London_weather_Agen that works locally via ACP server on http: // Localhost: 8000. He sends a simultaneous message asking about the weather using the Run_Sync method. Once the agent responds, the text program prints the weather details.
import asyncio
from acp_sdk.client import Client
from acp_sdk.models import Message, MessagePart
async def call_london_weather_agent() -> None:
async with Client(base_url="http://localhost:8000") as client:
run = await client.run_sync(
agent="london_weather_agent",
input=[
Message(
parts=[MessagePart(content="Tell me the weather", content_type="text/plain")]
)
],
)
print("Response from london_weather_agent:")
for message in run.output:
for part in message.parts:
print("-", part.content)
if __name__ == "__main__":
asyncio.run(call_london_weather_agent())
Customer operation
At another station, run the next order to send the request to our ACP server
You should see a response from the server that contains the current weather in London, is returned by London_weather_Agen.
Response from london_weather_agent:
- Weather in London: 20.8 °C, wind 10.1 km/h, code 3.
verify Symbols. All the credit for this research goes to researchers in this project. Also, do not hesitate to follow us twitterand YouTube and Spotify And do not forget to join 100K+ ML Subreddit And subscribe to Our newsletter.
I am a graduate of civil engineering (2022) from Islamic Melia, New Delhi, and I have a strong interest in data science, especially nervous networks and their application in various fields.
Don’t miss more hot News like this! AI/" target="_blank" rel="noopener">Click here to discover the latest in AI news!
2025-07-07 02:34:00