Actionable hint on upstream errors (weclapp field/filter grammar, Sorare new-location login) - #583
Open
keysersoft wants to merge 1 commit into
Open
Actionable hint on upstream errors (weclapp field/filter grammar, Sorare new-location login)#583keysersoft wants to merge 1 commit into
keysersoft wants to merge 1 commit into
Conversation
…ps retrying Two failure shapes send AI clients into loops: weclapp's 'unknown property: X' (the model tries other spellings for ten calls; 194 failures in a week from one workspace) and Sorare's authenticate_from_new_country (no retry can fix it, only the account owner confirming the vendor's email). The tool result now carries a 'hint' next to the unmodified vendor body: how weclapp field names work and how to discover them, the expression vs query-string filter grammar, and the hand-over-to-the-user message for new-location refusals. Keyed on the upstream host so hand-built tools get the same help as catalog ones. Audit rows keep the raw cause only.
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.
What
Adds a
hintfield to the error result a tool returns to the AI client, beside the unmodified vendor body. Pure modulemcp-server/error-hints.ts, keyed on the upstream host (so hand-built tools against the same API get the same help as catalog ones) or on the error text.Rules shipped:
unknown property/unexpected filter property→ how field names work (camelCase, line items nested underorderItems/salesInvoiceItems, links end inId) and the one reliable way to discover them: fetch one record withoutproperties, read the names, retry with those. This is the loop behind 194 failures in 7 days from a single starter workspace.Expression contains errors→ the filter-expression grammar (=,!=,~ "%pattern%",in [...], nolike/ilike), for tools that sendfilteras an expression.invalid parameter value/ unknown query parameter → the query-string form (property-operator=value,-in=[...]).authenticate_from_new_country/ new-device refusals (Sorare via LOGIN_TOKEN) → tell the user to confirm the login from the vendor's email; retrying cannot fix it.Audit rows keep the raw upstream cause only; the hint is for the client.
Verification
error-hints.spec.tscovers each rule, host scoping (another vendor saying "unknown property" gets nothing) and URL/host extraction.dynamic-mcp-tools.spec.tsgains two executor-level tests: a weclapp 400 carries both the vendor detail and the hint, and the audit row excludes the hint; an ordinary failure gets no hint.