Create your first Agent
Goal: create a Provider-backed Agent, attach instructions and tools, and run a simple smoke test with the real APIs in this repository.
Prerequisites
Stack up (Start Guide)
Session cookie or token for an authenticated user
A Provider with at least one Model. Boot seeds Ollama (synced from tags when reachable), OpenAI with
gpt-4o-mini/gpt-4o, and FAL. OpenAI chat needsOPENAI_API_KEYin the host.env(Compose already injects it). Sync is Ollama tags or OpenAIGET /v1/models; FAL has no catalog — add rows by API id.
What you need
Object |
Role |
|---|---|
Provider |
Inference backend (kind, URL, api_key_env name) |
Model |
LLM row under a Provider ( |
Tool |
Catalog row: |
Agent |
|
Create or reuse a Model
List providers and models:
GET /api/provider/
GET /api/model/
Or sync a provider catalog into local Model rows (Ollama tags, OpenAI
/v1/models):
POST /api/provider/<provider_uuid>/sync/
Django shell:
from agency.models import Provider, Model
provider = Provider.objects.filter(name="openai").first()
model = provider.models.filter(name="gpt-4o-mini").first()
Create an Agent
REST (field names from AgentSerializer):
POST /api/agent/
Content-Type: application/json
{
"name": "Researcher",
"instructions": "You are a careful research assistant. Be concise.",
"model_id": "<model-uuid>",
"tool_ids": ["get_datetime"],
"deep": false
}
model_id— PK ofModeltool_ids— PKs ofTool(usually the export attribute name, e.g.get_datetime;definitionis the import pathagency.tools.basic.get_datetime)toolsin responses is read-only nested detail
Python:
from agency.models import Agent, Model, Tool
model = Model.objects.get(id="...")
agent = Agent.objects.create(
name="Researcher",
model=model,
instructions="You are a careful research assistant. Be concise.",
)
tool = Tool.objects.get(id="get_datetime") # if seeded via ensure_default_tools
agent.tools.add(tool)
Smoke test (no Execution lifecycle)
Agent.test builds a one-shot LangGraph invoke with the agent’s model and
tools. It does not create Execution, Thread, Run, or Checkpoint:
POST /api/agent/<agent_uuid>/test/
Content-Type: application/json
{"message": "What time is it?"}
Python:
output = agent.test("What time is it?")
# LangGraph-style dict with "messages", …
Use this to verify model connectivity and tool wiring. For product runs that must be auditable and resumable, use a Mission dispatch instead (Create and execute a Mission).
What persists / what does not
Path |
Persisted |
|---|---|
Creating Agent / tools |
Agent, Tool M2M, Model FK |
|
Nothing in Execution/Thread/Run |
|
Execution, Thread, Run, checkpoints, … (see next tutorials) |
Possible improvements (not implemented)
Skills exist as a model but are not wired to
Agent(no M2M yet).Agent.testand product execute share tools/model but diverge on persistence — easy to confuse; keep them separate in ops docs.
Next: Create and execute a Mission.