Skip to content

Actionable hint on upstream errors (weclapp field/filter grammar, Sorare new-location login) - #583

Open
keysersoft wants to merge 1 commit into
mainfrom
keysersoft/upstream-error-hints
Open

Actionable hint on upstream errors (weclapp field/filter grammar, Sorare new-location login)#583
keysersoft wants to merge 1 commit into
mainfrom
keysersoft/upstream-error-hints

Conversation

@keysersoft

Copy link
Copy Markdown
Contributor

What

Adds a hint field to the error result a tool returns to the AI client, beside the unmodified vendor body. Pure module mcp-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:

  • weclapp unknown property / unexpected filter property → how field names work (camelCase, line items nested under orderItems/salesInvoiceItems, links end in Id) and the one reliable way to discover them: fetch one record without properties, read the names, retry with those. This is the loop behind 194 failures in 7 days from a single starter workspace.
  • weclapp Expression contains errors → the filter-expression grammar (=, !=, ~ "%pattern%", in [...], no like/ilike), for tools that send filter as an expression.
  • weclapp 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.ts covers each rule, host scoping (another vendor saying "unknown property" gets nothing) and URL/host extraction.
  • dynamic-mcp-tools.spec.ts gains 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.
  • tsc clean.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant