fix(vtex): surface curated param descriptions to the agent - #523
Closed
guitavano wants to merge 1 commit into
Closed
fix(vtex): surface curated param descriptions to the agent#523guitavano wants to merge 1 commit into
guitavano wants to merge 1 commit into
Conversation
Generated Zod schemas are produced with `metadata: false`, so no field description reaches the tool inputSchema (the JSON Schema the LLM sees). Agents got bare `f_RnB: string` with no hint of meaning or value format — which is why an agent couldn't map a coupon/promotion query to `f_RnB`. Rather than re-enabling metadata globally (measured: +1.57 MB / +35% server bundle, plus unrelated upstream schema drift and a broken export on regen), layer curated descriptions onto the flattened input schema in the tool adapter. Covers the params where the omission hurts on VTEX_LIST_ORDERS (f_RnB, date ranges, status, full-text q), written richer than the raw OpenAPI text — e.g. f_RnB now explains the coupon -> promotion-id lookup. Bundle unchanged (4.70 MB). Adds regression tests asserting descriptions reach the agent-facing JSON Schema and that overrides keep fields optional. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Consolidado no #525 (PR único cobrindo sync + metadata + overrides curados). |
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.
Problem
An agent using the VTEX MCP couldn't figure out it needed
f_RnBto count sales for a coupon/promotion (e.g.FICA10/ "Pop retenção DECO"). Root cause: the agent gets no description at all for that parameter.The generated Zod schemas are produced with
metadata: falseinopenapi-ts.config.ts(comment: "descriptions are not read at runtime"). That's inaccurate for an MCP — the input schema is read at runtime: it becomes the JSON Schema sent to the LLM. With metadata off, everyf_filter on every VTEX tool reaches the agent as a baref_RnB: string, with no meaning and no value format. The rich JSDoc intypes.gen.tsnever leaves compile time.Why not just flip
metadata: true?Measured it:
metadata: false)metadata: true(regen)Regenerating also can't be isolated:
download-schemaspulls current upstream, which drifts (~10k lines across 72 files), renames an operation (postApiAuthenticator→postApiAuthenticatorV1StorefrontUsers) that breaks aregistry.tsreference, and adds new modules. That's a separate "sync schemas" concern, not this fix.This PR
Layer curated descriptions onto the flattened input schema in the tool adapter (
applyParamDescriptions), keyed by tool id → field. Covers theVTEX_LIST_ORDERSparams where the omission actually hurts, written richer than the raw OpenAPI text:f_RnB— explains it takes the promotion id, not the coupon code, and that you resolveFICA10/ a promotion name via the promotions tools first.f_creationDate/f_invoicedDate— thecreationDate:[<from> TO <to>]UTC range format.f_status— the closed set of valid statuses.q— what full-text search matches.Adding coverage later = one line in
param-descriptions.ts.Impact
f_RnBand the other curated params now carry descriptions in the agent-facing JSON Schema (verified end-to-end viaz.toJSONSchema).Tests
bun test server/tools/registry.test.ts→ 53 pass. New regression tests assert the curated descriptions reach the JSON Schema, that overriding a field keeps it optional, and that tools without overrides are returned unchanged.Follow-up (out of scope)
Whether to do a full
metadata: trueregen for blanket coverage is a separate decision — it needs the +1.57 MB bundle accepted and the upstream drift / renamed export handled deliberately.🤖 Generated with Claude Code
Summary by cubic
Exposes curated parameter descriptions to the agent so VTEX filters like
f_RnB, date ranges, status, andqare clear and usable. Fixes the missing metadata that blocked counting sales by coupon/promotion, without increasing the bundle size.applyParamDescriptions.VTEX_LIST_ORDERS:f_RnB(promotion id, not coupon),f_creationDate/f_invoicedDaterange format, validf_statusvalues, and whatqsearches.Written for commit b55084a. Summary will update on new commits.