fix(llmobs): keep streamed tool calls apart when the delta has no index #22270
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.44) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 255 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.332
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #22270"
general
weight: 0.35
gnufede
Description
Re-opening #21111 from a branch in this repository with signed commits. The change is the original contributor's, rebased onto current
mainas a single commit that keeps Alex Castillo as author.Gemini's OpenAI-compatible endpoint (
https://generativelanguage.googleapis.com/v1beta/openai) streams each parallel tool call whole (id, name and arguments) in its own chunk and leavestool_calls[].indexunset.openai_construct_tool_call_from_streamed_chunklooked up the stored call byindex, so every call withindex=Nonewas appended to the first one, and the streamed LLMObs span showed a single tool call with concatenated arguments.When a delta has no index, an id that matches a collected call continues that call, a new id starts a new call, and a delta without an id continues the latest call. Indexed deltas behave as before. The final sort now keeps unindexed calls in arrival order after the indexed ones, since
Nonecan't be compared withNone.The same reducer is used by the LiteLLM integration and AI Guard's OpenAI streaming evaluation, so those paths get the fix too.
Customer impact
Parallel tool calls streamed by OpenAI-compatible backends that omit
tool_calls[].index(such as Gemini's endpoint) now appear as separate tool calls with their own ids and arguments. A release note is included.Testing
New
TestOpenAIConstructMessageWithUnindexedToolCallsintests/llmobs/test_integrations_utils.pycovers separate parallel calls, id-less continuation, repeated-name continuation, interleaved fragments rejoined by id, and repeated ids.Risks
Low. Only deltas without an index take the new branch. Calls from backends that send empty or missing ids still merge, as before.
Additional Notes
Original PR: https://github.com/DataDog/dd-trace-py/pull/21111 (fork PR, unsigned commits).
Claude session:
07f47f22-4d15-4fbc-b026-f1f4daafed1eResume:
claude --resume 07f47f22-4d15-4fbc-b026-f1f4daafed1e🤖 Generated with Claude Code