feat(llmobs): capture hosted tool calls in openai, openai-agents and anthropic #11448
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.60) × (1 − Review Confidence (0.44)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.60 · 384 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
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
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.344
No Reviewer Assigned
no_reviewer_assigned
0.120
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #11448"
general
weight: 0.35
oathead
What does this PR do?
Records provider-hosted tool calls on LLM spans as a tool call plus a tool result, matching dd-trace-py (DataDog/dd-trace-py#22103, DataDog/dd-trace-py#22104), including the size bounds added there in review.
web_search_call,file_search_callandcode_interpreter_callitems become one assistant message with the call and its result:-
web_search: arguments are the allowlistedactionkeys (type, query, queries, url, pattern); the result is{status, sources: [{url, title?}]}.-
file_search: arguments{queries}; the result is{status, results: [{file_id, filename, score}]}.-
code_interpreter: arguments{code, container_id}; the result is{status, outputs}, each logs output capped at 4096 characters.-
toolIdis the item id and the resulttypeistool_result, as in Python.getHostedToolMessageinllmobs/plugins/openai/utils.js) serves both the OpenAI plugin and the OpenAI Agents integration, on input and output. agents-core passes a prior search back as{type: 'hosted_tool_call', providerData}, so that wrapper is unwrapped first.includes('tool_use')/includes('tool_result')), as dd-trace-py does, in requests, responses and streams.server_tool_use,web_search_tool_resultandweb_fetch_tool_resultare now recorded. Search results keep url and title, neverencrypted_content. Web fetch results keep url, title,retrieved_atand page text capped at 4096 characters; a PDF or other binary source becomes[document omitted: <media type>]instead of base64.Motivation
Hosted tools run inside the model call, so the app never calls them and no tool span exists. Before this change:
web_search_callinto an empty assistant message;Users could see that a search was billed (
web_search_count, #10510), but not what was searched or whether it failed. MLflow and other tools already show these steps.Additional Notes
Tests:
openai-utils.spec.js: allowlist, logs cap at the 4096/4097 boundary) and the Anthropic formatter (anthropic-utils.spec.js: web search, web fetch text cap, PDF marker, fetch error). The new specs fail without the source changes.Runner.runnon-streaming and streaming, including a second turn that passes the search back as input. 14 passing on agents 0.7.0 and 0.21.0. The 4 new tests fail without the source change.Open points for review:
semver-minor(adds data to LLM spans).🤖 Generated with Claude Code