Skip to content

Conversation

@mkultraWasHere
Copy link
Contributor

@mkultraWasHere mkultraWasHere commented Dec 17, 2025

Summary

  • Added max_tool_calls config option to limit the number of tool calls an agent can make (defaults to -1 for unlimited)
  • Agent tool call tracking wasnt exactly correct previously, it was enforced through generation steps which is not 1 to 1.
  • Agent now tracks tool calls and raises Finish when limit is reached
  • New max_tool_calls_reached stop reason and MaxToolCallsError for proper error reporting

Generated Summary:

  • Introduced a new maximum tool calls limit for the Agent class.
  • Added max_tool_calls attribute to specify the maximum allowed tool calls during execution, defaulting to infinite.
  • Updated the core step loop to track the number of tool calls and raise MaxToolCallsError when the limit is reached.
  • Modified error handling to account for the new maximum tool calls logic.
  • Ensured the AgentStopReason type reflects the new possible state of max_tool_calls_reached.
  • These changes enhance control over the agent's execution flow, particularly in scenarios where too many tool calls could be problematic.

This summary was generated with ❤️ by rigging

@mkultraWasHere mkultraWasHere changed the title tool call counting fix: tool call counting Dec 17, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new max_tool_calls configuration option for the Agent class to limit the number of tool calls an agent can make during execution. The feature includes proper error handling and reporting through a new stop reason and exception type.

  • Added max_tool_calls attribute to the Agent class (defaults to -1 for unlimited)
  • Implemented tool call counting and limit enforcement in the agent's execution loop
  • Created MaxToolCallsError exception and max_tool_calls_reached stop reason for proper error reporting

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
dreadnode/agent/result.py Added max_tool_calls_reached to the AgentStopReason literal type
dreadnode/agent/error.py Introduced new MaxToolCallsError exception class for handling max tool call limit violations
dreadnode/agent/agent.py Added max_tool_calls config option, tool call counter, and enforcement logic in the execution loop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dreadnode-renovate-bot dreadnode-renovate-bot bot added the area/tests Changes to test files and testing infrastructure label Dec 17, 2025
Michael Kouremetis added 2 commits December 17, 2025 14:26
@mkultraWasHere mkultraWasHere added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit 46a58ea Dec 18, 2025
12 of 13 checks passed
@mkultraWasHere mkultraWasHere deleted the mk/tool_call_counting branch December 18, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tests Changes to test files and testing infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants