fix(agent_executor): rename force_final_answer to avoid self-referential router#5636
Merged
greysonlalonde merged 2 commits intoApr 27, 2026
Merged
Conversation
iris-clawd
approved these changes
Apr 27, 2026
iris-clawd
left a comment
Contributor
There was a problem hiding this comment.
Clean fix — breaks the self-referential router loop without changing routing behavior. ✅
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
The router method in
lib/crewai/src/crewai/experimental/agent_executor.pyis decorated with@router("force_final_answer")and also namedforce_final_answer, so Flow registers the same method under two identifiers that share a name. This causes a self-referential loop when an agent hitsmax_iter.Renames the method to
ensure_force_final_answer. The routing token"force_final_answer"(emitted bycheck_max_iterations) is unchanged, so existing tests asserting that string remain valid.Note
Low Risk
Low risk rename of a Flow router handler method; behavior and routing token remain the same, but any external callers referencing the old Python method name would break.
Overview
Fixes a max-iteration routing edge case by renaming the
@router("force_final_answer")handler method fromforce_final_answertoensure_force_final_answer, avoiding a self-referential router registration loop.The routing key (
"force_final_answer") and forced-final-answer behavior are unchanged, so flow transitions and existing string-based assertions should remain stable.Reviewed by Cursor Bugbot for commit f93c078. Bugbot is set up for automated code reviews on this repo. Configure here.