Repository navigation
fix(evaluation): read multimodal message content in reasoning metrics - #8797
MindOfqc (MindOfqc) wants to merge 4 commits into
Conversation
Strix Security ReviewWarning This pull request has 79 commits after the last Strix review ( ✅ No open security findings. PR summary: Fixes ReasoningEfficiencyEvaluator so that LLM responses whose message content is multimodal (a list of parts) are read through the shared message_content_text helper instead of being treated as strings, preventing crashes and giving correct length statistics. Review summaryThe PR hardens ReasoningEfficiencyEvaluator against multimodal (list) response content by routing three text-reading boundaries through the existing message_content_text helper. The change only affects loop-detection text extraction, response-length statistics, and readable call samples; the helper safely handles missing, non-list, and non-text content, and no untrusted data reaches a new dangerous sink. No security issues were found in the changed code. Review 1 on this PR · Reviewed by Strix |
13f3585 to
b245e9d
Compare
Summary
ReasoningEfficiencyEvaluatorhandles LLM responses that are lists of messages, but reads each message'scontentas a string. A valid multimodal response (content: [{"type": "text", "text": ...}]) therefore:AttributeError: 'list' object has no attribute 'lower',_get_call_sampleswithTypeError: sequence item 0: expected str instance, list found,_analyze_reasoning_patternscount content parts (1) instead of text characters (19), which skews the pattern classification.The fix uses the existing
message_content_texthelper at the three boundaries: loop detection and readable samples now use the extracted text, and response-length statistics count its characters. Raw-string responses are untouched, and missing or non-text content still falls back to the helper's existing behaviour (""/"[multimodal content]").Type of change
How Has This Been Tested?
Three cases added to
lib/crewai/tests/experimental/evaluation/metrics/test_reasoning_metrics.py: a three-call trace whoseresponseis[{"role": "assistant", "content": [{"type": "text", "text": "Review the evidence"}]}], asserted through_detect_loops,_get_call_samplesand_analyze_reasoning_patterns.Before:
After:
ruff checkon both files reports no new findings (the file keeps its 8 pre-existing ones).Fixes #8796
Prepared with an AI coding agent.
Note
Low Risk
Scoped to experimental reasoning evaluation parsing; uses an existing shared helper and leaves string responses as-is.
Overview
Fixes ReasoningEfficiencyEvaluator so LLM traces whose
responseis a message list with structured multimodalcontent(e.g.[{"type": "text", "text": "..."}]) no longer break loop detection, sample rendering, or length metrics.Loop detection, call samples, and
avg_lengthnow usemessage_content_textinstead of treatingmsg["content"]as a string—avoiding crashes and counting one part instead of real text length. Plain string responses are unchanged.Adds
TestReasoningEfficiencyMultimodalResponsescovering_detect_loops,_get_call_samples, and_analyze_reasoning_patternson repeated multimodal traces.Reviewed by Cursor Bugbot for commit 0edccc7. Bugbot is set up for automated code reviews on this repo. Configure here.