Render MCP list-tools spans instead of leaving them blank - #329
Open
laminar-coding-agent[bot] wants to merge 2 commits into
Open
Render MCP list-tools spans instead of leaving them blank#329laminar-coding-agent[bot] wants to merge 2 commits into
laminar-coding-agent[bot] wants to merge 2 commits into
Conversation
`_apply_mcp_span_data` was the only handler in span_data.py that never called `set_lmnr_span_io`, so an `agents.mcp_tools` span arrived with `lmnr.span.input`/`output` unset and showed up empty in the trace view. The tool list was there all along, just parked in `openai.agents.mcp.result`, which the UI does not read. Surfaced on a chi-bench run: 15 `agents.mcp_tools` spans, every one of them blank, while the attribute held all 30 tool names. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Problem
_apply_mcp_span_datais the only handler inopenai_agents/span_data.pythat never callsset_lmnr_span_io. It writesopenai.agents.mcp.serverandopenai.agents.mcp.resultand stops there — but those custom attributes are not rendered as span I/O, so anagents.mcp_toolsspan arrives withlmnr.span.input/lmnr.span.outputunset and shows up completely empty in the trace view.Found while reviewing a chi-bench collection run: 15
agents.mcp_toolsspans, every one blank, with all 30 tool names sitting unread inopenai.agents.mcp.result.Fix
Set span I/O alongside the attributes — server in, tool list out. Nothing else changes; the existing attributes stay for anyone querying them.
Testing
New
tests/test_instrumentations/test_openai_agents/test_mcp_span_data.py(2 tests) covers the populated case and the no-result case. The fulltests/test_instrumentations/test_openai_agents/suite passes (9 passed).Also exercised end-to-end by a live chi-bench run exporting to production Laminar.
Notes
CLAUDE.mdgains anopenai_agentssection recording the invariant (every_apply_*handler sets span I/O), plus two things that look like bugs and aren't: the first turn'smcp_toolsspan parenting to the trace root is upstream SDK ordering, and onemcp_toolsspan per turn is expected even withcache_tools_list=True(the repeats are ~0.3ms cache hits).🤖 Generated with Claude Code
Note
Low Risk
Small instrumentation change that only adds trace-view I/O attributes for MCP list-tools spans; no auth, export, or runtime behavior changes.
Overview
agents.mcp_toolsspans were empty in the trace UI because_apply_mcp_span_dataonly setopenai.agents.mcp.*attributes, which the frontend does not use for I/O.The handler now also calls
set_lmnr_span_io: MCP server name as input ({"server": ...}) and the tool list as output. Existingopenai.agents.mcp.server/openai.agents.mcp.resultattributes are unchanged for queries.CLAUDE.mddocuments the openai_agents invariant (every_apply_*_span_datahandler should set span I/O) and notes two upstream SDK behaviors (first-turn MCP span parenting, one MCP span per turn even with cached tool lists).Tests:
test_mcp_span_data.pycovers populated and no-result MCP list-tools spans.Reviewed by Cursor Bugbot for commit c1573e8. Bugbot is set up for automated code reviews on this repo. Configure here.