Skip to content

Conversation

@manuelkiessling
Copy link
Member

Summary

Restores the toolAttempts counter and ToolMaxTriesException circuit breaker in BaseCodingAgent::executeSingleTool().

The method overrides the parent without calling parent::executeSingleTool(), which bypassed the tool-attempt tracking logic. This removed a critical safety net: when the agent's context window overflows and conversation history is lost, the agent can call the same tool infinitely. With this fix, ToolMaxTriesException fires after $toolMaxTries (default: 5) attempts per tool, terminating the runaway loop.

Related: dx-tooling/sitebuilder-webapp#75

Changes

  • Added tool-attempt increment and max-tries check before tool execution
  • ToolMaxTriesException is thrown (not caught by the error-as-result handler)
  • Added unit tests for attempt tracking, per-tool independence, and error handling

Test plan

  • New unit tests pass (php vendor/bin/pest tests/Unit)
  • Integration test in sitebuilder-webapp with updated package version

Made with Cursor

The overridden executeSingleTool() was not calling parent, which
bypassed the toolAttempts counter and ToolMaxTriesException safety net.
This allowed an agent to call the same tool infinitely when the context
window overflowed and the conversation history was lost.

Re-add attempt tracking and max-tries enforcement before tool execution.
ToolMaxTriesException is thrown (not caught) so the agent loop terminates.

Ref: dx-tooling/sitebuilder-webapp#75
Co-authored-by: Cursor <cursoragent@cursor.com>
@manuelkiessling manuelkiessling merged commit 112dac7 into main Feb 7, 2026
1 of 2 checks passed
@manuelkiessling manuelkiessling deleted the bugfix/restore-tool-attempt-tracking branch February 7, 2026 10:49
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