Skip to content

fix(provider): reduce tool schemas to Gemini's subset; show degraded MCP reasons in the TUI - #162

Merged
lg2m merged 1 commit into
feat/eng-881-tui-trust-promptfrom
chore/eng-897-eng-898-onboarding-followups
Sep 25, 2026
Merged

lg2m merged 1 commit into
feat/eng-881-tui-trust-promptfrom
chore/eng-897-eng-898-onboarding-followups

Conversation

@lg2m

@lg2m lg2m commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Stack (3/3): #160 → #161 → this PR. Based on feat/eng-881-tui-trust-prompt; shows only its own diff.

Follow-ups collected across the onboarding plan. Linear: ENG-897 (Gemini), ENG-898 (the rest).

1. Gemini rejected every tool-using run — fixed (ENG-897)

Every built-in tool schema sets additionalProperties: false, and Gemini's Schema type is a restricted OpenAPI subset that rejects it (and $schema, $ref, oneOf, … which MCP servers commonly send) with provider returned HTTP 400: Invalid JSON payload received. Unknown name "additionalProperties". So any google/* model failed the moment it tried a tool. Found during OB3's manual test.

Fix: ToolSpec carries a lazily computed, cached Gemini form (OnceLock) with unsupported keywords stripped at every depth; only the Google codec reads it. OpenAI, Anthropic, and Bedrock bodies are byte-for-byte unchanged; catalog digests unchanged (equality/hash stay on the original text). Four bare enum properties gain "type": "string".

Hot path: one serde_json parse per spec on first use, then an atomic load. provider_encode bench, Google, 32 tools × 1 MiB transcript: 389–404 µs before, 404–405 µs after (noise); body 928 bytes smaller.

Tests: reduced schema captured on the wire while OpenAI/Anthropic keep the original; computed once and shared by clones; nothing-to-strip returns identical text. The built-in schema fingerprint golden updated (prompt-identity metadata, not a compatibility gate).

2. Degraded MCP reason visible in the TUI (ENG-898)

OB9 made a server with a missing credential degrade instead of failing the run, but the reason only reached qq doctor. It now shows as a warning on the composer rule once per distinct message (unavailable MCP servers: linear (credential … run qq auth set linear/default)) and under the search row of /skills. A healthy capabilities document clears the memory so a later regression warns again.

3–6. Housekeeping

  • AGENTS.md: Linear team is ENG, not DEV; branch examples updated.
  • docs/plans/onboarding-ux.md: the eight guide topics the site dropped, as unscheduled candidates with the source material for each.
  • docs/runbooks/local-dev.md: recommend a shared CARGO_TARGET_DIR across .worktrees/ (per-worktree targets filled a 915 GB disk this week). No repo .cargo/config.toml — it would affect CI caches.
  • website/tsconfig.json comment: the nub fix (tsconfig extends: exports wildcard subpaths (astro/tsconfigs/strict) never resolve nubjs/nub#804) is merged upstream but not released; revert to extends after the next release.

Verification

fmt, clippy -D warnings, cargo test --workspace (1864 on the stacked tip), cargo test -p qq-provider --no-default-features --features test-support, cargo bench -p qq-provider --bench provider_encode.

…MCP reasons in the TUI

Every built-in tool schema sets `additionalProperties: false`, and MCP
servers may declare `$schema`, `$ref`, `oneOf`, and other JSON Schema
keywords Gemini's Schema type rejects with HTTP 400, so every tool-using
run on `google/*` failed. `ToolSpec` now carries a lazily computed,
cached Gemini form (unsupported keywords stripped at every depth) that
only the Google codec reads; OpenAI, Anthropic, and Bedrock bodies are
byte-for-byte unchanged and the steady-state encode cost is unchanged
(one parse per spec, on first use). Four bare `enum` properties gain
`"type": "string"`.

The TUI now surfaces a degraded tool host's reason (`unavailable MCP
servers: linear (credential ... run qq auth set ...)`) as a warning on
the composer rule once per distinct message, and under the search row of
`/skills`.

Also: AGENTS.md names the Linear team `ENG`; the plan lists the eight
guide topics the site dropped as unscheduled candidates; local-dev
recommends a shared CARGO_TARGET_DIR across worktrees; the website
tsconfig comment tracks the nub release that lets it revert.

Closes ENG-897, ENG-898.
@lg2m
lg2m added this pull request to stack #174 September 25, 2026 14:32
@lg2m
lg2m merged commit 536a817 into main Sep 25, 2026
6 checks passed
@lg2m
lg2m deleted the chore/eng-897-eng-898-onboarding-followups branch September 25, 2026 14:37
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