Testing Locally

Test your agents locally

Test your agents locally before deploying.

Running Your Agent

python agent.py

The server starts on http://localhost:8080 by default.

Health Checks

# Runtime health
curl http://localhost:8080/health
# {"status": "healthy", "agents": ["my-agent"]}

# Agent health
curl http://localhost:8080/agent/my-agent/health
# {"name": "my-agent", "has_invoke": true, "has_chat": true}

Testing Invoke

curl -X POST http://localhost:8080/agent/my-agent/invoke \
  -H "Content-Type: application/json" \
  -d '{"input": {"name": "World"}, "stream": false}'

Response:

{"output": "Hello, World!"}

Testing Chat

curl -X POST http://localhost:8080/agent/my-agent/chat \
  -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "Hello!"}], "stream": false}'

Response:

{"message": {"role": "assistant", "content": "You said: Hello!"}}

Testing Streaming

Add "stream": true to the request:

curl -X POST http://localhost:8080/agent/my-agent/invoke \
  -H "Content-Type: application/json" \
  -d '{"input": {"text": "Hello world"}, "stream": true}'

Custom Port

serve(agent, port=3000)

Or use an environment variable:

import os
serve(agent, port=int(os.environ.get("PORT", 8080)))

Multiple Agents

Test multiple agents at once:

serve([agent1, agent2], port=8080)

Each agent is available at /agent/{name}/.

Common Issues

IssueSolution
Port already in useChange port or kill the existing process
Connection refusedMake sure the server is running
404 Not FoundCheck the agent name in the URL
501 Not ImplementedThe handler (invoke/chat) isn't registered

Next Steps

On this page