Agent API Reference
TheAgent class is the primary building block of BindAI.
Agents encapsulate AI behavior by combining a language model, prompts, tools, memory, knowledge, and execution settings into a reusable runtime component.
This page documents the public Agent API.
Overview
An Agent is responsible for:- receiving user input
- building prompts
- invoking language models
- calling tools
- accessing memory
- retrieving knowledge
- returning structured results
Creating an Agent
Agents can be created programmatically or loaded from configuration files. Example:Public Methods
run()
Executes the agent and returns the complete response. Example:Returns
AnAgentResult containing:
- success state
- output
- error (if any)
stream()
Streams the generated response incrementally. Example:from_yaml()
Creates an agent from a YAML configuration file. Example:Configuration
Agents typically contain:- name
- description
- provider
- model
- system prompt
- user prompt
- tools
- memory
- knowledge
- execution options
Language Model
Every agent uses a language model. Conceptually:Prompts
Agents support multiple prompt types. Examples include:- system prompt
- developer prompt
- user prompt
Tools
Agents may invoke registered tools during reasoning.Memory
Agents may use conversation memory.Knowledge
Agents may retrieve external knowledge before generating a response.Results
Agent execution returns anAgentResult.
Typical properties include:
Error Handling
Execution errors are captured inside the result object. Typical errors include:- provider failures
- invalid configuration
- unavailable tools
- timeout
- model errors
Streaming vs Run
Choose the method that best fits your application.
Best Practices
- Load agents from YAML whenever possible.
- Give every agent a clear responsibility.
- Register only the tools required by that agent.
- Keep prompts concise and focused.
- Use memory only when conversational context is needed.
- Attach knowledge sources only when retrieval is required.
- Validate
AgentResult.successbefore using the output.
Related APIs
The Agent API works closely with:- Project
- Workflow
- Tool
- Memory
- Provider
Summary
TheAgent class is the central execution component of BindAI.
It combines prompts, models, tools, memory, and knowledge into a reusable AI service capable of executing requests, streaming responses, participating in workflows, and serving as the foundation for BindAI applications.