Skip to content

query_sql: bake the three query rules into the sql param description - #346

Closed
bgmcmullen wants to merge 1 commit into
masterfrom
query-sql-param-rules
Closed

query_sql: bake the three query rules into the sql param description#346
bgmcmullen wants to merge 1 commit into
masterfrom
query-sql-param-rules

Conversation

@bgmcmullen

Copy link
Copy Markdown
Contributor

What

Extends the query_sql verb's sql parameter description with the three query rules an MCP caller needs at call time: date-filter ai_gateway_messages (with the slice-size guidance), the dialect and column-name gotchas (SELECT-only, || concat, conversation_source/client_name, TIMESTAMP-vs-string comparison, where token usage lives), and the dedup-by-part_id recipe for sums.

The parameter description travels to the model through the MCP inputSchema (toJsonSchema passes property descriptions through) without touching verb.summary, which doubles as the one-line CLI summary in help listings under the LLP 0034 one-declaration projection. The neighboring include-local-only property already carries a long model-facing description as precedent.

Why

From the Team AI Usage Review 2026-07-16 (prod fleet, 2026-06-16 → 2026-07-16), proposed change 6 (re-proposed from 07-15): query_sql failed 27% of its calls this window (47 of 173 on one machine). Sampled causes are exactly these three rule classes — timeouts from unfiltered scans, repeated dialect and column-name mistakes, and undeduped sums. The rules exist in the hypaware-query skill file, but the MCP tool path never loads skill files, so the tool has to teach its own dialect.

Rule 3 is the guard rail until the server-side ingest dedup lands (hyparam/hypaware-server#133 / #134); it stays true afterward as a safe default ("the table can re-log rows").

Notes

  • The report aimed this at hypaware-server, but the tool description is assembled from core's verb declaration (src/core/mcp/server.js reads verb.summary + inputSchema), so this repo is where the text lives; the server serves the same projected tool.
  • test/core/mcp-server.test.js + test/core/verb-codec.test.js: 23/23 pass; full npm test failure set is unchanged from master in this environment.

🤖 Generated with Claude Code

The MCP path never loads the hypaware-query skill file, so the rules
(date-filter ai_gateway_messages, dialect and column gotchas, dedupe
sums by part_id) ride the inputSchema the model reads at call time.
verb.summary stays one line for the CLI listing.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for freeto 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

@bgmcmullen