Skip to content

fix(agent_executor): rename force_final_answer to avoid self-referential router#5636

Merged
greysonlalonde merged 2 commits into
mainfrom
gl/fix/agent-executor-force-final-self-loop
Apr 27, 2026
Merged

fix(agent_executor): rename force_final_answer to avoid self-referential router#5636
greysonlalonde merged 2 commits into
mainfrom
gl/fix/agent-executor-force-final-self-loop

Conversation

@greysonlalonde

@greysonlalonde greysonlalonde commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

The router method in lib/crewai/src/crewai/experimental/agent_executor.py is decorated with @router("force_final_answer") and also named force_final_answer, so Flow registers the same method under two identifiers that share a name. This causes a self-referential loop when an agent hits max_iter.

Renames the method to ensure_force_final_answer. The routing token "force_final_answer" (emitted by check_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 from force_final_answer to ensure_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.

@iris-clawd iris-clawd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean fix — breaks the self-referential router loop without changing routing behavior. ✅

@greysonlalonde greysonlalonde merged commit ef40bc0 into main Apr 27, 2026
54 checks passed
@greysonlalonde greysonlalonde deleted the gl/fix/agent-executor-force-final-self-loop branch April 27, 2026 21:06
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