Agent API Reference
TheAgent class is the primary runtime component of BindAI.
An agent combines a model provider with instructions, tools, memory, Knowledge, and execution behavior to process requests.
This page documents the current public Agent API and the main components that interact with it.
Overview
An Agent can:- Receive user input.
- Execute requests through a configured model provider.
- Use instructions and runtime context.
- Invoke registered tools.
- Access Memory.
- Retrieve Knowledge.
- Return an
AgentResult. - Stream generated output.
- Participate in workflows.
- Participate in multi-agent execution.
Creating an Agent
The recommended programmatic construction API isAgent.builder().
- Name
- Description
- Instructions
- Model provider
- Tools
- Memory
- Knowledge
- Retriever
- Middleware
- Hooks
- Callbacks
- Execution configuration
run()
run() executes the agent for a user message and returns an AgentResult.
run() is the primary API for complete, non-streaming agent execution.
AgentResult
Successful execution returns anAgentResult.
The primary properties are:
For example:
success before relying on the output.
stream()
stream() provides incremental agent output.
- Chat interfaces
- Interactive assistants
- Long responses
- User-facing applications
run() because it exposes incremental output rather than a single completed AgentResult.
Structured Output
Agents can be configured to produce structured results using a supported output type. For example, a Pydantic model can define the expected structure:Providers
An Agent uses a configured model provider to generate responses. BindAI supports provider/model identifiers such as:Instructions
Agent instructions define the behavior the model should follow. For example:Runtime Input
The user message is supplied when the agent executes.Tools
Agents can use tools registered with the agent.- External APIs
- Search
- Database operations
- Calculations
- File operations
- Business operations
- External service integrations
Memory
An agent can be configured with a Memory provider. Conceptually:Knowledge
An agent can use Knowledge and retrieval capabilities to ground responses in external information. Conceptually:- Documentation assistants
- Internal knowledge systems
- Retrieval-augmented generation
- Domain-specific assistants
- Question answering over indexed content
Retriever
A retriever can be supplied to an agent when the application needs explicit retrieval behavior. Retrieval can use capabilities such as:- Vector search
- BM25 search
- Hybrid search
- Metadata filtering
- Reranking
- Conversational retrieval
Middleware
Agents can be configured with middleware to participate in execution processing. Middleware can be used for concerns such as:- Request processing
- Logging
- Validation
- Execution instrumentation
- Cross-cutting behavior
Hooks and Callbacks
Agents can expose execution lifecycle hooks and callbacks. These mechanisms can be used for:- Logging
- Instrumentation
- Monitoring
- Custom execution behavior
- Integration with external systems
Events
Agent execution can participate in BindAI’s event system. Events provide a way for applications to observe execution activity without placing logging or monitoring logic directly into every agent operation. Events can be useful for:- Debugging
- Execution tracing
- Monitoring
- External notifications
- Workflow integration
Delegation and Multi-Agent Execution
Agents can participate in multi-agent architectures. An agent may delegate work to another agent or participate in a configured team or role chain. Conceptually:- Delegation
- Teams
- Specialist agents
- Role chains
- Knowledge retrieval
Workflow Integration
Agents can be used as operations within workflows. Conceptually:- Conditions
- Loops
- Parallel execution
- Retries
- Timeouts
- Human tasks
- External integrations
Error Handling
Agent execution can fail for several reasons. Examples include:- Provider failures
- Invalid configuration
- Tool failures
- Knowledge or retrieval failures
- Memory failures
- Model errors
- Execution errors
Exceptions vs AgentResult
AnAgentResult represents the normal execution result.
Some failures may instead occur as exceptions during configuration, setup, or execution.
Applications should therefore distinguish between:
Streaming vs run()
Use
run() when the application needs a completed result.
Use stream() when incremental output improves the user experience.
Agent State
An Agent instance can hold configured runtime components such as:- Provider configuration
- Instructions
- Tools
- Memory
- Knowledge
- Retriever
- Middleware
- Hooks
- Callbacks
Resource Management
Some agent dependencies may manage external resources. Examples include:- Database connections
- Memory providers
- Vector stores
- External clients
Security
Agents may have access to tools, external services, Knowledge, and Memory. Therefore:- Give agents only the tools they require.
- Limit external-service permissions.
- Keep credentials outside prompts.
- Validate tool inputs.
- Restrict state-changing operations.
- Protect sensitive Knowledge.
- Avoid exposing secrets through model output.
- Apply appropriate access controls around persistent storage.
Testing
Agents should be tested at multiple levels. Useful tests include:- Agent construction
- Provider configuration
- Instruction behavior
- Tool execution
- Memory integration
- Knowledge retrieval
- Structured output
- Error handling
- Streaming
- Multi-agent behavior
- Workflow integration
API Accuracy
The current public Agent API is centered around programmatic construction and execution. This documentation intentionally does not assume APIs such as:Related APIs
The Agent API works closely with:AgentResult- Providers
- Tools
- Memory
- Knowledge
- Retrievers
- Workflows
- Connections
- Multi-agent execution
Summary
TheAgent class is a central runtime component of BindAI.
The primary lifecycle is:
Agent.builder(), execution through run() and stream(), and integration with tools, Memory, Knowledge, workflows, and multi-agent systems.
Higher-level deployment, hosting, and application-management concerns belong outside the core Agent API unless explicitly implemented by the corresponding BindAI subsystem.