Skip to content

fix(showcase): narrow aimock fixture patterns + add drift guardrail - #4155

Merged
MikeRyanDev merged 3 commits into
mainfrom
fix/aimock-fixture-tool-surface-drift
Apr 22, 2026
Merged

MikeRyanDev merged 3 commits into
mainfrom
fix/aimock-fixture-tool-surface-drift

Conversation

@AlemTuzlak

Copy link
Copy Markdown
Contributor

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 #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:

  • 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 #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

  • npx vitest run showcase/scripts/__tests__/validate-fixture-tool-surface.test.ts — 7/7 pass
  • npx 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 drift
  • Counterfactual: revert fixture fix, validator flags gen-ui-tool-based + declarative-gen-ui exactly
  • Direct aimock probe (localhost:4010) for all 8 fixed prompts → returns correct tool call
  • 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

@vercel

vercel Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat-with-your-data Ready Ready Preview, Comment Apr 22, 2026 3:21pm
docs Ready Ready Preview, Comment Apr 22, 2026 3:21pm
form-filling Ready Ready Preview, Comment Apr 22, 2026 3:21pm
research-canvas Ready Ready Preview, Comment Apr 22, 2026 3:21pm
travel Ready Ready Preview, Comment Apr 22, 2026 3:21pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📣 Social Copy Generator

Generate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.

  • Generate social media copies

@pkg-pr-new

pkg-pr-new Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/a2ui-renderer@4155

@copilotkitnext/angular

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkitnext/angular@4155

copilotkit

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/copilotkit@4155

@copilotkit/core

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/core@4155

@copilotkit/react-core

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/react-core@4155

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/react-textarea@4155

@copilotkit/react-ui

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/react-ui@4155

@copilotkit/runtime

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/runtime@4155

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/runtime-client-gql@4155

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/sdk-js@4155

@copilotkit/shared

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/shared@4155

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/sqlite-runner@4155

@copilotkit/voice

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/voice@4155

copilotkit-vscode-extension

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/copilotkit-vscode-extension@4155

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/web-inspector@4155

commit: e3ad39c

MikeRyanDev
MikeRyanDev previously approved these changes Apr 22, 2026

@MikeRyanDev MikeRyanDev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

MikeRyanDev
MikeRyanDev previously approved these changes Apr 22, 2026
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.
@BenTaylorDev
BenTaylorDev self-requested a review April 22, 2026 15:28
@BenTaylorDev

BenTaylorDev commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Totally manually derived feedback:

  1. parseBackendTools leaks non-tool identifiers into the tool surface
    (validate-fixture-tool-surface.ts:155-179)

const PY_TOOLS_ARRAY_RE = /tools\s*=\s*[([^]])]/g;
const PY_NAME_TOKEN_RE = /[a-zA-Z_][a-zA-Z0-9_]
/g;
// ...
for (const tok of body.matchAll(PY_NAME_TOKEN_RE)) {
const name = tok[0];
if (["None", "True", "False", "self", "cls"].includes(name)) continue;
names.add(name); // adds EVERY identifier in the array body
}

For a line like tools = [make_tool(name="query_data", schema=X)], this harvests make_tool, name,
query_data, schema, X as registered tools. Wrong direction for a drift validator — a wider tool surface
means real drift gets masked (false negative). If any local tools = [...] variable exists in a helper
function, its contents pollute too. The [^]]* also can't span nested brackets. Either tighten to
tools\s*=\s*[\s*([a-zA-Z_][a-zA-Z0-9_,\s])\s] (identifier list only) or rely solely on @tool
decorator discovery.

  1. SUGGESTION_MESSAGE_RE matches any message: key (line 117-118)

const SUGGESTION_MESSAGE_RE = /message:\s*([^]*`|"..."|'...')/g;

Not scoped to useConfigureSuggestions. Any object with a message: property in page.tsx (error toasts,
log lines, unrelated configs) gets harvested as a suggestion. If a harvested string happens to contain
one of the narrowed fixture phrases, you'd get a spurious cross-reference check — could be false
positive or (if the tool happens to be registered) false negative.

Scope it to a useConfigureSuggestions(...) block first, then extract message: within that block.

  1. Template-literal suggestions with ${...} silently unvalidated (line 117-131)

/message:\s*([^]*`|...)/g

A suggestion like message: Show ${N} items gets extracted verbatim as Show ${N} items — it will never
match a real user message, so any fixture drift in dynamic suggestions is invisible. Low-frequency
pattern in this codebase, but worth at least logging as "skipped unresolvable suggestion" instead of
silently swallowing.

  1. Zero unit tests for the harvesters (tests/validate-fixture-tool-surface.test.ts)

The 7 tests cover only validate(). parseDemoPage, parseBackendTools, loadAgentRoutes, loadGraphs,
collectDemoSurfaces are not covered.

@MikeRyanDev
MikeRyanDev merged commit 6ab211b into main Apr 22, 2026
14 checks passed
@MikeRyanDev
MikeRyanDev deleted the fix/aimock-fixture-tool-surface-drift branch April 22, 2026 15:42
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
…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

This branch was successfully deployed

5 active deployments
Preview – research-canvas — e3ad39c1 Deployed Apr 22, 2026 by vercel[bot]
Preview – travel — e3ad39c1 Deployed Apr 22, 2026 by vercel[bot]
Preview – form-filling — e3ad39c1 Deployed Apr 22, 2026 by vercel[bot]
Preview – docs — e3ad39c1 Deployed Apr 22, 2026 by vercel[bot]
Preview – chat-with-your-data — e3ad39c1 Deployed Apr 22, 2026 by vercel[bot]
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.

3 participants