mistralai: emit prompt events for ToolMessage and other SDK message objects - #4524
charan-rathore wants to merge 4 commits into
Conversation
|
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe MistralAI instrumentation now reads ChangesMistralAI message event handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change has no identified merge-blocking issue; normal checks remain appropriate. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Tool results can now appear in message-event logs when event logging is active. Message-content tracing is enabled by default, so this expands the information those logs may contain. Disabling content tracing still removes message bodies. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Fixes #4523. In Mistral event mode, the prompt loop recognizes user, assistant, and system SDK messages and plain dicts, but not
ToolMessage. A tool result first in the list raised an internal exception and lost the prompt events; a tool result after a user prompt reused the previous message's role and content.Read
roleandcontentfrom any other SDK message object, includingToolMessage, for each iteration. This emits the tool's own event and does not copy the preceding message. It also keeps future message types from inheriting stale values. The legacy span-attribute path is unchanged; open PR #4509 is working in that area.Tests
An offline test failed before the fix for both tool-first (no prompt events) and tool-after-user (duplicate user event). It now checks each message's event name and content, plus a previously unknown message class after a user prompt.
uv run --frozen --group dev --group test pytest tests/ -qin the Mistral instrumentation package: 29 passed. Ruff and diff checks passed. No cloud key or model call was needed.Instinct assisted with the change and tests.
Summary by CodeRabbit