Skip to content

Conversation

@MaxGfeller
Copy link

@MaxGfeller MaxGfeller commented Jan 14, 2026

Add a new allow_repeated_usage flag to BaseTool and CrewStructuredTool that allows tools to bypass the repeated usage check. This is essential for stateful tools like browser automation (e.g., Playwright MCP), where calling the same tool with the same arguments can produce different results due to external state changes. Currently, using the Playwright MCP tool with an agent does not work properly.

The repeated usage check was blocking consecutive calls to tools like browser_snapshot with the same (empty) arguments, even though the browser state had changed between calls. This made browser automation with MCP servers unusable.

Changes:

  • Add allow_repeated_usage: bool = False field to BaseTool
  • Add allow_repeated_usage parameter to CrewStructuredTool
  • Update to_structured_tool() to copy the flag
  • Update _check_tool_repeated_usage() to check for the flag

Usage:

class MyStatefulTool(BaseTool):
    name = "my_tool"
    description = "A stateful tool"
    allow_repeated_usage = True  # Allow same args consecutively

    def _run(self, **kwargs):
        # Tool implementation
        pass

Fixes: Browser automation with MCP servers not working due to repeated usage check blocking consecutive tool calls.

Note: For MCP adapters to work, a follow-up change to mcpadapt is necessary, too. I have a fix ready, and can submit the PR as soon as this is


Note

Enables stateful tools (e.g., browser automation) to be invoked consecutively with identical arguments when explicitly allowed.

  • Adds allow_repeated_usage: bool to BaseTool and CrewStructuredTool (default False)
  • Propagates the flag via BaseTool.to_structured_tool() and CrewStructuredTool constructor
  • Updates ToolUsage._use and ToolUsage._ause to pass the tool into _check_tool_repeated_usage()
  • Modifies _check_tool_repeated_usage() to skip the block when tool.allow_repeated_usage is True
  • No changes to usage limits or caching logic

Written by Cursor Bugbot for commit c8d3c78. This will update automatically on new commits. Configure here.

Add a new `allow_repeated_usage` flag to BaseTool and CrewStructuredTool
that allows tools to bypass the repeated usage check. This is essential
for stateful tools like browser automation (e.g., Playwright MCP) where
calling the same tool with the same arguments can produce different results
due to external state changes.

The repeated usage check was blocking consecutive calls to tools like
`browser_snapshot` with the same (empty) arguments, even though the
browser state had changed between calls. This made browser automation
with MCP servers unusable.

Changes:
- Add `allow_repeated_usage: bool = False` field to BaseTool
- Add `allow_repeated_usage` parameter to CrewStructuredTool
- Update `to_structured_tool()` to copy the flag
- Update `_check_tool_repeated_usage()` to check for the flag

Usage:
```python
class MyStatefulTool(BaseTool):
    name = "my_tool"
    description = "A stateful tool"
    allow_repeated_usage = True  # Allow same args consecutively

    def _run(self, **kwargs):
        # Tool implementation
        pass
```

Fixes: Browser automation with MCP servers not working due to
repeated usage check blocking consecutive tool calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant