Configure agentflow.json
agentflow.json is the single source of truth for how your API server behaves. This guide walks through each field with examples and explains when to use each option. For a complete reference, see agentflow.json Configuration Reference.
Basic structure
Every agentflow.json must have at least an agent field:
{
"agent": "graph.react:app"
}
This tells the server where to load your compiled graph from. All other fields are optional but recommended for production.
Core fields
agent (required)
The import path to your compiled graph, in the format module:attribute:
{
"agent": "graph.react:app"
}
This import happens when the server starts. The module graph.react is imported and the app attribute is retrieved. The app must be a CompiledGraph instance:
# graph/react.py
from agentflow.core.graph import StateGraph
state_graph = StateGraph(MyState)
# ... add nodes, edges ...
app = state_graph.compile() # app is the compiled graph
Why it matters: If this import fails, the server will not start. Common issues:
- The module does not exist (typo in the path)
- The attribute does not exist on the module
- The module has syntax errors
Debugging: Test the import manually:
python -c "from graph.react import app; print(type(app))"
env (optional)
Path to a .env file containing environment variables:
{
"agent": "graph.react:app",
"env": ".env"
}
The server uses python-dotenv to load this file before importing your graph module. This is useful for:
- Development secrets (API keys, database URLs) that should not be committed to git
- Local overrides of production variables for testing
Example .env:
# API keys
GOOGLE_API_KEY=sk-abc123...
OPENAI_API_KEY=sk-def456...
# Database connections
REDIS_URL=redis://localhost:6379/0
DATABASE_URL=postgresql://user:pass@localhost/mydb
# Feature flags
ENABLE_STREAMING=true
Your graph code accesses them:
import os
api_key = os.environ["GOOGLE_API_KEY"]
Important: Never commit .env files to version control. Add .env to .gitignore.
In production: Pass environment variables via container/process environment, not .env files:
export GOOGLE_API_KEY=...
export REDIS_URL=...
agentflow api --no-reload
Persistence: Checkpointer
Without a checkpointer
Each API request is stateless. There is no conversation history. The next request forgets all prior context.