Agents API Reference
January 22, 2026 ยท View on GitHub
Overview
AgentFly provides a comprehensive agent system with a base class and specialized implementations for different use cases. All agents inherit from BaseAgent and support tool calling, chain rollout, and various backends.
Structure
- Agent - Base agent class and implementations
- LLM Backends - Language model backends
- Rollout - Agent rollout strategies
Usage Examples
Basic Agent Creation
from agentfly.agents import ReactAgent
from agentfly.tools import get_tools_from_names
# Create a ReactAgent with tools
agent = ReactAgent(
model_name_or_path="gpt2",
tools=get_tools_from_names(["calculator", "google_search"]),
template="react"
)
Using AutoAgent
from agentfly.agents import AutoAgent
# Create agent from config
config = {
"agent_type": "react",
"model_name_or_path": "gpt2",
"template": "react",
"tools": ["calculator"]
}
agent = AutoAgent.from_config(config)
Custom Agent
from agentfly.agents import BaseAgent
class CustomAgent(BaseAgent):
def parse(self, response):
# Custom parsing logic
pass
def generate(self, messages):
# Custom generation logic
pass