Skip to content

Conversation

@zzstoatzz
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings August 13, 2025 18:22
@zzstoatzz zzstoatzz merged commit 5732445 into main Aug 13, 2025
3 checks passed
@zzstoatzz zzstoatzz deleted the fix-tool-limiting branch August 13, 2025 18:22
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 changes the tool limiting strategy from raising exceptions to returning a message when the tool usage limit is exceeded. It removes the custom ToolUseLimitExceeded exception and associated error handling, replacing it with a return value that instructs the agent to continue with gathered information.

  • Removes ToolUseLimitExceeded exception class and related error handling
  • Changes tool limit enforcement to return a message instead of raising an exception
  • Reduces default max tool calls from 50 to 5

Reviewed Changes

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

File Description
examples/slackbot/src/slackbot/wrap.py Removes exception class and changes limit enforcement to return a message
examples/slackbot/src/slackbot/settings.py Reduces default max tool calls from 50 to 5
examples/slackbot/src/slackbot/api.py Removes import and exception handling for ToolUseLimitExceeded

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if total_calls > max_tool_calls:
# Return a message that tells the agent to stop using tools and continue
# This will be returned as the tool result, which the agent will see
return "Tool use limit reached. Please continue with the information you've gathered so far to answer the user's question."
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Returning a string when the function is expected to return type T breaks the function's type contract. This could cause type errors or unexpected behavior for callers expecting the original return type.

Suggested change
return "Tool use limit reached. Please continue with the information you've gathered so far to answer the user's question."
return None

Copilot uses AI. Check for mistakes.
if len(args) > 1:
tool_name = args[1]

# Always track and enforce tool usage limits
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The comment says 'Always track and enforce' but the tracking logic only runs when _progress_message.get() returns a truthy value (line 112). This creates inconsistency between the comment and actual behavior.

Suggested change
# Always track and enforce tool usage limits
# Always enforce tool usage limits; progress tracking occurs only if a progress message context is present

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants