Testing Locally
Test your agents locally
Test your agents locally before deploying.
Running Your Agent
npx tsx agent.tsThe 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", "hasInvoke": true, "hasChat": 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:
serve(agent, { port: Number(process.env.PORT) || 8080 });Multiple Agents
Test multiple agents at once:
serve([agent1, agent2], { port: 8080 });Each agent is available at /agent/{name}/.
Common Issues
| Issue | Solution |
|---|---|
| Port already in use | Change port or kill the existing process |
| Connection refused | Make sure the server is running |
| 404 Not Found | Check the agent name in the URL |
| 501 Not Implemented | The handler (invoke/chat) isn't registered |
Next Steps
- Client Setup — Call deployed agents
- Examples — See more examples