Repository navigation
fix(showcase): make the A2UI fixed-schema guide followable (OSS-901) - #6645
Merged
Merged
Conversation
Contributor
Production Digest-Pinning AuditAll 42 services digest-pinned. Run 2026-08-21 06:51:42 PDT — 0 finding(s). |
BenTaylorDev
marked this pull request as ready for review
August 21, 2026 13:40
BenTaylorDev
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
August 21, 2026 13:40
`/mastra/generative-ui/a2ui/fixed-schema` published the entire 432-line tools barrel, because the `backend-render-operations` marker sits at the top of the file (the marker-hoist sweep in 34b6418 put it there so the snippet would carry its imports). The published body therefore included every unrelated tool plus `import { ... } from "@copilotkit/showcase-shared-tools"` — a tsconfig path alias to a symlink in this repo, not a package a reader can install. A Mastra onboarding run stopped there rather than invent an API (OSS-901). Move `generateA2uiTool` into its own module and mark the region there, so hoisting to the top of the file yields exactly the tool plus its own imports — the same shape as the reference cell, `langgraph-typescript/src/agent/a2ui-fixed.ts`, which likewise builds the A2UI operations locally instead of importing the showcase's shared tools. The published snippet goes from 432 lines to 166, and everything in it either installs from npm or is a visibly local `./` / `@/` module with a comment saying what a real app would use instead. `buildA2uiOperations` and `systemPromptFrom` replace the two shared-tools helpers so mastra keeps a single operation builder: the beautiful-chat flight tool now calls the same one. The prompt builder lands in the dependency-free `a2ui-context.ts` so its regression test keeps running without the Mastra SDK installed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Same defect as the mastra cell, same page: the `backend-render-operations`
marker is hoisted to the top of `agents/agent.py`, so
`/aws-strands/generative-ui/a2ui/fixed-schema` published 586 lines of a
1688-line module — the messages-snapshot wrapper, the weather/dice/query
tools, everything — instead of the A2UI tool the step is about.
Move `generate_a2ui` and its `_A2uiError` shape into
`agents/a2ui_generate.py`, which is what `gen_ui_agent.py` /
`a2ui_dynamic.py` already do for their own surfaces ("this module lives in
its own file so the surface area is reviewable in isolation"). `agent.py`
imports the tool back for the shared agent's tool list, so the wiring and
the tool id are unchanged; the published snippet is now 171 lines with its
own imports. `tools/generate_a2ui.py` joins the cell's highlighted files so
the guide also shows the helper the tool calls.
The error-handling suite patched `agents.agent.build_a2ui_operations_from_tool_call`,
which now lives on the new module — retargeted, and it still imports the
tool via `agents.agent` so the re-export stays covered.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Region bodies are assembled at bundle time, so neither failure mode in the two preceding commits is visible in review — the source diff looks fine while the docs page renders a 400-line slab or an uninstallable import. Two checks over every region the bundler is about to publish: - Any `@copilotkit/showcase-*` specifier fails the build. These resolve only through a tsconfig path alias to a symlink in this repo, so they cannot appear in a snippet a reader is meant to copy. The corpus is at zero once OSS-901 is fixed, so there is no baseline. - Over 200 lines fails the build. The median region is 28 lines and p90 is 125, so 200 catches a marker sitting above unrelated code without arguing about genuinely long single-purpose files (the 344-line declarative-gen-ui renderers.tsx is the point of that page). The 48 regions already over the line are baselined by `slug::region::file` and the list only shrinks. Both are reported together for the whole run, so one build lists every unfollowable snippet instead of only the first. Verified against the pre-fix tree: the guard exits 1 and names both the mastra `@copilotkit/showcase-shared-tools` bodies and the 586-line strands region. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The A2UI setup page imported `ExperimentalEmptyAdapter` and `copilotRuntimeNextJSAppRouterEndpoint` and then used neither, so the block was a truncated route a reader could not run. Show a complete route — and show the current API while doing it: #6618 retired the v1 runtime adapter across every showcase integration, so the page now uses `createCopilotRuntimeHandler` from `@copilotkit/runtime/v2` in the single-route form, matching `mastra/src/app/api/copilotkit-a2ui-fixed-schema/route.ts` and the reference in /runtime-server-adapter. That also settles the entrypoint question OSS-901 raised. The complaint was that the page mixes v1 `@copilotkit/runtime` with `@copilotkit/react-core/v2` below — not a broken pairing (v1's `CopilotRuntime` forwards `a2ui` straight to the v2 runtime), but the v1 root import was the stale half, so both halves of the page are now v2 entry points. The legacy form is noted as still working for readers who are on it. On the fixed-schema page, note that the LLM-driven integrations have no `a2ui.render(...)` equivalent, so the operation builder in the snippet is part of what a reader copies — and that the operations are nested, since a flat `{ type: "create_surface" }` is silently ignored. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
BenTaylorDev
force-pushed
the
ben1/oss-901-a2ui-fixed-schema-followable
branch
from
August 21, 2026 13:50
13bed7d to
a43bd7c
Compare
Reapplies the formatter fix the CI auto-format job pushed (13bed7d), which a rebase force-push dropped. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
MikeRyanDev
approved these changes
Aug 21, 2026
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.
Closes OSS-901.
Problem
/mastra/generative-ui/a2ui/fixed-schemacould not be followed. A Mastra onboarding run on Codex stopped there rather than invent an API, reporting that the guide "depends on unbundled showcase helpers."That is true, and the mechanism is worse than the report. Region bodies are assembled at bundle time, so what ships is invisible in a source diff. The
backend-render-operationsmarker sits on line 1 ofmastra/src/mastra/tools/index.ts— put there by the marker-hoist sweep in 34b6418 so snippets would carry their imports — and the closing marker is at the bottom of the file. The page therefore published all 432 lines of the tools barrel: weather, stock price, dice, d20, query-data, schedule-meeting, search-flights, the aimock header-forwarding import, and@copilotkit/showcase-shared-toolsis not a package. It is a tsconfigpathsentry (mastra/tsconfig.json:23) pointing at./shared-tools, a symlink toshowcase/shared/typescript/tools. There is nothing for a reader to install.Same defect on the strands page from the same sweep: 586 lines of a 1688-line
agents/agent.py.What changed
The two cells get a dedicated module for the A2UI tool, so hoisting the marker to the top of the file yields exactly the tool plus its own imports. This is the shape of the reference cell (
langgraph-typescript/src/agent/a2ui-fixed.ts, which likewise builds A2UI operations locally) and, on the Python side, ofgen_ui_agent.py/a2ui_dynamic.py.Every line in the new snippets either installs from npm or is a visibly local
.//@/module carrying a comment about what a real app uses instead. Mastra keeps a single operation builder — the beautiful-chat flight tool now calls the same one. The strands cell also highlightstools/generate_a2ui.pyso the guide shows the helper the tool calls.A guard in the bundler, because neither failure mode shows up in review:
@copilotkit/showcase-*specifier in a published body fails the build (corpus is at zero after this change, so no baseline);slug::region::fileand the list only shrinks).The entrypoint half of the issue lands differently than I first read it. OSS-901 flagged
@copilotkit/runtime+@copilotkit/react-core/v2on the shared A2UI page as a v1/v2 trap. It is not a broken pairing — v1'sCopilotRuntimeforwardsa2ui(andmcpApps/openGenerativeUI) straight to the v2 runtime (packages/runtime/src/lib/runtime/copilot-runtime.ts:414). But #6618 landed while this branch was open and retired the v1 runtime adapter across every showcase integration, so the page's v1 root import was the stale half. The block also importedExperimentalEmptyAdapterandcopilotRuntimeNextJSAppRouterEndpointand used neither, so it was a route a reader could not run. It now showscreateCopilotRuntimeHandlerfrom@copilotkit/runtime/v2in the single-route form, matching the rebased showcase route and/runtime-server-adapter, with a note that the legacy form still works.On the systemic question. A separate sweep counted ~50 regions whose marker sits on line 1 with a matching close at end-of-file, and proposed failing a region that spans >=90% of its file. That rule does not survive contact with the published bodies: of 141 regions at >=90% span, only 2 publish more than 200 lines, and 98 publish under 100 — dedicated single-purpose files whose whole content is the intended snippet. It would also flag this PR's own fix (
strands/a2ui_generate.pyis 171/188 = 91%) and the langgraph reference cells. Published size is the signal that separates the defect from the pattern, which is what the guard here measures.Testing
Guard catches the pre-fix tree (restored HEAD sources, moved the new modules aside, ran the bundler):
and passes on this branch (
bundler exit=0, 801 demos bundled).Guard unit tests —
showcase/scripts/lib/__tests__/demo-region-guard.test.ts, 10 passed. Mutation-checked: raisingMAX_REGION_LINESand short-circuiting the alias scan fails exactly 2 of them; restoring passes 10/10.Showcase script suites —
demo-region-guard,bundle-demo-content,validate-parity,verify-shell-docs,validate-shared-symlinks: 151 passed (5 files).Mastra vitest —
tests/vitest/a2ui-context.test.ts, 5 passed. The prompt builder lives in the dependency-freea2ui-context.tsso this regression test still runs without the Mastra SDK installed, as it did before. Mutation-checked: breaking the join fails 1 of 5.Strands pytest —
tests/python/test_generate_a2ui_errors.py11 passed (was 1 failed / 10 passed after the move, because the happy-path test patchedagents.agent.build_a2ui_operations_from_tool_call; retargeted at the new module). Whole runnable suite: 40 passed acrosstest_generate_a2ui_errors,test_hook_injection,test_sales_state_from_args,test_tool_call_cap. Mutation-checked: stubbing out the builder call fails the happy-path test.test_cvdiag_boundaries/test_instrumentor_patchneedstarlette/opentelemetry-instrumentation-threading, absent from this venv — unrelated to this change.Published snippet, rendered (
demo-content.jsonafter bundling):Docs verification —
verify-shell-docs.tsproduces a byte-identical finding set with my two MDX edits toggled on and off (empty diff), so the edits add no new findings.component-imports,essential-contentand the rest are unchanged; the suite's pre-existing failures are untouched.Lint / format —
oxfmton all changed TS,oxlintclean on the new and edited files.Follow-ups (not in this PR)
strands::supervisor-delegation-toolspublishes 795 lines,strands::subagent-setup625,ms-agent-dotnet::weather-tool-backend549. Each wants the same split.claude-sdk-typescript/shared-tools/andlanggraph-typescript/shared-tools/are real directories where symlinks belong — the erosionshowcase/AGENTS.mddocuments. Untouched here.14c7351) is safe on its own; it only requires addingstrands::backend-render-operations::src/agents/agent.pyto the guard baseline.🤖 Generated with Claude Code