Repository navigation
fix: prevent result_as_answer from returning hook-block message as final answer - #5697
Merged
Greyson LaLonde (greysonlalonde) merged 1 commit intoMay 4, 2026
Conversation
iris-clawd
approved these changes
May 4, 2026
iris-clawd
left a comment
Contributor
There was a problem hiding this comment.
Tiny, surgical fix. Adding and not hook_blocked to the result_as_answer guard is the obvious correct thing — if a hook blocked execution, the block message should never be treated as the agent's final answer. Test covers it cleanly.
LGTM ✅
Greyson LaLonde (greysonlalonde)
deleted the
gl/fix/result-as-answer-hook-blocked
branch
May 4, 2026 11:42
This was referenced Oct 20, 2026
Closed
2 tasks done
电大老baby (HhH666-ux)
added a commit
to HhH666-ux/crewAI
that referenced
this pull request
Oct 29, 2026
The shared native path (execute_single_native_tool_call) excludes hook-blocked calls from result_as_answer (crewAIInc#5697), and the ReAct path does too. AgentExecutor keeps its own copy of that logic and missed the check: when a before_tool_call hook blocks a tool with result_as_answer=True, the 'Tool execution blocked by hook' notice satisfied the short-circuit condition (tool_failure is None for a block), became the agent's final answer, and the model was never called again. Since crewAIInc#8192 made AgentExecutor the default executor, every function-calling agent hits this. Surface hook_blocked on the per-call execution result and require it to be false in both result_as_answer short-circuit sites, mirroring the shared path. The block notice still reaches the model as ordinary tool context and the agent continues. Fixes crewAIInc#8338
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.
Note
Low Risk
Low risk: a small boolean gating change plus a regression test; behavior only changes when a before-tool hook blocks execution.
Overview
Prevents
execute_single_native_tool_callfrom settingresult_as_answer=Truewhen a before-tool hook blocks execution, so the hook-block message can’t be returned as the agent’s final answer.Adds a regression test ensuring
result_as_answerstaysFalseforresult_as_answer=Truetools when blocked by a registered before-hook.Reviewed by Cursor Bugbot for commit fca3e89. Bugbot is set up for automated code reviews on this repo. Configure here.