Agent Configuration
TheAgent class provides extensive configuration options to customize behavior, performance, and capabilities.
Core Parameters
Model Configuration
The name of the language model to use. Supports any model from OpenAI, Anthropic, Groq, Cohere, and more via LiteLLM.
Pre-configured LLM instance. If not provided, will be created automatically based on
model_name.Controls randomness in model outputs (0.0 = deterministic, 1.0 = creative).
Maximum number of tokens to generate in a single response.
Maximum context window size. Automatically set based on the model.
Agent Identity
Unique name for the agent. Used in multi-agent systems and logging.
Description of the agent’s purpose and capabilities.
The system prompt that defines agent behavior and expertise.
Execution Control
Number of execution loops. Set to “auto” for autonomous mode.
Delay in seconds between loops.
Number of retry attempts for failed LLM calls.
Delay in seconds between retry attempts.
Timeout in seconds for agent execution.
Output Configuration
Format for agent output. Options: “str”, “list”, “json”, “dict”, “yaml”, “xml”.
Enable basic streaming with formatted panels.
Enable detailed token-by-token streaming with metadata.
Callback function to receive streaming tokens in real-time.
Enable detailed logging output.
Enable printing of agent responses.
Memory and History
Return full conversation history instead of just final response.
Name to use for user messages in conversation history.
Automatically manage context window to prevent overflow.
Advanced Features
Randomly adjust temperature between loops for varied outputs.
Add reasoning prompts to guide multi-step thinking.
Enable interactive mode for conversational agents.
Display agent dashboard on initialization.
State Management
Automatically save agent state after each execution.
Path to save agent state.
Path to load previous agent state from.
Reliability
List of fallback models to try if primary model fails.
Performance
Agent execution mode. Options: “interactive”, “fast”, “standard”.
Nucleus sampling parameter for model generation.
Example Configurations
Production Agent
Research Agent
Fast Batch Processing Agent
Next Steps
Agent Memory
Configure conversation history and memory
Agent Tools
Add tools to extend capabilities
Reference
Location in source:swarms/structs/agent.py:352-454