agentle.agents.errors.max_tool_calls_exceeded_error¶
Exception module for handling maximum tool call limits in Agentle agents.
This module provides the MaxToolCallsExceededError exception, which is raised when an agent attempts to make more tool calls than allowed by its configuration. This exception helps prevent infinite loops or excessive resource consumption by enforcing reasonable bounds on agent tool usage.
The error is typically raised by the Agent class when the number of iterations in its run_async method exceeds the maxIterations setting in the AgentConfig.
Example: ```python from agentle.agents.agent_config import AgentConfig from agentle.agents.agent import Agent from agentle.agents.errors.max_tool_calls_exceeded_error import MaxToolCallsExceededError
# Create an agent with a strict limit on iterations agent = Agent(
# … other parameters … config=AgentConfig(maxIterations=3)
)
- try:
result = agent.run(“This is a complex task that might require many tool calls”)
- except MaxToolCallsExceededError as e:
print(f”Agent exceeded tool call limit: {e}”) # Handle the error (e.g., by simplifying the task or increasing the limit)
Exceptions
|
Exception raised when an agent exceeds its configured maximum number of tool calls. |