fix(llm): use validated messages variable instead of raw params access#5165
Open
Ricardo-M-L wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix(llm): use validated messages variable instead of raw params access#5165Ricardo-M-L wants to merge 1 commit intocrewAIInc:mainfrom
Ricardo-M-L wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
590dc5f to
3547be4
Compare
This was referenced Apr 17, 2026
Both _handle_non_streaming_response and its async variant extract
messages via params.get("messages", []) and validate them, but then
pass params["messages"] to _handle_emit_call_events. If the key is
missing this raises a confusing KeyError instead of the intended
ValueError. Use the already-validated `messages` variable instead.
Signed-off-by: Ricardo-M-L <ricardoporsche001@icloud.com>
3547be4 to
ca46bf5
Compare
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.
Fixes #5164
Both
_handle_non_streaming_responseand_ahandle_non_streaming_responseextract and validate messages withparams.get("messages", []), but then passparams["messages"]to_handle_emit_call_events. This would raise a confusingKeyErrorinstead of the intendedValueErrorif the key is missing.Changed
params["messages"]tomessageson both lines (sync and async).Note
Low Risk
Low risk: a small bug fix that only changes which
messagesvalue is passed into LLM call-completed events, avoidingKeyErrorwhenparamslacksmessages.Overview
Fixes non-streaming LLM event emission for
response_modelcalls (sync and async) by passing the already-extracted/validatedmessagesvariable into_handle_emit_call_eventsinstead of directly indexingparams["messages"].This prevents a confusing
KeyErrorwhenmessagesare missing and preserves the intended validation error behavior.Reviewed by Cursor Bugbot for commit ca46bf5. Bugbot is set up for automated code reviews on this repo. Configure here.