apps/backend/src/agent/). There is no separate service to start — it activates automatically when a user sends a chat message.
All agent configuration is done via environment variables in apps/backend/.env.
Prerequisites
- Backend running (see Backend Setup)
- An OpenAI or Anthropic API key
Environment variables
Add these toapps/backend/.env:
Model format
TheAGENT_MODEL variable uses provider/model format:
| Value | Provider | Model |
|---|---|---|
openai/gpt-4.1 | OpenAI | GPT-4.1 |
openai/gpt-4o | OpenAI | GPT-4o |
anthropic/claude-sonnet-4-5 | Anthropic | Claude Sonnet 4.5 |
anthropic/claude-opus-4-6 | Anthropic | Claude Opus 4.6 |
Start the backend
The agent starts with the backend — no extra step needed:Sandbox configuration
The agent uses a sandbox for filesystem and shell tools. For local development no extra setup is needed (SPRITES_ENABLED=false). For production, see Sandbox Setup.
Tracing with LangSmith (optional)
To trace agent runs visually:Troubleshooting
Agent doesn't respond in chat
Agent doesn't respond in chat
- Confirm
OPENAI_API_KEY(orANTHROPIC_API_KEY) is set inapps/backend/.env - Check the backend logs for errors from
AgentServiceorChatController - Ensure the database is running and migrations are applied — the agent uses LangGraph checkpointing backed by PostgreSQL
'invalid selectedModelId' error at startup
'invalid selectedModelId' error at startup
AGENT_MODEL must use the provider/model format, e.g. openai/gpt-4.1. A
plain model name like gpt-4o is not valid.Anthropic model not working
Anthropic model not working
Set
ANTHROPIC_API_KEY in apps/backend/.env. The OPENAI_API_KEY is only
needed for OpenAI models.Agent turns get stuck or don't stream
Agent turns get stuck or don't stream
- Check for
AbortErrorin logs — a previous run may still be active. CallPOST /api/v1/chat/stopto cancel it. - Verify
FRONTEND_URLandTRUSTED_ORIGINSinapps/backend/.envare correct, as SSE responses may be blocked by CORS.