fix: tool call counting#282
Merged
Merged
Conversation
added 2 commits
December 17, 2025 12:11
Contributor
There was a problem hiding this comment.
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_callsattribute to the Agent class (defaults to -1 for unlimited) - Implemented tool call counting and limit enforcement in the agent's execution loop
- Created
MaxToolCallsErrorexception andmax_tool_calls_reachedstop 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.
added 2 commits
December 17, 2025 13:16
…all that is past max
added 2 commits
December 17, 2025 14:26
rdheekonda
reviewed
Dec 17, 2025
rdheekonda
reviewed
Dec 17, 2025
rdheekonda
approved these changes
Dec 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
max_tool_callsconfig option to limit the number of tool calls an agent can make (defaults to-1for unlimited)Finishwhen limit is reachedmax_tool_calls_reachedstop reason andMaxToolCallsErrorfor proper error reportingGenerated Summary:
max_tool_callsattribute to specify the maximum allowed tool calls during execution, defaulting to infinite.MaxToolCallsErrorwhen the limit is reached.AgentStopReasontype reflects the new possible state ofmax_tool_calls_reached.This summary was generated with ❤️ by rigging