Agents SDK

Troubleshooting

Common issues and how to fix them.

The API returns fewer messages than expected

Make sure you're sending the full message history on each sendMessage call. The platform persists whatever history you send — if you only send the last message, only that message will be stored in our database. The agent itself knows the full history from its local files, but the API response reflects what you sent.

Auth & token issues

  • 401 Unauthorized — your API key is missing or invalid. Re-run an login or check API_KEY_21ST in your environment.
  • Token exchange failing — ensure your /api/an-token route is correctly calling createTokenHandler with a valid API key.

Agent not responding

  • Sandbox expired — idle sandboxes are destroyed after a timeout. The next message will create a new sandbox automatically.
  • Max turns reached — the agent hit its maxTurns limit. Increase it in the agent config or per-request via options.maxTurns.
  • Budget exceeded — if maxBudgetUsd is set and the cost exceeds it, the agent stops.

Tool permission errors

If the agent can't execute a tool, check the permission mode in your agent config. In default mode, risky tools require user confirmation. Use bypass for fully autonomous agents in isolated sandboxes.

SSE streaming drops or doesn't start

Ensure your client supports Server-Sent Events and that no proxy or CDN is buffering the response. Check the Logs page in the dashboard for error details on the specific dialog.

Deploy fails

  • Missing entry point — ensure agents/<slug>/index.ts exists with a default export using agent().
  • Invalid API key — re-run an login.
  • Bundle too large — keep agent code small, avoid heavy dependencies in the entry point.