Skip to main content
Agents are a stateful control loop around a stateless model. The model reasons and calls tools in a loop, guided by instructions. Add memory, knowledge, tools, guardrails, and middleware as needed.
from definable.agent import Agent
from definable.tool.decorator import tool

@tool
def search_web(query: str) -> str:
    """Search the web for information."""
    return f"Results for: {query}"

agent = Agent(
    model="gpt-4o",
    tools=[search_web],
    instructions="You are a research assistant.",
)

output = agent.run("What are the latest developments in quantum computing?")
print(output.content)

Guides

Build Agents

Create agents with tools and instructions.

Run Agents

Execute agents sync, async, and with streaming.

Configure Agents

Control retries, limits, compression, and tracing.

Key Concepts

ConceptWhat it does
ToolsFunctions the agent can call to take actions
KnowledgeRAG pipeline for grounding responses in documents
MemoryPersistent session history across conversations
ThinkingReasoning phase before generating responses
MiddlewareComposable wrappers for logging, retries, metrics
TracingStructured event export for debugging
SecurityTool policies, rate limiting, prompt injection detection
EvaluationAccuracy, performance, and reliability testing

Beyond Single Agents

AbstractionWhat it does
TeamMultiple agents that coordinate, route, collaborate, or divide tasks
WorkflowOrchestrate agents through sequential, parallel, conditional, and iterative steps

Usage Examples

Agent with Tools

Multiple tools with parallel execution.

Agent with Knowledge

RAG-grounded responses from documents.

Agent with Memory

Persistent memory across conversations.

Structured Output

Return typed Pydantic models.

Streaming

Stream tokens in real time.

Resources