Repository navigation
rust(fix): keep unmatched fields visible when list output is truncated - #847
Draft
alexa-sift wants to merge 6 commits into
Draft
alexa-sift wants to merge 6 commits into
alexa-sift wants to merge 6 commits into
Conversation
Rename the list tools' unmatched_fields key to _unmatched_fields so it sorts ahead of the items and survives head truncation of large responses. Document the key in each list tool's Output section and add tests for the ordering and the descriptions.
alexa-sift
marked this pull request as ready for review
October 26, 2026 19:28
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the `_unmatched_fields` rename with a `list_result` helper. The text block agents read now writes `count`, `has_more`, `unmatched_fields` and other metadata before the items, so they survive head truncation in every list tool, including the 7 whose items key sorts before `count`. `structuredContent` is unchanged, and the key keeps its original `unmatched_fields` name. ENG-15730 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexa-sift
marked this pull request as draft
October 29, 2026 18:47
The bullets were added so agents would learn the `_unmatched_fields` rename. With the rename reverted, each tool's `fields` bullet already names the key, so remove the bullets, their docs guard test, and the CHANGELOG mention. ENG-15730 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Background: Every
list_*MCP tool builds its response throughlist_body. A caller can passfields: ["name", "asset_id"]to keep only those keys on each row. If a requested name matches nothing on any row (a typo likenmae),list_bodyaddsunmatched_fields: ["nmae"]. Without that key, a typo would quietly return rows with that field missing, and the agent could report the data as empty when the field name was wrong.unmatched_fieldslets the agent catch the mistake and retry, or at least tell the user.The problem: serde_json sorts keys alphabetically, so
unmatched_fieldscomes after the items array. In 7 of the 14 list tools (channels,assets,annotations, and others), the items key also sorts beforecountandhas_more. The agent output guard cuts large responses from the end, so these keys disappear on exactly the big responses where they matter most.The fix: a new
list_resulthelper writes the text block agents read with every metadata key first and the items array last. All 14 list tools return through it.count,has_more,unmatched_fields,artifact_url, andnext_stepnow survive head truncation regardless of how the items key sorts or whether serde_json'spreserve_orderis ever enabled.structuredContentis unchanged, and the key keeps its existing name.Verification
list_resulttests incommon/test.rs:count,has_more, andunmatched_fieldsbefore the items.structuredContent.next_stepgets its own leading block.list_channels,list_artifact_versions(artifact_urlfirst), andlist_calculated_channel_versions(next_stepblock first).list_resultreverted to alphabetical output, 6 of the new tests fail.cargo fmt --check --all,cargo check --all-features, andcargo clippy --all-featurespass with no new warnings.cargo test -p sift_mcppasses 605 tests.