Configuration
The AgentConfig class allows you to fine-tune the behavior of your Agents, such as retry policies, token limits, and logging.
Purpose
Use AgentConfig to:
- Set global or per-agent configuration.
- Control retry behavior for LLM calls.
- Enable parallel tool execution.
- Manage context window sizes.
Usage
Applying Configuration
Pass a config object when initializing an Agent.
from yosrai import Agent, AgentConfig
config = AgentConfig(
max_loops=5, # Max tool execution loops
max_retries=3, # Retries on LLM failure
timeout=30, # Request timeout in seconds
parallel_tool_calls=True, # Execute independent tools in parallel
thinking=True, # Enable thinking mode
reflection=True # Enable reflection mode
)
agent = Agent(
name="RobustAgent",
instructions="Help the user.",
config=config,
verbose=True # Enable step-by-step output
)
Skill Configuration (For Conductors)
When using a Conductor, you can wrap individual skill agents with SkillConfig to enforce specific execution policies like retries and timeouts for that specific skill.
from yosrai import SkillConfig
robust_skill = SkillConfig(
skill=my_agent,
retries=3,
timeout=5.0
)
See Conductor documentation for more details.
API Reference
yosrai.engine.core.config.AgentConfig
Bases: BaseModel
Configuration for the Agent.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
str
|
Model identifier (e.g. 'openai/gpt-4o', 'ollama/llama3'). |
max_turns |
int
|
Maximum number of ReAct loop turns (default: 10). |
temperature |
float
|
Sampling temperature (default: 0.0). |
api_key |
Optional[str]
|
API Key for the provider. |
extra_headers |
Dict[str, str]
|
Extra HTTP headers for requests. |