Skip to content

fix: adjust executor listener value to avoid recursion#4705

Merged
lorenzejay merged 3 commits intomainfrom
gl/fix/recursion-in-executor
Mar 4, 2026
Merged

fix: adjust executor listener value to avoid recursion#4705
lorenzejay merged 3 commits intomainfrom
gl/fix/recursion-in-executor

Conversation

@greysonlalonde
Copy link
Contributor

@greysonlalonde greysonlalonde commented Mar 4, 2026

Note

Medium Risk
Touches core Flow execution by adding a per-method call cap that raises RecursionError, which could change behavior for unusually long-running/cyclic flows. Agent execution routing constants also changed, so any external code depending on the old trigger label may need updates.

Overview
Prevents runaway Flow executions caused by listeners that re-trigger themselves (e.g., a @listen label matching the method name) by adding a per-method call counter and configurable max_method_calls guard that raises RecursionError.

Updates AgentExecutor to route max-iteration handling via a new max_iterations_exceeded trigger (instead of force_final_answer) and passes a higher max_method_calls limit (max_iter * 10) when initializing its internal flow. Tests are updated and expanded to cover the new recursion guard and OR-condition self-listen behavior.

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

@greysonlalonde greysonlalonde requested review from a team and lorenzejay March 4, 2026 17:54
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@lorenzejay lorenzejay merged commit ea70976 into main Mar 4, 2026
45 checks passed
@lorenzejay lorenzejay deleted the gl/fix/recursion-in-executor branch March 4, 2026 18:47
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.

2 participants