Repository navigation
rust(fix): keep unmatched fields visible when list output is truncated - #847
Draft
alexa-sift wants to merge 1 commit into
Draft
alexa-sift wants to merge 1 commit into
alexa-sift wants to merge 1 commit 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.
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.
Every
list_* MCPtool 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. The agent output guard cuts large responses from the end, so the warning disappears on exactly the big responses where it matters most.To resolve this, this PR renames the list tools'
unmatched_fieldskey to_unmatched_fieldsso it sorts ahead of the items and survives head truncation of large responses. We also, document the key in each list tool's Output section and add tests for the ordering and the descriptions.Verification
Automated (run locally on d64a0d7f9):
cargo test -p sift_mcp: 602 passed.cargo fmt --all -- --check: clean.cargo clippy -p sift_mcp --all-targets --all-features: no new warnings (the 7 existing ones are in untouched files).list_body_writes_unmatched_fields_before_the_items: the warning is serialized ahead of the items for all 14 list keys.list_body_unmatched_fields_survive_head_truncation: a 500-row body keeps the warning in its first 200 characters.every_fields_tool_documents_unmatched_fields: every tool that acceptsfieldsnames_unmatched_fieldsin itsfieldsbullet and Output section, and never the old key.unmatched_fields, the ordering, truncation, and existing projection tests fail; with one description set back, the docs guard flagslist_runs.Manual (dev org, local
sift-clibuild):list_channelswith a mistyped field returns text starting with{"_unmatched_fields":[...]._unmatched_fieldskey in the response.sift-cli, sees_unmatched_fieldsafter a mistyped field (including on a large, truncated listing) and retries with the correct name.