Repository navigation
fix(sdk): unwrap {result: ...} transport carriers before MCP citation detection - #4555
Merged
Merged
Conversation
…on detection
Data-platform RAG MCP tools deliver their business JSON inside a
single-key {"result": "<JSON string>"} transport carrier. The retrieval
detection only scanned top-level lists and text objects, so the carrier
escaped annotation entirely: no SEARCH_CONTENT sources reached the
frontend and the model invented its own reference keys, leaving citation
markers stuck on "Source details are loading".
Unwrap the carrier before retrieval detection (up to two nested levels,
sole "result" key only, mirroring the jiuwen adapter's carrier decoding
constraint of never touching arbitrary nested business JSON). All other
payload shapes keep the previous pass-through behavior, so no other MCP
tool result changes. Five regression cases cover the payload captured
on tianzhou-beta, nested carriers, plain-text carriers, multi-key
payloads and non-retrieval lists inside carriers.
TiTi-iTiT
requested review from
WMC001,
YehongPan,
hhhhsc701,
jeffwu-1999 and
xuyaqist
as code owners
December 4, 2026 03:18
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Exercise the scalar-value carrier branch ({"result": 42}) so the new
carrier unwrapping reaches 100% line coverage, closing the codecov
patch gap reported on PR #4555 (88.23% against the 90% target).
YehongPan
approved these changes
Dec 4, 2026
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.
Summary
datacenter_tools__2, verified on tianzhou-betaconversations/13734) return their business JSON inside a single-key{"result": "<JSON string>"}transport carrier (double-encoded)._extract_retrieval_itemsonly recognized top-level lists and text objects, so the carrier escaped detection entirely: nosearch_contentsources were reported to the frontend, and the model invented its own reference keys ([[a1]](1)), which React-Markdown rendered as plain links instead of citation badges — the "Source details are loading" dead end._unwrap_result_carrier(): unwrap a sole-key{"result": ...}carrier (JSON-string or object value, up to two nested levels) before retrieval detection, mirroring the jiuwen adapter's carrier-decoding constraint ("never arbitrary nested business JSON").tool_sign="q"sources on the SEARCH_CONTENT channel,reference_mark: [[q1]]in the model payload, and the frontend renders resolvable citation badges (title fromdocument_name).Compatibility
source == "mcp"tools; built-in search tools, local/langchain/builtin sources and the jiuwen core are untouched.resultis treated as a carrier; a business payload that merely carries aresultfield among others is never misinterpreted.Test evidence
pytest test/sdk/core/agents/test_mcp_citation.py— 54 passed (49 existing + 5 new regressions: JSON-string carrier replaying the tianzhou-beta payload, nested carrier, plain-text carrier pass-through, multi-key payload pass-through, non-retrieval list inside carrier pass-through).pytest test/sdk/core/agents/test_nexent_agent.py— 248 passed (wiring regression).Notes