Repository navigation
fix(showcase): narrow aimock fixture patterns + add drift guardrail - #4155
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
83345fb to
9ab18a8
Compare
@copilotkit/a2ui-renderer
@copilotkitnext/angular
copilotkit
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
copilotkit-vscode-extension
@copilotkit/web-inspector
commit: |
MikeRyanDev
left a comment
There was a problem hiding this comment.
Reviewed locally on 2026-04-22. I checked the fixture narrowing, the new validator/tests, and the bundled Dockerfile + registry-count updates. I didn’t find a review-blocking issue.
Substring-match fixtures (pie chart, bar chart, schedule, trip, etc.) cross-fired across demos with different tool surfaces and returned tool names the target agent never registered, causing demos to render nothing in prod when aimock handles traffic. Fixture changes (showcase/aimock/feature-parity.json): - Replace generic pie-chart / bar-chart matches with per-suggestion specific phrases so gen-ui-tool-based gets render_pie_chart / render_bar_chart directly and beautiful-chat gets pieChart / barChart with real data (skipping the query_data two-step that caused the infinite loop on re-matching prompts). - Narrow schedule+meeting to the Beautiful Chat 30-minute prompt returning scheduleTime. - Narrow flight+fly to flights-from-SFO-to-JFK. - Narrow background to sunset-themed-gradient. - Remove trip, sales, pipeline, todo: substring-false-firing across unrelated demos; interrupt/A2UI demos fall through to real LLM. Guardrail (showcase/scripts/validate-fixture-tool-surface.ts): - Pure validate() cross-references every fixture's tool-call name against the tool surface of each demo whose suggestion prompt contains the fixture's match substring. Loud failure when the fixture returns a tool the demo's agent does not register. - CLI walks packages/ collecting suggestions from page.tsx + hooks/, frontend tools from useComponent / useHumanInTheLoop / useFrontendTool / useRenderTool / useDefaultRenderTool, and backend tools via route.ts agentId->graphId map + langgraph.json graph->file + @tool decorators. - 7 vitest cases written TDD-first covering the drift detection, content-only fixtures, case-insensitivity, and multi-tool responses. - Current state: 33 fixtures x 191 demos, no drift. Counterfactual (reverting the pie-chart fix) correctly flags gen-ui-tool-based and declarative-gen-ui. Also fixes a separate runtime bug in the langgraph-python package Dockerfile: WORKDIR /app left /app owned by root; the app user could not create the .langgraph_api cache dir LangGraph's in-memory runtime needs, so the agent crashed on boot. Added a non-recursive chown app:app /app (preserves the original perf intent of the explicit --chown on COPY, which avoided a recursive chown).
…n-ui scrub Post-#4029 (c92dde4) the langgraph-python manifest dropped from 32 to 30 features/demos when open-gen-ui was scrubbed from the constraint schemas and manifest. The Registry Generator test wasn't updated and has been failing on main since — blocking every subsequent PR's CI. Updates the hardcoded 32 → 30 to match the current manifest reality so CI can go green again. Pre-existing drift, unrelated to the aimock fixture work in the parent commit but bundled here to unblock this PR.
…se job Adds a new step that runs validate-fixture-tool-surface.ts on every PR and push to main. Sits alongside the existing validate-parity / validate-workflow-starters / validate-pins steps and follows the same pnpm-exec-tsx pattern. Without this, the drift validator only runs locally or via the vitest suite (which only catches bugs in the validator itself, not drift in the real fixture/demo state). The CLI invocation against the committed tree is what would have caught the 2026-04-22 regression before it reached prod.
467d350 to
e3ad39c
Compare
|
Totally manually derived feedback:
const PY_TOOLS_ARRAY_RE = /tools\s*=\s*[([^]])]/g; For a line like tools = [make_tool(name="query_data", schema=X)], this harvests make_tool, name,
const SUGGESTION_MESSAGE_RE = /message:\s*( Not scoped to useConfigureSuggestions. Any object with a message: property in page.tsx (error toasts, Scope it to a useConfigureSuggestions(...) block first, then extract message: within that block.
/message:\s*( A suggestion like message:
The 7 tests cover only validate(). parseDemoPage, parseBackendTools, loadAgentRoutes, loadGraphs, |
…opilotKit#4155) ## Summary Showcase demos (e.g. gen-ui-tool-based's "Traffic pie chart", Beautiful Chat's pie/bar-chart suggestions) were rendering nothing in prod because aimock's substring-match fixtures cross-fired across demos with different tool surfaces, returning tool names the target agent never registered. This PR narrows the fixture patterns to fix the immediate breakage and adds a static validator so the same class of drift fails CI before it reaches prod. ## What broke Aimock serves deterministic responses in prod for cost reasons. Fixtures substring-match the user message and return hardcoded tool calls. The `"pie chart"` pattern returned `query_data` (for Beautiful Chat's two-step flow where it has that tool), but the same substring also fires for gen-ui-tool-based's suggestions — which only registers `render_pie_chart`. The returned `query_data` call dangles, no UI renders. Beautiful Chat also looped on the same fixture: aimock has no conversation-turn awareness, so after `query_data` returned its tool result, the follow-up model call had the same user-message context and the fixture re-matched, emitting `query_data` again — infinite until LangGraph's iteration cap. Exposed by PR CopilotKit#4113 (showcase-ops) / the prod-mode migration cluster that started routing prod traffic through aimock. The fixtures themselves had been incrementally drifting for a while, but the routing change turned silent drift into user-visible breakage across many demos simultaneously. ## Fix CopilotKit#1 — narrow the fixture patterns `showcase/aimock/feature-parity.json`: - Replaced the generic `"pie chart"` / `"bar chart"` / `"show pie"` / `"show bar"` patterns with **6 per-suggestion specific-phrase matches**. gen-ui-tool-based and declarative-gen-ui get `render_pie_chart` / `render_bar_chart` directly; Beautiful Chat gets `pieChart` / `barChart` with real data (skipping the query_data loop). - Narrowed `"schedule"` + `"meeting"` into one match for Beautiful Chat's "30-minute meeting to learn about CopilotKit" → `scheduleTime`. - Narrowed `"flight"` / `"fly"` to `"flights from SFO to JFK"`. - Narrowed `"background"` to `"sunset-themed gradient"`. - Removed `"trip"`, `"sales"`, `"pipeline"`, `"todo"` — too generic, substring-false-firing across unrelated demos. Interrupt and A2UI demos with those prompts fall through to the real LLM proxy. ## Fix CopilotKit#2 — static drift guardrail New `showcase/scripts/validate-fixture-tool-surface.ts`: - Pure `validate()` function: for each fixture with tool-call responses, finds every demo whose suggestion prompt contains the fixture's match substring, then asserts the fixture's returned tool names are all registered by that demo's agent. - CLI walks `packages/*/` collecting: - suggestions from `page.tsx` + sibling `hooks/*.tsx` - frontend tools from `useComponent` / `useHumanInTheLoop` / `useFrontendTool` / `useRenderTool` / `useDefaultRenderTool` calls - backend tools via `api/copilotkit*/route.ts` → agentId→graphId map → `langgraph.json` graph→Python-file → `@tool` decorators + `tools=[...]` arrays - 7 vitest cases written TDD-first (watched fail, then implemented) covering: drift detection, content-only fixtures, no-matching-demo, case-insensitivity, multi-demo cross-check, multi-tool responses. Runs as `npx tsx showcase/scripts/validate-fixture-tool-surface.ts`. Exit 0 = clean; exit 1 = per-fixture drift report. Current state: **33 fixtures × 191 demos, no drift.** Counterfactual: reverting just the pie-chart fixture fix correctly flags `langgraph-python/gen-ui-tool-based` and `langgraph-python/declarative-gen-ui` — i.e. the exact demos that broke in prod. ## Also fixed — unrelated LangGraph Python Dockerfile bug `showcase/packages/langgraph-python/Dockerfile`: `WORKDIR /app` left `/app` owned by root; the explicit `--chown=app:app` on COPY lines chowned *contents* but not the directory itself, so the `app` user couldn't create `.langgraph_api` (the in-memory LangGraph runtime's cache dir) and the agent crashed on boot with `PermissionError: [Errno 13]`. Added a non-recursive `chown app:app /app` (preserves the perf intent of not doing a recursive chown). ## Known follow-ups (out of scope for this PR) - Interrupt demos (`gen-ui-interrupt`, `interrupt-headless`, `hitl-in-chat`) and A2UI demos (`declarative-gen-ui`, `a2ui-fixed-schema`, `mcp-apps`, Calculator App) currently fall through to the real LLM when unmatched. Faithful fakes would need per-agent fixture keying in the aimock engine — separate upstream change. - Python backend-tool parser uses regex; misses star-spread collections like `tools=[query_data, *todo_tools]`. Safe failure mode — missing tools surface as guardrail drift rather than silently pass. - Add this validator to `.github/workflows/showcase_*.yml` so CI runs it on every PR touching fixtures or demos. ## Test plan - [x] `npx vitest run showcase/scripts/__tests__/validate-fixture-tool-surface.test.ts` — 7/7 pass - [x] `npx vitest run showcase/scripts/__tests__/aimock-fixtures.test.ts` — 17/17 still pass (no regression) - [x] `npx tsx showcase/scripts/validate-fixture-tool-surface.ts` — 33 fixtures × 191 demos, 0 drift - [x] Counterfactual: revert fixture fix, validator flags gen-ui-tool-based + declarative-gen-ui exactly - [x] Direct aimock probe (localhost:4010) for all 8 fixed prompts → returns correct tool call - [x] End-to-end through local LangGraph agent (localhost:3100) → gen-ui-tool-based "Traffic pie chart" suggestion → `render_pie_chart` with real data - [ ] Merge → Railway redeploys aimock + langgraph-python → smoke cycle on Beautiful Chat + gen-ui-tool-based + declarative-gen-ui suggestions
Summary
Showcase demos (e.g. gen-ui-tool-based's "Traffic pie chart", Beautiful Chat's pie/bar-chart suggestions) were rendering nothing in prod because aimock's substring-match fixtures cross-fired across demos with different tool surfaces, returning tool names the target agent never registered. This PR narrows the fixture patterns to fix the immediate breakage and adds a static validator so the same class of drift fails CI before it reaches prod.
What broke
Aimock serves deterministic responses in prod for cost reasons. Fixtures substring-match the user message and return hardcoded tool calls. The
"pie chart"pattern returnedquery_data(for Beautiful Chat's two-step flow where it has that tool), but the same substring also fires for gen-ui-tool-based's suggestions — which only registersrender_pie_chart. The returnedquery_datacall dangles, no UI renders.Beautiful Chat also looped on the same fixture: aimock has no conversation-turn awareness, so after
query_datareturned its tool result, the follow-up model call had the same user-message context and the fixture re-matched, emittingquery_dataagain — infinite until LangGraph's iteration cap.Exposed by PR #4113 (showcase-ops) / the prod-mode migration cluster that started routing prod traffic through aimock. The fixtures themselves had been incrementally drifting for a while, but the routing change turned silent drift into user-visible breakage across many demos simultaneously.
Fix #1 — narrow the fixture patterns
showcase/aimock/feature-parity.json:"pie chart"/"bar chart"/"show pie"/"show bar"patterns with 6 per-suggestion specific-phrase matches. gen-ui-tool-based and declarative-gen-ui getrender_pie_chart/render_bar_chartdirectly; Beautiful Chat getspieChart/barChartwith real data (skipping the query_data loop)."schedule"+"meeting"into one match for Beautiful Chat's "30-minute meeting to learn about CopilotKit" →scheduleTime."flight"/"fly"to"flights from SFO to JFK"."background"to"sunset-themed gradient"."trip","sales","pipeline","todo"— too generic, substring-false-firing across unrelated demos. Interrupt and A2UI demos with those prompts fall through to the real LLM proxy.Fix #2 — static drift guardrail
New
showcase/scripts/validate-fixture-tool-surface.ts:validate()function: for each fixture with tool-call responses, finds every demo whose suggestion prompt contains the fixture's match substring, then asserts the fixture's returned tool names are all registered by that demo's agent.packages/*/collecting:page.tsx+ siblinghooks/*.tsxuseComponent/useHumanInTheLoop/useFrontendTool/useRenderTool/useDefaultRenderToolcallsapi/copilotkit*/route.ts→ agentId→graphId map →langgraph.jsongraph→Python-file →@tooldecorators +tools=[...]arraysRuns as
npx tsx showcase/scripts/validate-fixture-tool-surface.ts. Exit 0 = clean; exit 1 = per-fixture drift report.Current state: 33 fixtures × 191 demos, no drift.
Counterfactual: reverting just the pie-chart fixture fix correctly flags
langgraph-python/gen-ui-tool-basedandlanggraph-python/declarative-gen-ui— i.e. the exact demos that broke in prod.Also fixed — unrelated LangGraph Python Dockerfile bug
showcase/packages/langgraph-python/Dockerfile:WORKDIR /appleft/appowned by root; the explicit--chown=app:appon COPY lines chowned contents but not the directory itself, so theappuser couldn't create.langgraph_api(the in-memory LangGraph runtime's cache dir) and the agent crashed on boot withPermissionError: [Errno 13]. Added a non-recursivechown app:app /app(preserves the perf intent of not doing a recursive chown).Known follow-ups (out of scope for this PR)
gen-ui-interrupt,interrupt-headless,hitl-in-chat) and A2UI demos (declarative-gen-ui,a2ui-fixed-schema,mcp-apps, Calculator App) currently fall through to the real LLM when unmatched. Faithful fakes would need per-agent fixture keying in the aimock engine — separate upstream change.tools=[query_data, *todo_tools]. Safe failure mode — missing tools surface as guardrail drift rather than silently pass..github/workflows/showcase_*.ymlso CI runs it on every PR touching fixtures or demos.Test plan
npx vitest run showcase/scripts/__tests__/validate-fixture-tool-surface.test.ts— 7/7 passnpx vitest run showcase/scripts/__tests__/aimock-fixtures.test.ts— 17/17 still pass (no regression)npx tsx showcase/scripts/validate-fixture-tool-surface.ts— 33 fixtures × 191 demos, 0 driftrender_pie_chartwith real data