python, tutorial, traylinx, sdk, code,

Building Your First Traylinx Agent: A Python 'Hello World'

Sebastian Schkudlara Sebastian Schkudlara Follow · 3 mins read
Building Your First Traylinx Agent: A Python 'Hello World'
Share this

Building Your First Traylinx Agent: A Python ‘Hello World’

We’ve covered the Brain, the Router, the Events, and the Security. Now, it’s time to get our hands dirty.

Today, we’re going to build a simple Echo Agent using the traylinx-python-sdk. This agent will:

  1. Register itself with the Registry.
  2. Expose a capability (echo).
  3. Respond to A2A requests.

Let’s go!

Building Agents


Prerequisites

  • Python 3.10+
  • Docker (to run the core services)
  • A sense of adventure

Step 1: Install the SDK

First, let’s install the magic library.

pip install traylinx-agent-sdk

Step 2: The Code

Create a file called echo_agent.py.

import asyncio
from traylinx_agent import Agent, Capability

# 1. Define the Agent
agent = Agent(
    name="echo-agent-v1",
    port=8090,
    secret_token="my-super-secret-token"
)

# 2. Define a Capability
@agent.capability(
    name="echo_service",
    description="I repeat whatever you say",
    keys={"domain": "utility", "op": "echo"}
)
async def echo(message: str):
    """
    Simple echo function.
    """
    print(f"Received: {message}")
    return {
        "response": f"Echo: {message}",
        "agent": agent.name
    }

# 3. Start the Agent
if __name__ == "__main__":
    agent.run()

That’s it. Seriously. No complex configuration, no boilerplate. The SDK handles the FastAPI server, the registration loop, and the heartbeat.


Step 3: What Just Happened?

When you run python echo_agent.py, here is the flow:

sequenceDiagram
    participant A as Echo Agent
    participant R as Agent Registry
    
    Note over A: Startup
    A->>R: POST /a2a/register
    Note right of A: Sends Agent Card:\n{"capabilities": [{"op": "echo"}]}
    R-->>A: 200 OK (Registered)
    
    loop Every 30s
        A->>R: Heartbeat (I'm alive!)
    end

Your agent is now live, registered, and discoverable by the entire network.


Step 4: Testing It

You can test it using curl or another agent.

curl -X POST http://localhost:8080/a2a/route \
  -H "Authorization: Bearer TOKEN" \
  -d '{
    "capabilities": [{"key": "op", "value": "echo"}],
    "payload": {"message": "Hello Traylinx!"}
  }'

Response:

{
  "response": "Echo: Hello Traylinx!",
  "agent": "echo-agent-v1"
}

The Router found your agent based on the op: echo capability and forwarded the request.


Conclusion

Building autonomous agents doesn’t have to be hard. With the Traylinx SDK, you focus on the logic (what the agent does), and the platform handles the plumbing (discovery, routing, security).

This concludes our 5-part series on the Traylinx Ecosystem. We’ve gone from “Amnesic Chatbots” to “Secure, Event-Driven, Collaborative Agent Swarms.”

Now, go build something amazing.

Happy Coding!

Sebastian Schkudlara
Written by Sebastian Schkudlara Follow
Hi, I am Sebastian Schkudlara, the author of Jevvellabs. I hope you enjoy my blog!