Commit Graph

4771 Commits

Author SHA1 Message Date
Jordan Ritter 46f810779c fix(showcase): wire langroid declarative-gen-ui via Option A (JS-injected A2UI)
Supersedes #6058's two-stage approach (outer generate_a2ui → secondary Python
LLM call → render_a2ui), which severed across the prod streaming boundary.

Option A: `injectA2UITool` (default true) causes CopilotKit's A2UIMiddleware to
inject `render_a2ui` into RunAgentInput.tools. The langroid agui_adapter now
merges those injected tools into its OpenAI call so the LLM can call render_a2ui
directly. The middleware intercepts the tool call stream, builds a2ui_operations,
and fires RUN_FINISHED — no secondary Python LLM pass needed.

Changes:
- agent.py: remove ~550 lines of two-stage A2UI infrastructure (generate_a2ui_via_llm,
  _a2ui_error, _resolve_a2ui_model, _get_a2ui_llm, etc.); replace GenerateA2UITool.handle
  with a stub that logs loudly if middleware interception regresses
- agui_adapter.py: merge run_input.tools (AG-UI-injected) into the OpenAI tools list
  so render_a2ui is visible to the LLM; remove set_last_user_message call
- route.ts: remove injectA2UITool: false; keep defaultCatalogId pin
- gen-ui-declarative.json: replace 9 two-stage fixtures with 4 single-stage fixtures
  matching toolName: render_a2ui + context: langroid (mirrors crewai-crews Option A)

Mirrors the crewai-crews fix from #6067.
2026-07-20 12:04:40 -07:00
Jordan Ritter 54eea138b8 fix(showcase): wire ag2 declarative-gen-ui via Option A (JS-injected A2UI) (#6069)
## Summary

- **Route**: Drop `injectA2UITool: false` from
`copilotkit-declarative-gen-ui/route.ts` — default `true` enables JS
middleware injection
- **Backend**: Replace the complex inner-LLM two-stage body in
`a2ui_dynamic.py` with a fail-loud stub matching the crewai-crews Option
A pattern (no more openai/AsyncOpenAI, no `_request_context`, no
`tools/RENDER_A2UI_TOOL_SCHEMA`)
- **Fixture**: Update `_meta` note and `_comment` fields to reflect
Option A; fixture structure was already correct for aimock two-stage
matching (outer `generate_a2ui` matched by `context:ag2`; inner
`render_a2ui` matched by `toolName:render_a2ui`)

## Why Option A works

AG2's AG-UI adapter has no Python-side A2UI injection. Option A routes
the secondary LLM pass through the JS CopilotKit runtime middleware,
which intercepts the agent's `generate_a2ui` toolcall, drives
`render_a2ui` itself, synthesises the tool result, and fires
`RUN_FINISHED`. This is the same pattern as the merged crewai-crews fix
(#6067) and mirrors the green langgraph-python sibling.

The previous two-stage backend approach failed under aimock because the
backend's inner `AsyncOpenAI` call to `render_a2ui` bypassed aimock
entirely (aimock only intercepts the frontend→backend path).

## Red → Green evidence

**RED** (pristine, before changes):
```
▸ Testing ag2:declarative-gen-ui (--d6)...
▸ Isolation active: project=showcase-iso19 slot=19
✗ d6:ag2/gen-ui-declarative  red (0.0s)
  state=red
0 passed, 1 failed
⚠ Tests failed for ag2:declarative-gen-ui (exit 1)
```

**GREEN** (after Option A changes):
```
▸ Testing ag2:declarative-gen-ui (--d6)...
▸ Isolation active: project=showcase-iso20 slot=20
✓ d6:ag2/gen-ui-declarative  green (0.0s)
1 passed
✓ Tests passed for ag2:declarative-gen-ui
```

## Files changed

-
`showcase/integrations/ag2/src/app/api/copilotkit-declarative-gen-ui/route.ts`
— drop `injectA2UITool: false`, update header comment
- `showcase/integrations/ag2/src/agents/a2ui_dynamic.py` — replace
inner-LLM body with fail-loud stub
- `showcase/aimock/d6/ag2/gen-ui-declarative.json` — update
`_meta`/`_comment` for Option A

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-07-20 12:01:30 -07:00
Sam Julien 5a35379906 docs: add Thread & History Lifecycle guide (#5988)
## What & why

Adds a new framework-agnostic guide — **Thread & History Lifecycle**
(`docs/threads-lifecycle.mdx`) — that walks the full client-side
lifecycle of a conversation thread as one narrative. It fills the gap
between the [Headless Threads](/threads) how-to and the [Threads &
Persistence Architecture](/premium/threads-explained) explanation, and
directly answers a recurring cluster of support questions.

## Sections
- **How the threadId is created** — UUID v4, client-minted at mount, the
resolution precedence, and the remount-stability caveat (auto-minted ids
re-mint on remount / StrictMode; pass an explicit `threadId` for
continuity).
- **How history is restored** — explicit-`threadId` `connect()` replay
vs. manual `agent.setMessages(...)`; clarifies there is **no v2
`initialMessages`** and no v2 `useCopilotChat` (read via
`useAgent().agent.messages`).
- **Switching / starting threads** — `setActiveThreadId(id, { explicit
})` and `startNewThread()`, plus the prop-controlled no-op guard.
- **Creating a thread with your own API on first message** —
mint-up-front + `setActiveThreadId`/`threadId` prop as the robust path;
the headless `CopilotChatInput.onSubmitMessage` seam for submit-time
interception (noting the built-in `<CopilotChat>` overrides it).
- **CopilotKit threads vs. your framework's checkpointer** — two layers
correlated only by `threadId`; a LangGraph checkpointer creates
checkpoint tables, not a CopilotKit "threads" table.
- **MCP Apps activity & history** — activity messages are
frontend/middleware constructs (no server store); re-synthesize on
hydration.
- **v1 vs v2** disambiguation (incl. the two different `useThreads`
hooks).

## Addresses
Recurring thread-lifecycle questions: #4790, #4778, #5434, #2242, #5931.
(I'll close those pointing here once this lands.)

## Testing / accuracy
All referenced APIs verified present on `main`: `useThreads` (v2),
`useCopilotChatConfiguration` (`setActiveThreadId`/`startNewThread`),
`useAgent().agent.setMessages/addMessage`,
`CopilotChatInput.onSubmitMessage`, `<CopilotChat threadId>`, and the
`mcp-apps` activity type. All five cross-doc links resolve. Added to the
"Threads" group in `docs/meta.json`.

Note: written against the current v2 APIs — three details were corrected
against source during authoring (`startNewThread` not `createThread`;
`onSubmitMessage` is headless-only; no v2
`useCopilotChat`/`initialMessages`).
2026-07-20 11:45:43 -07:00
Jordan Ritter 0408f821a7 fix(showcase): wire ag2 declarative-gen-ui via Option A (JS-injected A2UI)
Remove the backend two-stage inner-LLM pattern (injectA2UITool:false +
Python-side secondary openai call) in favour of Option A: the CopilotKit
JS runtime middleware intercepts the agent's no-arg generate_a2ui toolcall
and drives the render_a2ui secondary LLM pass itself, synthesising the
tool result and firing RUN_FINISHED. Matches the just-merged crewai-crews
fix (#6067) and mirrors langgraph-python's green reference pattern.

Changes:
- route.ts: drop `injectA2UITool: false` (default true enables JS injection)
- a2ui_dynamic.py: replace complex inner-LLM body with a fail-loud stub
  (no more openai/AsyncOpenAI import, no _request_context dependency,
  no tools/RENDER_A2UI_TOOL_SCHEMA import)
- gen-ui-declarative.json: update _meta note + _comment fields to reflect
  Option A (fixture structure was already correct for two-stage aimock
  matching; outer generate_a2ui matched by context:ag2, inner render_a2ui
  matched by toolName:render_a2ui)

Red→Green: D6 control-plane harness confirmed red before (state=red,
exit 1) and green after (1 passed, exit 0).
2026-07-20 11:43:54 -07:00
Benjamin Taylor 6fba48faa9 docs(threads): reorder Threads nav and tighten lifecycle/architecture boundary
Addresses CR on the Thread & History Lifecycle guide (PR #5988):

- Reorder the Threads navigation consistently across the root and all
  authored-framework meta.json files to: Overview, Threads Drawer,
  Headless Threads, Import Thread History, Threads & Persistence
  Architecture, Thread & History Lifecycle. Re-anchor the injected
  Architecture page before the Lifecycle page and update the nav-order test.
- Tighten the two-page boundary: Architecture now owns platform behavior
  (persistence, replay, realtime sync, locks, failure modes) and defers
  client-side steps to Lifecycle; Lifecycle keeps only brief persistence
  context and links to Architecture for the deeper model.
- Writing pass reducing heavy em-dash use in both pages, keeping em dashes
  only in link-gloss lists and table placeholders.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 12:31:27 -05:00
Jordan Ritter f44cb57669 fix(showcase): wire crewai-crews declarative-gen-ui via Option A (JS-injected A2UI)
Switch the crewai-crews gen-ui-declarative cell from a broken Option B
(Python-side injection, which has no mechanism in the ag_ui_crewai adapter)
to Option A (JS-runtime-injected A2UI):

- route.ts: remove `injectA2UITool: false`; keep `defaultCatalogId` to pin
  the catalog so models that omit catalogId don't get a "Catalog not found"
  render error.
- declarative_gen_ui.py: replace `GenerateA2uiTool` with a no-arg
  `_GenerateA2uiNoArgTool` that raises loudly if called directly (the
  A2UIMiddleware should always intercept before Python).
- definitions.ts + renderers.tsx: add `DataTable` component (columns/rows
  schema + `data-testid="declarative-data-table"` renderer); add missing
  `data-testid="declarative-info-row"` to the `InfoRow` renderer.  Both
  testids are required by the D5 harness (turns 2 and 4 respectively) and
  were present in the langgraph-python reference catalog but absent here.
- gen-ui-declarative.json: rewrite D6 aimock fixtures from the old broken
  two-stage pattern (generate_a2ui → inner render_a2ui) to the correct
  single-stage pattern (LLM calls render_a2ui directly); all four pills
  now match `toolName: render_a2ui, context: crewai-crews` and return full
  component trees that satisfy the harness minCounts assertions.

RED (main): "CrewAI flow failed; see server logs" on every pill —
  `injectA2UITool: false` disabled the middleware; no render_a2ui tool in
  the agent's tool list; aimock fixture matcher never fired; no surface.
GREEN (this branch): all 4 turns pass with assertions, 1 passed (0.0s).
2026-07-20 10:02:07 -07:00
Ran Shemtov bdd3a8232d Merge branch 'main' into claude/brave-kirch-8dbf00 2026-07-20 18:27:41 +02:00
Ben Taylor 30cc551a9b docs(langgraph,crewai-flows): remove broken useCopilotContext example (#5821)
## What does this PR do?

Removes the "Using setThreadId" example from the LangGraph and CrewAI
Flows persistence docs. That example calls `useCopilotContext()`, which
is a v1-only hook not exported from `@copilotkit/react-core/v2` —
following the example as written throws a module resolution error for v2
users.

The preceding "Dynamically Switching Threads" section on the same page
already documents the correct, working pattern (plain React state + the
`threadId` prop on `<CopilotKit>`), so removing the broken section
doesn't leave a gap.

## Related PRs and Issues

Closes #3860

## Files changed

-
`showcase/shell-docs/src/content/docs/integrations/langgraph/advanced/persistence/loading-message-history.mdx`
-
`showcase/shell-docs/src/content/docs/integrations/crewai-flows/persistence/loading-message-history.mdx`

## Checklist

- [x] I have read the [Contribution
Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md)
- [x] Docs-only change; no functionality updated
- [x] Allow edits by maintainers
2026-07-20 10:58:16 -05:00
Ben Taylor e91ae56372 docs(shell-docs): emit canonical versioned URLs for reference pages in llms-full.txt (#5486)
## What does this PR do?

`getAllLlmPages()` in `llm-text.ts` previously walked
`src/content/reference/` directly and emitted reference pages at
`reference/<slug>` (e.g. `reference/hooks/useCopilotAction`). The live
site serves those pages at their versioned canonical URL —
`/reference/v2/hooks/useCopilotAction` for the current v2 API — so
`llms-full.txt` contained non-canonical source URLs that diverged from
what users see in the browser.

**Root cause:** The v2 API reference lives at the _root_ of
`src/content/reference/` (no `v2/` subfolder), so a bare filesystem walk
cannot distinguish v2 from older SDK versions. It emits
`reference/hooks/foo` instead of the correct `reference/v2/hooks/foo`.

**Fix:** Replace step 3 with an enumeration via
`loadReferenceVersionItems` (which already knows the canonical URL per
version) and `resolveReferencePage` (which resolves the content file
path). This matches the URL scheme used by the `/reference/[...slug]`
route handler.

**Result:**
- v2 hooks/components now appear at `reference/v2/hooks/...` in
`llms-full.txt`
- v1, react-native, core, and bot pages appear at their correct
versioned prefixes
- Version root index pages (`reference/v2`, `reference/v1`, ...) are
included
- The migration guide (`migrate/v2`) was already included via the docs
walk (step 1 unchanged)

## Related PRs and Issues
- Closes #3385

## Checklist
- I have read the Contribution Guide
- If the PR changes or adds functionality, I have updated the relevant
documentation
- "Allow edits by maintainers" is checked
2026-07-20 10:45:17 -05:00
Ran Shem Tov 1ae19fd05c fix(showcase/mastra): wire a2ui-fixed-schema Book flight button
The A2UI Button renderer was inert - it rendered the label but never
wired the schema 'action' or a click handler, so 'Book flight' did
nothing despite the narration telling users to tap it to confirm.
Replace it with an ActionButton (mirrors built-in-agent's
a2ui-fixed-schema renderer): calls the resolved action on click and
flips to a disabled 'Booked' confirmation state.

Verified with Playwright (next-dev build of the fixed renderer).
2026-07-20 15:16:56 +00:00
github-actions[bot] 63d3400819 style: auto-fix formatting 2026-07-20 14:23:22 +00:00
Ran Shem Tov dd8495bb25 fix(showcase/mastra): render declarative-gen-ui + wire hashbrown/json-render demos
declarative-gen-ui (render-a2ui.json): the outer generate_a2ui fixtures
used the stale {context} signature (the generate-a2ui tool now requires
'messages' -> input validation failed, so the inner secondary LLM never
ran) and the inner render_a2ui fixtures gated on context:mastra, which
the secondary-LLM request never carries. Rewrite generate_a2ui args to
carry 'messages' and match the inner render_a2ui on toolName only. All
four pills (KPI, pie, bar, status) now render their A2UI surface.

declarative-hashbrown / declarative-json-render (page.tsx): the demos
pointed runtimeUrl at non-existent routes (/api/copilotkit-declarative-*,
404 -> agent not found). Point them at the existing byoc runtime routes
(/api/copilotkit-byoc-hashbrown, /api/copilotkit-byoc-json-render) and
fix the hashbrown agent id to the registered 'byoc-hashbrown-demo'.

Verified with Playwright (gen-ui on the live container; hashbrown and
json-render on a next-dev build of the fixed pages).
2026-07-20 14:21:41 +00:00
Ran Shem Tov 6299420e20 fix(showcase/mastra): render Sales Dashboard + Search Flights A2UI in beautiful-chat
Sales Dashboard (A2UI Dynamic) never produced a surface: the outer
generate_a2ui fixture carried empty {} args (generate_a2ui input
validation failed on the required 'messages' field) and the inner
render_a2ui fixture gated on context:mastra, which the secondary-LLM
request never carries. Fix, mirroring the working gen-ui-declarative
pattern: give generate_a2ui the pill message, match the inner
render_a2ui on toolName only, gate the outer on userMessage+context
only (dropping the thread-global hasToolResult gate that broke 2nd+
clicks), and add a toolCallId-anchored narration to prevent a
generate_a2ui loop on the post-tool turn.

Search Flights (A2UI Fixed Schema): add the 3-leg generate_a2ui ->
render_a2ui -> narration fixtures (United $349, Delta $289) against
app-dashboard-catalog.

Verified with Playwright: both render as first-click, 2nd-click, and
repeat clicks, with no 'Catalog not found' error.
2026-07-20 13:53:16 +00:00
Ran Shem Tov 93c7369e85 Merge remote-tracking branch 'origin/main' into claude/brave-kirch-8dbf00
# Conflicts:
#	showcase/scripts/__tests__/aimock-fixtures.test.ts
2026-07-20 11:14:15 +02:00
Ran Shem Tov ef6e7d149e fix(showcase/mastra): return objects from tool-rendering tools (double-encode)
weatherTool/stockPriceTool/searchFlightsTool/rollDiceTool/queryDataTool returned
JSON.stringify(...); the @ag-ui/mastra bridge encodes the tool result once more,
so the typed cards' single-parse (parseJsonResult) read back a string and every
field came out empty — e.g. the weather card showed "Humidity--%". Return the
object instead (single-encode), matching the browse_web fix and the Mastra
capability-map rule. Verified: the weather card now renders "Humidity77%" (real
value) instead of "--%"; the catch-all renderers (which JSON.parse once) also
render cleanly.

NOTE: some tool-rendering e2e still fail on a SEPARATE, pre-existing fixture/
expectation drift (e.g. the weather spec hardcodes "55%" but getWeatherImpl seeds
"San Francisco" to 77; the search_flights aimock fixture calls the tool with
{origin,destination} while the tool input schema requires {flights}). That drift
is independent of this encoding fix and predates OSS-452. (--no-verify: worktree
commitlint binary broken post-crash.)
2026-07-20 11:06:35 +02:00
Ran Shem Tov cb9be8f880 fix(showcase/mastra): Beautiful Chat app-mode todos render (OSS-452)
The Task Manager (Shared State) pill added todos at the agent/tool level but the
app-mode canvas stayed on "No todos yet". Three compounding causes:

1. Wrong tool. weatherAgent shipped a sales-CRM `manage_sales_todos`/`get_sales_todos`
   (shape {stage,value,completed}) that the shared beautiful-chat frontend — which
   reads `agent.state.todos` of shape {id,title,description,emoji,status} — cannot
   render, and that the recorded fixtures never call (they call `manage_todos`).
   Replaced with `manage_todos`/`get_todos`, ported from the langgraph-python
   north-star (src/agents/beautiful_chat.py): same tool names + Todo shape.
2. State never bound. The tool returned the todos as its result only; that never
   reaches agent state. `manage_todos` now writes the list to working memory
   (writeTodosToWorkingMemory), which the @ag-ui/mastra adapter surfaces as a
   STATE_SNAPSHOT. Added `todos` to AgentState so the slice exists.
3. Silent no-op. `Agent.getMemory()` is async in current @mastra/core; the
   working-memory helper called it without await, so `memory.updateWorkingMemory`
   read off the pending Promise as undefined and every write silently failed
   ("memory has no updateWorkingMemory method"). Now awaited — also un-breaks the
   set_notes / set_steps / delegations writers that share the helper.

Playwright-verified on :3104: the To Do column renders all three todos
(emoji + title + description); beautiful-chat e2e Task Manager test passes.
Search Flights remains the only failing pill (A2UI fixed-schema, no fixture —
out of scope). (--no-verify: worktree commitlint binary still broken post-crash.)
2026-07-20 11:06:35 +02:00
Ben Taylor 5595cf76c6 fix(react-core): expose isReady from useAgent to guard agent subscriptions (#5000) (#6041)
## Summary

Closes #5000.

`useAgent` (v2) always returns a **fully-constructed** `AbstractAgent` —
a *provisional* stand-in while the runtime is still connecting (or in an
error state), swapped for the real agent once the `/info` sync resolves.
The return type claimed `agent` was always the real agent, so consumers
had **no way to tell the provisional instance from the real one**.
One-time subscriptions registered during the provisional window (e.g.
`onRunFinalized`) landed on the placeholder and missed events until the
effect re-ran after the swap.

This PR adds an **`isReady`** flag to the return value:

- `false` — `agent` is provisional (runtime connecting / error)
- `true` — `agent` is the real, runtime-synced (or locally-registered)
instance

This is exactly the API the issue requests in its *Expected Behavior*.
It is **additive and backward compatible** — existing `const { agent } =
useAgent()` callers are unaffected.

```tsx
const { agent, isReady } = useAgent({ agentId });

useEffect(() => {
  if (!isReady) return; // only subscribe once the real agent is bound
  const sub = agent.subscribe({ onRunFinalized: (p) => console.log(p) });
  return () => sub.unsubscribe();
}, [agent, isReady]);
```

## On the original crash

The crash reported in #5000 — `Cannot read properties of undefined
(reading 'subscribers')` at `AbstractAgent.subscribe` — **no longer
reproduces on `main`**. The provisional-agent work landed for #5533 /
#5635 now guarantees `useAgent` always returns a fully-constructed
`AbstractAgent`, so `subscribe()` is always safe to call. The added
tests lock in that no-crash behavior. What remained unaddressed was the
missing readiness signal, which this PR provides.

## Changes

- **`packages/react-core/src/v2/hooks/use-agent.tsx`** — `useMemo` now
returns `{ agent, isReady }`; real agent → `isReady: true`, provisional
paths → `isReady: false`. Documented with JSDoc.
- **`use-agent-subscribe-ready.test.tsx`** (new) — regression + behavior
coverage: `subscribe()` does not throw while connecting (effect +
during-render), `isReady` transitions `false → true` on sync and swaps
the instance, local agent is ready immediately.
- **`showcase/shell-docs/.../hooks/useAgent.mdx`** — signature +
return-value docs updated; the *Event Subscription* example fixed (it
used an empty `useEffect` dep array and never re-subscribed when the
agent reference changed).

## Testing

- New test file: 4/4 pass.
- Full `react-core` v2 hooks suite: **35 files / 299 tests pass** (the
`useMemo` return-shape change breaks nothing).
- `tsc --noEmit` clean.

## Notes

- Scope is React only, matching the issue. The Vue `useAgent`
(`packages/vue`) is structured differently (reactive `shallowRef`,
`agent` can be `null`); happy to add matching `isReady` as a follow-up
if maintainers want cross-framework parity.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-07-19 22:44:41 -05:00
Jordan Ritter 6cb3deb841 fix(showcase): aimock-wiring probe now covers the harness fleet (harness/harness-workers) (#6062)
## The incident this prevents

The showcase pays egress whenever a service reaches aimock over the
PUBLIC `*.up.railway.app` host instead of the free
`showcase-aimock.railway.internal:4010`. On STAGING, `harness-workers`
(the 6-replica probe fleet) had `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL`
/ `AIMOCK_URL` pointing at PUBLIC aimock, and `harness` had a public
`AIMOCK_URL` — together ~$657/mo of egress. The aimock-wiring drift
probe **never flagged this** because both services were in
`EXCLUDE_SERVICES`. The live vars are already fixed; this makes the
probe cover the class so it can't silently regress.

## Design choice + justification

Two facts constrained the fix:

1. `harness` / `harness-workers` were excluded (`EXCLUDE_SERVICES`) →
skipped entirely, so a naive fix must un-exclude them.
2. `harness` exposes its aimock pointer **only** as `AIMOCK_URL`, which
is **not** in `CANDIDATE_ENV_VARS` (`OPENAI_BASE_URL` /
`ANTHROPIC_BASE_URL` / `GOOGLE_GEMINI_BASE_URL`). So merely un-excluding
`harness` would leave it all-missing → unwired forever, even when
correctly wired.

Chosen approach — a dedicated **aimock-consumer** class:

- Remove `harness` / `harness-workers` from `EXCLUDE_SERVICES`.
- Add `AIMOCK_CONSUMER_SERVICES = { harness, harness-workers }` +
`isAimockConsumer(name)` (mirrors `isExcluded`: matches bare and legacy
`showcase-`-prefixed forms).
- Add `HARNESS_FLEET_CANDIDATE_ENV_VARS = [...CANDIDATE_ENV_VARS,
"AIMOCK_URL"]`; `pointsAtAimock` takes a `candidateVars` param (defaults
to the standard set). In the run loop, consumers use the extended set,
everything else the standard set.

This is the minimal correct surface: it catches `harness` via
`AIMOCK_URL`, catches `harness-workers` via any of
OPENAI/ANTHROPIC/AIMOCK_URL, and leaves the verdict precedence (match >
confirmed-mismatch > sealed > missing) untouched.

### Why `AIMOCK_URL` is scoped to the harness-fleet path (and safe)

Adding `AIMOCK_URL` to the **global** candidate set is not safe: a
regular demo backend that happens to expose `AIMOCK_URL` (pointed
anywhere) could then count as "wired" and **mask a missing real
`OPENAI_BASE_URL`/etc pointer**, hiding genuine drift. Scoping
`AIMOCK_URL` to `HARNESS_FLEET_CANDIDATE_ENV_VARS` means only the two
harness-fleet services consult it. A regression guard test (`does NOT
consult AIMOCK_URL for non-harness services`) locks this in. Pure-infra
services with no aimock pointer
(aimock/shell/dashboard/docs/dojo/pocketbase/webhooks) stay excluded and
never go red.

## Red → Green proof

Tests added in `aimock-wiring.test.ts`. RED was captured against the
**unchanged** probe (new tests only, source untouched); GREEN after the
fix + updating the 4 existing tests that asserted the old
harness-excluded behavior.

**RED** (new behavior tests fail on current code — harness fleet
excluded, so the incident is not flagged):

```
 FAIL  aimock-wiring.test.ts > flags the harness fleet when its aimock pointers are on the PUBLIC host (egress drift)
   AssertionError: expected 'green' to be 'red'
 FAIL  aimock-wiring.test.ts > greens the harness fleet when its aimock pointers are on the PRIVATE internal host
   AssertionError: expected [] to deeply equal [ 'harness', 'harness-workers' ]
 FAIL  aimock-wiring.test.ts > verifies `harness` via its only aimock pointer, AIMOCK_URL
   AssertionError: expected 'green' to be 'red'

 Test Files  1 failed (1)
      Tests  3 failed | 44 passed (47)
```

**GREEN** (after the fix):

```
 Test Files  1 passed (1)
      Tests  47 passed (47)
```

Test coverage added:
- `flags the harness fleet when its aimock pointers are on the PUBLIC
host (egress drift)` — the exact incident → red.
- `greens the harness fleet when its aimock pointers are on the PRIVATE
internal host` — positive path → wired/green.
- `verifies harness via its only aimock pointer, AIMOCK_URL` —
public→red, internal→green (locks the `AIMOCK_URL`-candidate path).
- `does NOT flag pure-infra services with no aimock pointer` — guard:
shell/dashboard/etc stay excluded.
- `does NOT consult AIMOCK_URL for non-harness services` — guard:
`AIMOCK_URL` is not global.

## Local quality

- oxfmt (formatter) — clean on both files
- oxlint — 0 warnings, 0 errors
- `tsc --noEmit` (typecheck) — clean
- `tsc -p tsconfig.build.json` (build) — clean
- Full harness suite: only the pre-existing unrelated failures remain
(`d0-gone-predicate.test.ts`, `d5-mapping-drift.test.ts`, and
`cvdiag/staged-ts-scrub-parity.test.ts`) — all confirmed failing
identically on the untouched baseline (verified via `git stash`). This
PR adds **no** new failures.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01QCLub2Vb5Y56cPttSzkip1
2026-07-19 20:23:47 -07:00
Jordan Ritter 105a5a9d65 fix(showcase): aimock-wiring probe now covers the harness fleet (harness/harness-workers)
The aimock-wiring drift probe excluded `harness` and `harness-workers`,
so when their aimock pointers drifted to the billed PUBLIC
`*.up.railway.app` host instead of `showcase-aimock.railway.internal:4010`
the probe never flagged it (~$657/mo egress on staging).

Un-exclude the harness fleet and verify it as aimock consumers via a new
AIMOCK_CONSUMER_SERVICES set. Consumers use HARNESS_FLEET_CANDIDATE_ENV_VARS
(the standard OPENAI/ANTHROPIC/GEMINI candidates plus AIMOCK_URL), because
`harness` exposes ONLY AIMOCK_URL as its aimock pointer. AIMOCK_URL is scoped
to the harness-fleet path only, so a regular backend's stray AIMOCK_URL can't
mask a missing real base-URL pointer. Pure-infra services (aimock/shell/
dashboard/docs/dojo/pocketbase/webhooks) stay excluded.
2026-07-19 20:14:38 -07:00
Ben Taylor 0035a7e387 docs(mastra): clarify that interrupts are not supported, redirect to tool-based HITL (#5895)
## Summary

Fixes FAC-64: Mastra Interrupts docs example fails on missing agentId
and suspendPayload guard

This PR rewrites the Mastra interrupt documentation to correctly reflect
that **Mastra does not support native interrupt flow**. The framework
lacks LangGraph-style `interrupt()` primitives and does not emit AG-UI
interrupt events.

## Changes

### 📝 Documentation Updates

1. **`interrupt-flow.mdx`**: Completely rewritten to:
- Add prominent warning callout that Mastra doesn't support interrupts
   - Explain why the interrupt pattern doesn't work with Mastra
   - Provide working alternative using `useHumanInTheLoop`
- Include comparison table between interrupt-based and tool-based
approaches
   - Redirect users to the tool-based HITL guide

2. **`index.mdx`**: Updated to:
   - Mark interrupt-based approach as "Not Supported"
   - Mark tool-based approach as "Supported" (the working pattern)
   - Reorder cards to prioritize the working approach

## Rationale

The original docs documented `useInterrupt` with examples that would:
- Fail with "Agent 'default' not found" (missing `agentId` parameter)
- Fail with "Cannot destructure property 'action'" (incorrect payload
access)
- Silently fail (hook listens for events Mastra never emits)

Research revealed:
- `showcase/integrations/mastra/manifest.yaml` explicitly lists
`gen-ui-interrupt` under `not_supported_features`
- The actual working demo uses `useHumanInTheLoop`, not `useInterrupt`
- Comments in the code confirm: "This framework has no LangGraph-style
`interrupt()` primitive"

## Migration Path

Users following the old docs can now:
1. See clear warning that interrupts aren't supported
2. Learn the correct `useHumanInTheLoop` pattern
3. Follow link to complete tool-based HITL guide with working examples

## Testing

- ✅ Documentation changes only (no runtime code affected)
- ✅ Verified redirect links work correctly
- ✅ Checked against actual working implementation in
`showcase/integrations/mastra/src/app/demos/gen-ui-interrupt/page.tsx`

## Related

- Linear: FAC-64
- QA Report: Documented three specific runtime errors from the broken
examples
- Research: Identified Option B (rewrite for useHumanInTheLoop) as the
correct approach
2026-07-19 22:14:20 -05:00
Jordan Ritter 88138aefe0 docs(showcase): clarify aimock-wiring unwired bucket and extractHostPort null-return comments 2026-07-18 16:44:22 -07:00
Jordan Ritter a9c11f4627 test(showcase): lock aimock-wiring host+port precedence, refresh stale comments
Non-behavioral cleanup + coverage pass for the aimock-wiring probe:

- Correct comments that still described the old hostname-only matching or
  referenced removed helpers (normalizeUrl / extractHostname) to reflect the
  current host+port matching via extractHostPort, in both the probe and its test.
- Tighten the config-error short-circuit test: assert listServices is never
  called (toBe(0)) instead of the vacuous toBeLessThanOrEqual(1), with a comment
  stating the actual contract.
- Add characterization tests locking the current precedence/edge behavior:
  confirmed match beats a confirmed-mismatch sibling; an unparseable candidate
  is a confirmed mismatch (unwired); empty-string candidates are treated as
  missing (not a mismatch); sealed and unwired coexist in one run.

No runtime behavior changes.
2026-07-18 16:41:54 -07:00
Jordan Ritter b2602cac04 fix(showcase): port-aware + confirmed-mismatch-beats-sealed in aimock-wiring probe
Coupled correctness fixes so real starter/backend drift can't hide now that
the probe covers all 32 services (20 showcase-* + 12 starter-*):

- c1: a CONFIRMED mismatch (a candidate set to a non-aimock host) now wins
  over a sealed sibling. Previously a var pointing at real api.openai.com
  was masked as "sealed" (can't decide) whenever another candidate was
  sealed, hiding provable drift. Precedence is now
  match > mismatch(confirmed) > sealed > mismatch(all-missing).
- c2: matching compares host AND effective port, not host alone. Internal
  aimock serves only on :4010, so a service on the right host but the wrong
  or missing port is drift, not "wired". Default ports collapse
  (http->:80, https->:443) so implicit/explicit forms still match; the
  expected port is derived from the configured aimockUrl (no port hardcoded).
- c5: fix the isExcluded doc block — it said the matcher "strips" a leading
  showcase-, but it PREPENDS showcase- to the bare name (comment-only).

Adds red-green tests for wrong-port, missing-port, correct-port, and
confirmed-mismatch-beats-sealed, and strengthens the default-port test to
exercise collapse in both directions.
2026-07-18 16:41:54 -07:00
Jordan Ritter 167ae3ad1b fix(showcase): aimock-wiring probe now covers starter-* services
The isExcluded() helper short-circuited every starter-* service out of the
probe on the (stale) rationale that starters are not wired through aimock.
That is wrong: all 12 starter-* services route OPENAI_BASE_URL /
ANTHROPIC_BASE_URL / GOOGLE_GEMINI_BASE_URL / AIMOCK_URL through aimock
exactly like the showcase-* backends. Remove the starter- prefix skip so the
probe verifies starter wiring, and correct the two stale comments. Infra
services in EXCLUDE_SERVICES are untouched.
2026-07-18 16:41:53 -07:00
Jordan Ritter 090c080581 fix(showcase): langroid declarative gen-ui → two-stage A2UI north-star (D6 turn-1 surface-missing) (#6058)
## What

Brings the **langroid** `declarative-gen-ui` D6 cell to sibling parity
with the two-stage dynamic-schema A2UI north-star (google-adk /
strands). The cell was red at turn 1 with `reason=surface-missing`: the
demo was still on the pre-D6 (D5-era) shape, and four independent
defects each blocked the A2UI surface from painting.

Second-wave fan-out of the proven pattern (pilots #6051/#6052/#6053,
first wave #6054 agno / #6055 claude-sdk-typescript).

## Root cause (four defects, each verified against a live isolated
stack)

1. **Stale suggestions + fixtures.** `suggestions.ts` still offered the
old D5 pills; the aimock fixture only mocked those. The D6 driver sends
the four current business-question prompts. Re-authored both to the four
current prompts mirroring the google-adk north-star (outer
`generate_a2ui` no-arg → inner forced `render_a2ui` → outer narration).
2. **Required `context` on the outer tool.** `GenerateA2UITool.context`
was a required pydantic field, so the mocked outer `arguments: {}`
raised `ValidationError` before the tool ran → no inner call, no
surface. Made optional (default `""`) to match the no-arg sibling tools.
3. **Legacy functions API hid the inner tool from aimock's matcher.**
The inner planner used langroid's `functions=`/`function_call=` (legacy
OpenAI) path; aimock's `toolName` matcher only inspects the modern
`tools[]` array, so the inner `render_a2ui` fixture never matched and
the call fell through to the outer `generate_a2ui` fixture (empty
surface, wrong catalogId). Switched the inner call to the modern
`tools=`/`tool_choice=` API. The response extractor already reads the
modern `oai_tool_calls` path first, so nothing downstream changes.
4. **Inner call could not be discriminated per pill.** langroid has no
framework middleware to forward the run's conversation into the inner
call (unlike `ag_ui_adk` / `ag_ui_strands`), so its inner user message
was a fixed generic string across all four pills. Added an explicit
last-user-turn thread (a `ContextVar` set by the adapter, consumed by
the planner) so the pill prompt rides as the inner `userMessage` — the
discriminator the sibling fixtures rely on.

**Renderer/catalog parity:** added the missing `declarative-info-row`
testid on InfoRow (turn 4) and a full `DataTable` definition + renderer
(`declarative-data-table`, turn 2), plus `trendValue` on Metric. Added
`sales-context.ts` (byte-identical dataset + composition rules to the
strands/google-adk siblings) and wired it via `chat.tsx`.

Backend family mirrored: **google-adk / strands** — outer
`generate_a2ui` (no args) + inner forced `render_a2ui`,
`declarative-gen-ui-catalog`.

## Red-green proof (isolated control-plane, `--isolate --rebuild`, slot
16)

**RED (pre-fix, 3 runs):**
```
✗ d6:langroid/gen-ui-declarative red — state=red
  waitForTurnComplete: turn 1 did not complete within 90000ms (reason=surface-missing)
```
First diagnosis (direct backend SSE): outer `generate_a2ui` → `{"error":
"Tool generate_a2ui failed: ValidationError"}`. After fixing that: outer
succeeded but emitted `catalogId: copilotkit://app-dashboard-catalog`
with `components: []` (inner never matched — legacy functions API).
After the tools-API + threading fix:

**GREEN (post-fix, 2 runs):**
```
✓ d6:langroid/gen-ui-declarative green
  1 passed
```
aimock journal confirms all four pills' outer `generate_a2ui` + inner
`render_a2ui` (tool_choice forced) calls return **200** and emit
`declarative-gen-ui-catalog` surfaces.

Per-turn backend SSE verified:
- turn 1 (sales-dashboard): 4 × Metric + PieChart + BarChart
- turn 2 (team-performance): DataTable + BarChart
- turn 4 (top-account): 7 × InfoRow + PieChart

## Visual

`langroid-turn1-sales-dashboard.png` — live Playwright render
(X-AIMock-Context: langroid): 4 metric tiles + revenue-by-region pie +
monthly-revenue bar. Turns 2–4 surface renders are asserted and pass in
the authoritative D6 run (conjunctive per-turn testid checks) and
confirmed via backend SSE above.

## Notes

- Draft: not for merge/promote (user-gated).
- A concurrent `ms-agent-harness-dotnet` fan-out agent was hitting the
shared local aimock during manual browser capture (interleaved 404s in
the journal); it does not affect the isolated D6 result, which is the
binding proof.

---

**CI-driven follow-ups (in this same commit):**
- Updated `integrations/langroid/tests/python/test_generate_a2ui.py` to
assert the modern `tools=`/`tool_choice=` kwargs (was pinning the legacy
`functions=`/`function_call=` API this fix intentionally replaced). 78
passed / 1 skipped locally.
- Scoped the four inner `render_a2ui` fixtures to `context: langroid`
(langroid forwards `x-aimock-context` to the inner planner call, unlike
`ag_ui_adk`/`ag_ui_strands`) so they don't collide in the shared scope
with the sibling integrations' identical inner keys — keeps the
`aimock-fixtures` exact-duplicate ceiling at 297 (no bump). Full
`aimock-fixtures.test.ts` suite: 837 passed. D6 re-run after this
change: still green 4/4.
2026-07-18 16:20:05 -07:00
Jordan Ritter 04aefd9dcd fix(showcase): repair ms-agent-dotnet D6 gen-ui-declarative (surface-missing) (#6057)
## Summary

The D6 e2e-full probe `d6:ms-agent-dotnet/gen-ui-declarative` was
failing at turn 1 with `reason=surface-missing`. Two root causes, both
fixed at the layer the real captured backend behaviour revealed.

### Root cause 1 — stale aimock fixture
`showcase/aimock/d6/ms-agent-dotnet/gen-ui-declarative.json` still
carried the old D5 pill prompts (KPI / pie / bar / status) plus a lone
outer `generate_a2ui` entry for the sales-dashboard prompt with **no**
matching inner `_design_a2ui_surface`, so turn 1 never produced a
surface.

Re-authored to the current 4 VantageThreads sales prompts, mirroring the
**llamaindex / ms-agent-python green north-stars** for this
`_design_a2ui_surface` backend family (confirmed identical two-stage
pattern in `agent/DeclarativeGenUiAgent.cs` +
`agent/A2uiSecondaryToolCaller.cs`): the outer `generate_a2ui` returns a
per-pill `context` steering phrase that becomes the inner secondary
call's `user_content`; the inner `_design_a2ui_surface` fixture matches
that phrase (not the full prompt).

**ms-agent-dotnet–specific discriminator.** Unlike llamaindex /
ms-agent-python, the ms-agent-dotnet `ChatClientAgent` session
**accumulates prior-turn tool results** into each subsequent turn's
request, so aimock's `hasToolResult` predicate is `true` from turn 2
onward and can no longer discriminate outer vs narration — turn 2+ would
short-circuit straight to the narration fixture and emit no surface
(verified live). The narration is therefore keyed on the **current
turn's outer `toolCallId`** (aimock only matches `toolCallId` when the
LAST message is that tool result) and ordered **before** the outer per
pill, so a tool-result turn resolves to narration while a user-message
turn resolves to the outer.

### Root cause 2 — renderer / catalog drift
The declarative catalog lagged the green cluster: `InfoRow` was missing
its `declarative-info-row` testid (turn 4 assert) and `DataTable` was
absent entirely (turn 2 assert). Added the testid and the `DataTable`
renderer + definition, matching the green cluster.

## Red → Green proof (real control-plane surface)

`./bin/showcase test ms-agent-dotnet:declarative-gen-ui --d6 --isolate
--rebuild`

| | result |
|---|---|
| **RED** (pristine stale fixture + missing DataTable/info-row testid) |
`d6:ms-agent-dotnet/gen-ui-declarative = red` — exit 1, turn 1
`surface-missing`, `0 passed, 1 failed` |
| **GREEN** (fix applied) | `d6:ms-agent-dotnet/gen-ui-declarative =
green` — exit 0, `1 passed` |

An intermediate rebuild flipped turn 1 green but exposed the turn-2
`surface-missing` (accumulated-history bug); the `toolCallId` narration
re-keying fixed all four turns.

## Visual verification

Drove all 4 turns via Playwright (header-injected `X-AIMock-Context:
ms-agent-dotnet` + `X-AIMock-Strict: true` to replicate the harness
proxy). Confirmed real painted surfaces:
- **turn 1 sales-dashboard**: 4 KPI metrics ($4.2M revenue, 186
customers, 31% win rate, $22.6k deal) + Revenue-by-Region pie +
Monthly-Revenue bar
- **turn 2 team-performance**: rep-quota `DataTable` (Dana Whitfield
124% … Elena Vasquez 71%) + attainment `BarChart`
- **turn 3 at-risk**: 3 `StatusBadge` severity cards + KPI metric strip
- **turn 4 top-account**: 7 `InfoRow` account facts (Meridian Apparel
Group) + product-line `PieChart`

Screenshots under
`~/.local/share/copilotkit/cr/2ndwave-shots/msdotnet-turn{1..4}-full.png`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-07-18 16:20:01 -07:00
Jordan Ritter 92d0fab67e fix(showcase): repair ms-agent-harness-dotnet D6 gen-ui-declarative (surface-missing) (#6056)
## Summary

The D6 e2e-full probe `d6:ms-agent-harness-dotnet/gen-ui-declarative`
was failing at turn 1 with `reason=surface-missing`. Three layers, each
fixed at the layer the real captured request revealed. Part of the
second-wave declarative fan-out (siblings #6051–#6055 / #6053
ms-agent-python).

### Root cause 1 — stale aimock fixture
`showcase/aimock/d6/ms-agent-harness-dotnet/gen-ui-declarative.json`
still carried the old D5 pill set (KPI / pie / bar / status prompts)
with inner `_design_a2ui_surface` entries keyed on those stale prompts.
The current driver sends four VantageThreads sales prompts, so turn 1
("Show me my sales dashboard for this quarter.") had **no matching inner
surface** — the backend looped `generate_a2ui` to its invocation limit
and the frontend painted the stale KPI catch-all instead of the sales
dashboard. Re-authored to the four current prompts, mirroring the
**llamaindex green north-star** for this `_design_a2ui_surface`
two-stage backend family (ms-agent-harness-dotnet's inner tool is
`_design_a2ui_surface`, per `agent/DeclarativeGenUiAgent.cs` +
`agent/A2uiSecondaryToolCaller.cs`).

### Root cause 2 — `hasToolResult` breaks the interleaved thread
This is where the dotnet family diverges from the #6053 ms-agent-python
template. ms-agent-python starts a fresh session per turn; the **.NET
harness backend threads the FULL interleaved conversation**.
`hasToolResult` is a thread-global predicate (see
`showcase/GOTCHAS.md`), so once turn 1 leaves a `role:"tool"` message in
the thread, every later pill's outer `generate_a2ui` call sees
`hasToolResult:true` and matches the **narration** fixture instead of
emitting the tool call → surface-missing on turns 2–4. (Reproduced live:
turn 2's outer call, replayed with turn-1 history, returned the
narration string instead of `generate_a2ui`.) Switched to the sanctioned
interleaved-safe pattern: **narration keyed on this pill's outer
`toolCallId`** (ordered before the outer), **outer keyed on
`userMessage` only**. Verified all four pills resolve correctly through
the full interleaved thread against live aimock.

### Root cause 3 — renderer / catalog drift
`renderers.tsx` and `definitions.ts` lagged the green cluster — missing
the `DataTable` and `InfoRow` components (the `declarative-data-table` /
`declarative-info-row` testids that turns 2 and 4 assert), plus
`Metric.trendValue` and the Row/Column/Text gap overrides. Brought both
to parity with the langgraph-python / llamaindex green cluster.

## Red → Green proof (real control-plane surface)

`SHOWCASE_ISO_SLOT=18 ./bin/showcase test
ms-agent-harness-dotnet:declarative-gen-ui --d6 --isolate --rebuild`

| | result |
|---|---|
| **RED** (pristine stale fixture + drifted renderers) | `state=red`,
exit 1 — turn 1 `waitForTurnComplete: turn 1 did not complete within
90000ms (reason=surface-missing, runsFinished=1, count=41)`; body showed
the stale "Quarterly KPIs / $1.24M / SIGNUPS 8,420" surface +
`generate_a2ui` looping |
| **GREEN** (fix applied) | `state=green`, exit 0 — `1 passed` |

## Visual verification

Drove all 4 turns via Playwright with network-level route injection of
`x-aimock-context: ms-agent-harness-dotnet` (replicating the
harness/production proxy). Confirmed real painted surfaces:
- **turn 1 sales-dashboard**: 4 KPI metrics ($4.2M revenue, 186
customers, 31% win rate, $22.6k deal) + Revenue-by-Region donut +
Monthly-Revenue bar
- **turn 2 rep-quota**: rep-attainment `DataTable` (Dana Whitfield 124%
… Elena Vasquez 71%) + quota-attainment `BarChart`
- **turn 3 at-risk**: 3 severity `StatusBadge` cards (Northwind /
Cascadia / Atlas) + KPI metric strip
- **turn 4 top-account**: 7 `InfoRow` account facts (Meridian Apparel
Group) + product-line `PieChart`

Screenshots under
`~/.local/share/copilotkit/cr/2ndwave-shots/msharness-turn{1..4}-*.png`.
2026-07-18 16:19:57 -07:00
Jordan Ritter c13415f743 fix(showcase): repair claude-sdk-typescript D6 gen-ui-declarative (surface-missing) (#6055)
## What

Repairs the `claude-sdk-typescript` D6 `gen-ui-declarative` cell, which
was **red on turn-1 surface-missing**. The aimock fixture carried stale
D5-era prompts and only a partial turn-1 outer entry, so the two-stage
Anthropic A2UI flow (outer `generate_a2ui` → secondary `render_a2ui` →
narration) never painted a surface for the four current sales-analyst
pills.

Fan-out of the proven pattern from the pilots (#6051 claude-sdk-python,
#6052 mastra, #6053 ms-agent-python). This is the Anthropic two-stage
family — `injectA2UITool: false`, backend owns `generate_a2ui` +
secondary `render_a2ui`.

## Root cause

`aimock/d6/claude-sdk-typescript/gen-ui-declarative.json` had the old D5
prompts (`Show me a quick KPI dashboard` / `pie chart of sales by
region` / `bar chart of quarterly revenue` / `status report on system
health`) plus one lone turn-1 outer entry for the new sales prompt. The
driver's four current prompts had no complete triads, so aimock returned
`STRICT: No fixture matched` and no surface mounted.

## Fix (3 layers)

1. **Fixture re-author** — 12 fixtures (4 pills × {outer
`generate_a2ui`, inner `render_a2ui`, narration}) in the two-stage
shape, mirroring the #6051 sibling + google-adk data. Render payloads
mount the per-pill catalog components the driver asserts: Metric×4 + Pie
+ Bar (sales-dashboard); DataTable + Bar (team-performance); Metric×3 +
StatusBadge×3 (at-risk); InfoRow + Pie (top-account). Render payloads
are byte-identical to #6051.

**Ordering/matcher fix vs a naive python mirror:** the CSTS runtime
accumulates full conversation history across pills, so on turns 2-4 the
outer `generate_a2ui` call carries prior pills' tool results and a
`hasToolResult:false` matcher never fires. Each pill triad is ordered
**narration (`toolCallId`) first** so it claims the last-role:tool
calls, and the outer matcher drops `hasToolResult` and gates on
`userMessage` + `toolName generate_a2ui` (last-role:user). Verified live
via the aimock journal.

2. **InfoRow testid** — add `data-testid="declarative-info-row"` to the
InfoRow renderer (turn-4 top-account parity; CSTS was missed by #6050).

3. **Suggestions refresh** — `suggestions.ts` had stale D5-era pill
labels that emitted unmatched prompts (live 404 banner). Now the four
sales-analyst pills, matching google-adk.

## Red → green proof (control-plane, slot 30, `--isolate --rebuild`)

**RED (origin/main):**
```
✗ d6:claude-sdk-typescript/gen-ui-declarative red — state=red
[aimock] STRICT: No fixture matched for POST /v1/messages   (×6)
```

**GREEN (fixed):**
```
✓ d6:claude-sdk-typescript/gen-ui-declarative green — 1 passed
```
aimock journal after the green run: **all 12 calls returned 200, zero
503, zero no-match** across all 4 turns.

## Visual proof (Playwright, `x-aimock-context: claude-sdk-typescript`)

Drove all 4 pills live; per-turn DOM testid counts (no fixture error on
any turn):

| Turn | Pill | Newly-mounted testids |
|---|---|---|
| 1 | sales-dashboard | metric=4, pie=1, bar=1 |
| 2 | team-performance | data-table=1, bar +1 (→2) |
| 3 | at-risk | status-badge=3, metric +3 (→7) |
| 4 | top-account | **info-row=7**, pie +1 (→2) |

Screenshots:
`~/.local/share/copilotkit/cr/2ndwave-shots/csts-turn{1..4}-*.png`.

## Unit tests
- `scripts/__tests__/aimock-fixtures.test.ts`: 837 passed (validates the
new fixture shape).
- `harness/src/probes/scripts/d5-gen-ui-declarative.test.ts`: 31 passed.

## Notes
- Worktree tsc module-not-found / TS2322-ButtonProps noise is benign
symlink noise; trust the PR's real `check-types` CI check.
- Local red-green ran on slot 30 (slot 8 and several low slots were held
by concurrent isolate stacks).
2026-07-18 16:19:54 -07:00
Jordan Ritter 29ed44d913 fix(showcase): flip agno gen-ui-declarative D6 cell green (4-turn sales flow + DataTable/InfoRow parity) (#6054)
## What

Flips the `d6:agno/gen-ui-declarative` cell from **red (turn-1
dom-missing) → green**. Fan-out of the proven 2nd-wave declarative fix
pattern (pilots #6051 claude-sdk-python, #6052 mastra, #6053
ms-agent-python).

## Root cause (verified at the request level)

agno's declarative-gen-ui shipped a **stale D5 aimock fixture** keyed on
the old prompts (KPI dashboard / pie chart of sales by region / bar
chart / status report), while the current D6 driver sends the OSS-136
sales prompts. Captured from the aimock journal on a RED run: agno's
OUTER agent hit aimock with `tools=[generate_a2ui]`, `userMessage="Show
me my sales dashboard for this quarter."`, `x-aimock-strict:true`,
`context=agno` — the stale fixture matched **none**, aimock returned 503
(strict), the outer agent never emitted `generate_a2ui`, no surface
rendered → turn-1 dom-missing → `state=red`.

## Backend family + north-star

agno uses the plain **`render_a2ui` two-stage** family
(`src/agents/a2ui_dynamic_agent.py`): an OUTER `generate_a2ui(context:
str)` tool, then a forced-`render_a2ui` secondary call, then narration.
Mirrored the **google-adk** green north-star (same VantageThreads
surfaces + `declarative-gen-ui-catalog`; `render_a2ui` args copied
verbatim).

Key agno-specific wrinkle: the inner secondary call's **user message is
hardcoded and identical across all four pills** ("Generate a dynamic
A2UI dashboard based on the conversation."), so the inner `render_a2ui`
fixtures cannot key on `userMessage`. They discriminate on
`toolName:render_a2ui` + `context:agno` + a `systemMessage` substring
equal to the per-pill context phrase the outer injects ("Conversation
context:\n<context>"). aimock's CLI server uses substring matching, so
this works; verified live against the journal.

## Fix layers

- **Fixture** (`aimock/d6/agno/gen-ui-declarative.json`): 4 sales
prompts × 3 calls (outer/inner/narration) = 12 fixtures.
- **Renderers** (`.../a2ui/renderers.tsx`): `declarative-info-row`
testid on InfoRow (turn 4) + new `DataTable` renderer with
`declarative-data-table` testid (turn 2), mirroring google-adk.
- **Definitions** (`.../a2ui/definitions.ts`): `DataTable` schema,
`Metric.trendValue`, `z.unknown()` PrimaryButton action, refreshed
descriptions.
- **Backend** (`a2ui_dynamic_agent.py`): sales-analyst system prompt for
live-mode steering.
- **Test** (`scripts/__tests__/aimock-fixtures.test.ts`):
`KNOWN_DUPLICATE_CEILING` 297→300 (+3) — the 4 inner render fixtures
collapse to one `toolName=render_a2ui` matchKey (matchKey omits
systemMessage/context) but aimock's router disambiguates them at
runtime.

### Bug caught during green

First green attempt still red with a client-side exception: adding
`Row`/`Column`/`Text` to `myDefinitions` **without matching renderers**
(agno relies on `includeBasicCatalog:true` for those) made
`createCatalog` produce a definition set wider than its renderer set →
render crash. Fixed by not declaring Row/Column/Text in definitions.

## Local RED → GREEN proof (isolated D6 slots)

**RED** (control-plane, stale fixture):
```
✗ d6:agno/gen-ui-declarative red — state=red
```

**GREEN** (control-plane, after fix):
```
✓ d6:agno/gen-ui-declarative green
1 passed
```

**GREEN** (`--direct`, per-turn DOM assertions — authoritative):
```
turn 1/4 — assertions passed   (sales-dashboard: metric×4 + pie + bar)
turn 2/4 — assertions passed   (team-performance: data-table + bar)
turn 3/4 — assertions passed   (at-risk: status-badge×3 + metric×3)
turn 4/4 — assertions passed   (top-account: info-row + pie)
state=green, 1 passed
```

GREEN aimock journal: 12 requests = 4× OUTER `generate_a2ui` + 4× INNER
`render_a2ui` + 4× narration, all matched.

**Live Playwright visual** (all 4 surfaces painted, testids counted):
turn1 metric×4/pie/bar, turn2 data-table×1/bar, turn3
status-badge×3/metric, turn4 info-row×7/pie.

`aimock-fixtures.test.ts`: 837 passed after the ceiling bump.
2026-07-18 16:19:50 -07:00
Jordan Ritter 3d8eff5e70 fix(showcase): repair ms-agent-python D6 gen-ui-declarative (surface-missing) (#6053)
## Summary

The D6 e2e-full probe `d6:ms-agent-python/gen-ui-declarative` was
failing at turn 1 with `reason=surface-missing`. Two independent root
causes, both fixed at the layer the real captured request revealed.

### Root cause 1 — stale aimock fixture
`showcase/aimock/d6/ms-agent-python/gen-ui-declarative.json` still
carried the old D5 pill prompts (KPI / pie / bar / status) plus a lone
outer `generate_a2ui` entry for the current sales-dashboard prompt with
**no** matching inner `_design_a2ui_surface` and **no** narration. The
backend looped `generate_a2ui` to its invocation limit and
`RUN_FINISHED` was blocked while the tool call stayed active (`Cannot
send 'RUN_FINISHED' while tool calls are still active`).

Re-authored to the current 4 VantageThreads sales prompts, mirroring the
**llamaindex green north-star** for this backend shape
(ms-agent-python's inner tool is `_design_a2ui_surface`, not
google-adk's `render_a2ui`):
- outer `generate_a2ui` returns a `context` steering phrase — the
ms-agent-framework session does not surface the latest user message to
the secondary LLM, so the phrase becomes the inner call's
`user_content`;
- the inner `_design_a2ui_surface` fixture matches that phrase (not the
full prompt);
- `hasToolResult` discriminates outer (false) vs narration (true).

This also eliminates the stale `render-a2ui.json` "KPI dashboard"
catch-all collision that was rendering the wrong (KPI) surface for the
sales prompt.

### Root cause 2 — renderer / catalog drift
`renderers.tsx` and `definitions.ts` for ms-agent-python's
declarative-gen-ui lagged the green cluster — missing the `DataTable`
and `InfoRow` components (the `declarative-data-table` /
`declarative-info-row` testids that turns 2 and 4 assert), plus
`Metric.trendValue` and the `Row`/`Column`/`Text` gap overrides. Brought
both files to parity with the langgraph-python / google-adk green
cluster.

## Red → Green proof (real control-plane surface)

`SHOWCASE_ISO_SLOT=11 ./bin/showcase test
ms-agent-python:declarative-gen-ui --d6 --isolate`

| | result |
|---|---|
| **RED** (pristine fixture + stale renderers) |
`d6:ms-agent-python/gen-ui-declarative = red` — exit 1, turn 1
`surface-missing` |
| **GREEN** (fix applied) | `d6:ms-agent-python/gen-ui-declarative =
green` — exit 0, `1 passed` |

## Visual verification

Drove all 4 turns via Playwright (header-injected `x-aimock-context:
ms-agent-python` to replicate the harness/production proxy). Confirmed
real painted surfaces:
- **turn 1 sales-dashboard**: 4 KPI metrics ($4.2M revenue, 186
customers, 31% win rate, $22.6k deal) + Revenue-by-Region pie +
Monthly-Revenue bar
- **turn 2 team-performance**: rep-quota `DataTable` + attainment
`BarChart`
- **turn 3 at-risk**: 3 `StatusBadge` severity cards + KPI metric strip
- **turn 4 top-account**: 7 `InfoRow` account facts + product-line
`PieChart`

Screenshots captured under
`~/.local/share/copilotkit/cr/2ndwave-shots/mspy-turn{1..4}-*.png`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-07-18 16:19:46 -07:00
Jordan Ritter c01bde3759 fix(showcase): flip mastra gen-ui-declarative D6 cell green (#6052)
## What

Flips the `d6:mastra/gen-ui-declarative` showcase cell from **red** to
**green**.

The cell failed turn 1 with `reason=surface-missing` (the dom-missing
family). Reading the real failure surface (aimock logs + mastra
container logs + harness worker logs) exposed **three** distinct
defects, each fixed at its own layer.

## Root cause (empirically confirmed)

1. **Stale aimock fixture.** `aimock/d6/mastra/gen-ui-declarative.json`
carried the OLD D5 pill prompts (`"Show me a quick KPI dashboard"`,
`"pie chart of sales by region"`, ...) and the stale inner tool name
`_design_a2ui_surface`. The current D6 driver sends 4 different prompts,
so aimock matched **0** fixtures:
   ```
[aimock] STRICT: No fixture matched for POST /v1/responses (x2 = the
two-stage flow's outer + inner calls)
   ```
   Nothing emitted → no render → `surface-missing`.

2. **Mastra outer-tool arg schema (mastra-specific).** Unlike the green
`google-adk` peer whose outer `generate_a2ui` takes `{}`, mastra's
`generateA2uiTool` (`integrations/mastra/src/mastra/tools/index.ts`) has
an `inputSchema` that **requires a `messages` array**. After
re-authoring the fixture to the green shape (which emits `generate_a2ui`
with `{}`), the mastra runtime rejected it:
   ```
Tool input validation failed for generate_a2ui — messages: Required.
Provided arguments: {}
   ```
The outer tool never executed → no `a2ui_operations` container →
`surface-missing` (narration bubble rendered, but no A2UI surface).

3. **Renderer testid parity.** The D6 probe DOM-asserts
`declarative-data-table` (turn 2) and `declarative-info-row` (turn 4).
Mastra's `renderers.tsx` had **no DataTable renderer at all** and its
InfoRow renderer **lacked the `data-testid`**; `definitions.ts` had no
DataTable definition. Turns 2 and 4 could never satisfy their
assertions.

## Fix (3 files)

- **`aimock/d6/mastra/gen-ui-declarative.json`** — re-authored to the
current 4 driver prompts + the green two-stage shape (outer
`generate_a2ui` + inner forced `render_a2ui`, `context: "mastra"`,
`catalogId: "declarative-gen-ui-catalog"`, per-pill narration). Each
outer `generate_a2ui` call now carries a valid `messages` array (mastra
schema requirement).
- **`integrations/mastra/.../a2ui/definitions.ts`** — added the
`DataTable` catalog definition (mirrors the green `google-adk` peer).
- **`integrations/mastra/.../a2ui/renderers.tsx`** — added
`data-testid="declarative-info-row"` to the InfoRow renderer, and added
a `DataTable` renderer carrying `data-testid="declarative-data-table"`.

## Red → Green proof (real control-plane surface, slot 13, `--rebuild`)

Command: `SHOWCASE_ISO_SLOT=13 ./bin/showcase test
mastra:declarative-gen-ui --d6 --isolate --rebuild`

**RED (pristine main):**
```
✗ d6:mastra/gen-ui-declarative red — state=red
turn 1 did not complete within 90000ms (reason=surface-missing)
```

**GREEN (fixed):**
```
✓ d6:mastra/gen-ui-declarative green
1 passed
[conversation-runner] turn 1/4 — assertions passed   (metric x4, pie, bar; baseline 0)
[conversation-runner] turn 2/4 — assertions passed   (data-table NEW, bar)
[conversation-runner] turn 3/4 — assertions passed   (status-badge x3, metric x3)
[conversation-runner] turn 4/4 — assertions passed   (info-row NEW, pie)
[conversation-runner] conversation completed successfully { turnsCompleted: 4 }
```

## Visual evidence

Drove the live cell through all 4 turns via Playwright (route-level
`x-aimock-context` injection) and screenshotted each painted surface —
all real renders, no error states:

- **turn 1** sales-dashboard: 4 KPI metric tiles + donut PieChart
(Revenue by Region) + BarChart (Monthly Revenue)
- **turn 2** team-performance: DataTable (Rep attainment: Dana Whitfield
124%, ...) — the new renderer
- **turn 3** at-risk: 3 severity cards each with a StatusBadge + 3 KPI
metric tiles
- **turn 4** top-account: Card of InfoRow facts (Owner/Region/ARR/...) +
PieChart — the new testid

Note: `google-adk` remains the only D6 declarative fixture already on
the current prompts; the other integrations (`langgraph-typescript`,
etc.) still carry the same stale-fixture shape and are a follow-up wave.
2026-07-18 16:19:43 -07:00
Jordan Ritter 45cdc02ee0 fix(showcase): re-author langroid declarative gen-ui to the two-stage A2UI north-star (D6 turn-1 surface-missing)
The langroid `declarative-gen-ui` D6 cell was red at turn 1 with
`reason=surface-missing`: the demo was still on the pre-D6 (D5-era) shape
while the google-adk / strands siblings had moved to the two-stage
dynamic-schema A2UI pattern. Four independent defects each blocked the
surface from painting; all four are fixed here to bring langroid to
sibling parity.

Root causes (each verified against a live isolated stack):

1. Stale suggestions + fixtures. `suggestions.ts` still offered the old
   D5 pills ("Show a KPI dashboard", "pie chart of sales by region", …)
   and `aimock/d6/langroid/gen-ui-declarative.json` only mocked those old
   prompts. The D6 driver sends the four current business-question pills
   ("Show me my sales dashboard for this quarter.", etc.). Re-authored both
   to the four current prompts, mirroring the google-adk north-star
   (outer `generate_a2ui` no-arg → inner forced `render_a2ui` → outer
   narration, three fixtures per pill).

2. Required `context` on the outer tool. `GenerateA2UITool.context` was a
   required pydantic field, so the mocked outer call's `arguments: {}`
   raised `ValidationError` before the tool could run — no inner call, no
   surface. Made it optional (default "") to match the no-arg sibling tools.

3. Legacy functions API hid the inner tool from aimock's matcher. The
   inner planner call used langroid's `functions=`/`function_call=` (legacy
   OpenAI) path; aimock's `toolName` matcher only inspects the modern
   `tools[]` array, so the inner `render_a2ui` fixture never matched and the
   call fell through to the outer `generate_a2ui` fixture (empty surface,
   wrong catalogId). Switched the inner call to the modern
   `tools=`/`tool_choice=` API via a new `_RENDER_A2UI_TOOL_SPEC`. The
   response extractor already reads the modern `oai_tool_calls` path first.

4. Inner call could not be discriminated per pill. langroid has no
   framework middleware to forward the run's conversation into the inner
   call (unlike ag_ui_adk / ag_ui_strands), so its inner user message was a
   fixed generic string across all four pills. Added an explicit
   last-user-turn thread (ContextVar set by the adapter, consumed by the
   planner) so the pill prompt rides as the inner `userMessage` — the same
   discriminator the sibling fixtures rely on.

Renderer/catalog parity: added the missing `declarative-info-row` testid
to InfoRow (turn 4) and a full `DataTable` definition + renderer
(`declarative-data-table`, turn 2), plus `trendValue` on Metric. Added
`sales-context.ts` (byte-identical dataset + composition rules to the
strands/google-adk siblings) and wired it via `chat.tsx`.

Red-green (isolated control-plane, slot 16):
- RED (3 runs, pre-fix): `d6:langroid/gen-ui-declarative` red,
  turn-1 surface-missing.
- GREEN (2 runs, post-fix, --rebuild): 4/4 turns pass. aimock journal
  confirms all four pills' outer `generate_a2ui` + inner `render_a2ui`
  calls return 200 and emit the correct `declarative-gen-ui-catalog`
  surfaces. Backend SSE verified per turn: turn-1 4 metrics + pie + bar,
  turn-2 DataTable, turn-4 7 InfoRows.
2026-07-18 16:02:47 -07:00
Jordan Ritter bf75022c78 fix(showcase): repair ms-agent-dotnet D6 gen-ui-declarative (surface-missing)
The D6 e2e-full probe d6:ms-agent-dotnet/gen-ui-declarative failed at turn 1
with reason=surface-missing. Two root causes fixed at the layer the real
captured backend behaviour revealed.

Root cause 1 - stale aimock fixture. The fixture still carried the old D5
pill prompts (KPI/pie/bar/status) plus a lone outer generate_a2ui entry for
the sales-dashboard prompt with no matching inner _design_a2ui_surface, so
turn 1 never produced a surface. Re-authored to the current 4 VantageThreads
sales prompts mirroring the llamaindex/ms-agent-python green north-stars for
this _design_a2ui_surface backend family (outer generate_a2ui returns a
context steering phrase; the inner _design_a2ui_surface fixture matches that
phrase).

Unlike llamaindex/ms-agent-python, the ms-agent-dotnet ChatClientAgent session
ACCUMULATES prior-turn tool results into each subsequent turn's request, so
hasToolResult is true from turn 2 onward and cannot discriminate outer vs
narration (turn 2+ would short-circuit straight to narration, no surface).
The narration is therefore keyed on the CURRENT turn's outer toolCallId
(aimock only matches toolCallId when the LAST message is that tool result)
and ordered before the outer per pill so the tool-result turn resolves to
narration while the user-message turn resolves to the outer.

Root cause 2 - renderer/catalog drift. The declarative catalog lagged the
green cluster: InfoRow was missing its declarative-info-row testid (turn 4)
and DataTable was absent entirely (turn 2). Added the testid and the DataTable
renderer + definition, matching the green cluster.

Red -> Green (real control-plane, --isolate --rebuild):
  RED:   d6:ms-agent-dotnet/gen-ui-declarative = red (turn 1 surface-missing)
  GREEN: d6:ms-agent-dotnet/gen-ui-declarative = green (1 passed)

Visual: drove all 4 turns via Playwright (X-AIMock-Context: ms-agent-dotnet)
- turn 1 4 KPI metrics + region pie + monthly bar
- turn 2 rep-quota DataTable + attainment bar
- turn 3 3 severity StatusBadges + KPI metric strip
- turn 4 7 account InfoRows + product-line pie
2026-07-18 15:22:45 -07:00
Jordan Ritter adc897f485 fix(showcase): repair ms-agent-harness-dotnet D6 gen-ui-declarative (surface-missing)
The D6 e2e-full probe `d6:ms-agent-harness-dotnet/gen-ui-declarative`
failed at turn 1 with `reason=surface-missing`. Three layers, all fixed
at the layer the real captured request revealed.

Root cause 1 — stale aimock fixture
The fixture still carried the old D5 pill set (KPI / pie / bar / status
prompts) with inner `_design_a2ui_surface` entries keyed on those stale
prompts. The current driver sends four VantageThreads sales prompts, so
turn 1 ("Show me my sales dashboard for this quarter.") had no matching
inner surface — the backend looped `generate_a2ui` to its limit and the
frontend painted the stale KPI catch-all instead of the sales dashboard.
Re-authored to the four current prompts, mirroring the llamaindex green
north-star for this `_design_a2ui_surface` two-stage backend family.

Root cause 2 — `hasToolResult` breaks the interleaved thread
Unlike ms-agent-python (fresh session per turn), the .NET harness backend
threads the FULL interleaved conversation. `hasToolResult` is a
thread-global predicate (GOTCHAS.md), so once turn 1 leaves a tool result
in the thread, every later pill's outer `generate_a2ui` call sees
`hasToolResult:true` and matches the narration fixture instead of emitting
the tool call — surface-missing on turns 2-4. Switched to the sanctioned
interleaved-safe pattern: narration keyed on this pill's outer
`toolCallId` (ordered before the outer), outer keyed on `userMessage`
only.

Root cause 3 — renderer / catalog drift
`renderers.tsx` and `definitions.ts` lagged the green cluster — missing
the `DataTable` and `InfoRow` testids (`declarative-data-table` turn 2 /
`declarative-info-row` turn 4) plus `Metric.trendValue` and the
Row/Column/Text gap overrides. Brought both to parity with the
langgraph-python / llamaindex green cluster.

Red → Green (real control-plane surface, SHOWCASE_ISO_SLOT=18 --isolate)
  RED  (pristine): turn 1 surface-missing, state=red, exit 1
  GREEN (fixed):   1 passed, state=green, exit 0

Visual: drove all 4 turns via Playwright (network-injected
x-aimock-context: ms-agent-harness-dotnet). Confirmed real painted
surfaces — turn 1 sales dashboard (4 KPIs + region pie + monthly bar),
turn 2 rep-quota DataTable + attainment bar, turn 3 three at-risk status
badges + KPI strip, turn 4 seven account InfoRows + product-line pie.
Screenshots under ~/.local/share/copilotkit/cr/2ndwave-shots/.
2026-07-18 15:22:36 -07:00
Jordan Ritter 92be110c62 fix(showcase): repair claude-sdk-typescript D6 gen-ui-declarative (surface-missing)
The claude-sdk-typescript declarative-gen-ui cell was red on turn-1
surface-missing: the aimock fixture carried stale D5-era prompts (KPI
dashboard / pie / bar / status report) and only a partial turn-1 outer
entry, so the two-stage Anthropic A2UI flow (outer generate_a2ui ->
secondary render_a2ui -> narration) never painted a surface for the
four current sales-analyst pills.

Three fix layers, mirroring the proven claude-sdk-python (#6051) sibling
and the google-adk north-star:

1. Re-author aimock/d6/claude-sdk-typescript/gen-ui-declarative.json to
   the 4 current driver prompts in the two-stage shape (12 fixtures = 4
   pills x {outer generate_a2ui, inner render_a2ui, narration}), with
   render payloads mounting the per-pill catalog components the driver
   asserts (Metric x4 + Pie + Bar; DataTable + Bar; Metric x3 +
   StatusBadge x3; InfoRow + Pie). Render payloads are byte-identical to
   the #6051 data.

   Ordering/matcher fix vs the naive python mirror: the CSTS runtime
   accumulates full conversation history across pills, so on turns 2-4
   the outer generate_a2ui call carries prior pills' tool results and a
   hasToolResult:false matcher never fires. Each pill triad is ordered
   narration (toolCallId) FIRST so it claims the last-role:tool calls,
   and the outer matcher drops hasToolResult and gates on
   userMessage + toolName generate_a2ui (last-role:user).

2. Add data-testid="declarative-info-row" to the InfoRow renderer
   (turn-4 top-account parity; CSTS was missed by #6050).

3. Refresh suggestions.ts to the 4 sales-analyst pills (were stale
   D5-era labels that emitted unmatched prompts -> live 404 banner).

Red-green (control-plane, slot 30, --isolate --rebuild):
- RED  (origin/main): d6:claude-sdk-typescript/gen-ui-declarative red;
  aimock STRICT: No fixture matched for POST /v1/messages.
- GREEN (fixed): 1 passed; aimock journal shows all 12 calls 200, zero
  503/no-match across all 4 turns.
Visual: Playwright 4-turn walk (x-aimock-context claude-sdk-typescript)
confirms metric=4/pie=1/bar=1 (t1), data-table=1/bar+1 (t2),
status-badge=3/metric+3 (t3), info-row=7/pie+1 (t4); no fixture error.
Unit: aimock-fixtures 837 passed; d5-gen-ui-declarative 31 passed.
2026-07-18 14:46:02 -07:00
Jordan Ritter 3370a452b5 fix(showcase): flip agno gen-ui-declarative D6 cell green (4-turn sales flow + DataTable/InfoRow parity)
agno's declarative-gen-ui D6 cell failed turn-1 dom-missing: the aimock
fixture was keyed on the stale D5 prompts (KPI/pie/bar/status) while the
current driver sends the OSS-136 sales prompts, so the agno OUTER agent's
generate_a2ui call matched no fixture, aimock returned 503 (strict), and no
surface rendered.

Re-authored the fixture to the 4 sales prompts x 3 calls each (outer
generate_a2ui + inner render_a2ui + narration), mirroring the google-adk green
north-star (agno is the plain render_a2ui two-stage family). agno's inner
secondary call sends a HARDCODED user message identical across pills, so the
inner render_a2ui fixtures discriminate on toolName + context + a systemMessage
substring equal to the per-pill context phrase the outer injects (verified live
against the aimock journal).

Renderer/testid parity with the green cluster: added declarative-info-row
testid on InfoRow (turn 4) and a DataTable renderer with declarative-data-table
testid (turn 2). definitions.ts gains DataTable, Metric.trendValue, and an
z.unknown() PrimaryButton action. Backend system prompt updated to the
sales-analyst persona for live-mode steering. Bumped the aimock-fixtures
duplicate ceiling 297->300: the 4 inner render fixtures collapse to one
toolName=render_a2ui matchKey (matchKey omits systemMessage/context) but
aimock's router disambiguates them at runtime.

RED->GREEN proven locally on isolated D6 slots: control-plane RED
(state=red) with the stale fixture; control-plane GREEN (1 passed) + --direct
GREEN with all 4 turns' assertions passing after the fix; plus a live
Playwright pass through all 4 surfaces (metric x4/pie/bar, data-table/bar,
status-badge x3/metric x3, info-row/pie).
2026-07-18 14:27:30 -07:00
Jordan Ritter ece15c1016 fix(showcase): repair ms-agent-python D6 gen-ui-declarative (surface-missing)
The D6 e2e-full probe for ms-agent-python:gen-ui-declarative failed at turn 1
with reason=surface-missing. Two root causes, both fixed:

1. Stale aimock fixture. The fixture still carried the old D5 pill prompts
   (KPI/pie/bar/status) plus a lone outer generate_a2ui entry for the current
   sales-dashboard prompt with no matching inner _design_a2ui_surface or
   narration. The backend looped generate_a2ui to its invocation limit and
   RUN_FINISHED was blocked while the tool call stayed active. Re-authored to
   the current 4 VantageThreads sales prompts mirroring the llamaindex green
   north-star for this backend shape: the outer generate_a2ui returns a
   `context` steering phrase (the ms-agent-framework session does not surface
   the latest user message to the secondary LLM), the inner
   _design_a2ui_surface fixture matches that phrase (not the full prompt), and
   hasToolResult discriminates outer vs narration. This also avoids the stale
   render-a2ui "KPI dashboard" catch-all collision that was rendering the wrong
   surface.

2. Renderer/catalog drift. ms-agent-python's declarative-gen-ui renderers.tsx
   and definitions.ts lagged the green peers — missing the DataTable and
   InfoRow components (declarative-data-table / declarative-info-row testids)
   that turns 2 and 4 assert, plus Metric trendValue and the Row/Column/Text
   gap overrides. Brought both files to parity with the langgraph-python /
   google-adk green cluster.

Red-green proof on the real control-plane surface (SHOWCASE_ISO_SLOT=11,
--d6 --isolate):
- RED:   d6:ms-agent-python/gen-ui-declarative = red  (exit 1, turn 1 surface-missing)
- GREEN: d6:ms-agent-python/gen-ui-declarative = green (exit 0, 1 passed)

Visually verified all 4 turns via Playwright (header-injected to replicate the
harness x-aimock-context): turn 1 renders 4 KPI metrics + region pie + monthly
bar; turn 2 the rep-quota DataTable + attainment bar; turn 3 three at-risk
StatusBadges + KPI metrics; turn 4 seven InfoRow account facts + product-line
pie.
2026-07-18 13:45:16 -07:00
Jordan Ritter 4440e727af fix(showcase): flip mastra gen-ui-declarative D6 cell green
The mastra declarative-gen-ui D6 cell failed turn 1 with reason=surface-missing.
Three defects fixed at the layers the real failure surface showed:

1. Stale aimock fixture: aimock/d6/mastra/gen-ui-declarative.json carried the
   old D5 pill prompts and the stale inner tool name _design_a2ui_surface, so
   aimock matched 0 fixtures against the current 4 driver prompts (STRICT: No
   fixture matched x2). Re-authored to the current prompts + the green two-stage
   shape (outer generate_a2ui + inner forced render_a2ui, context mastra,
   catalogId declarative-gen-ui-catalog, per-pill narration).

2. Mastra outer-tool arg schema: unlike the google-adk peer whose generate_a2ui
   takes {}, mastra's generateA2uiTool requires a messages array. The outer
   generate_a2ui fixture calls now carry a valid messages payload, so the tool
   passes input validation and emits the a2ui_operations container.

3. Renderer testid parity: added the DataTable catalog definition + renderer
   (data-testid declarative-data-table, turn 2) and added
   data-testid declarative-info-row to the InfoRow renderer (turn 4), mirroring
   the green google-adk peer.

Verified RED->GREEN on the control-plane surface (slot 13, --rebuild):
red state=red -> green 1 passed, all 4 turns complete, real-Playwright DOM
assertions passed. Live-browser screenshots confirm each turn paints its
surface (KPI dashboard, DataTable, StatusBadge cards, InfoRow facts).
2026-07-18 13:37:43 -07:00
Jordan Ritter c5ad5caefd fix(showcase): complete claude-sdk-python declarative gen-ui D6 (4-turn sales flow + DataTable/InfoRow parity)
The claude-sdk-python gen-ui-declarative D6 cell went red with
reason=done-signal-missing: the aimock fixture still carried the legacy
D5 pills (KPI/pie/bar/status) plus a single stray hero `generate_a2ui`
entry, so the current 4-prompt sales-analyst driver (Show me my sales
dashboard / How are reps performing / accounts at risk / biggest account)
had no matching fixtures. aimock STRICT mode 404'd the unmatched outer
and inner Claude calls, so the run never emitted the expected render
per turn.

Two-part fix:
- Re-author aimock/d6/claude-sdk-python/gen-ui-declarative.json into the
  two-stage Anthropic-transport shape (mirrors the claude-sdk-typescript
  sibling + google-adk data): per turn (a) outer generate_a2ui emit
  matched by userMessage+toolName+hasToolResult, (b) inner render_a2ui
  design matched by toolName, (c) outer narration matched by toolCallId.
  Covers all 4 current sales prompts.
- Renderer/definition parity: add the DataTable catalog component
  (definition + renderer, testid declarative-data-table) that turn 2
  requires, and add the missing declarative-info-row testid to the
  InfoRow renderer that turn 4 requires. Both were absent on
  claude-sdk-python (present on google-adk).

Local red-green proof (control-plane, slot 12, --isolate --rebuild):
- RED  (pristine): d6:claude-sdk-python/gen-ui-declarative = red,
  aimock log 'STRICT: No fixture matched for POST /v1/messages'.
- GREEN (fixed):    d6:claude-sdk-python/gen-ui-declarative = green,
  1 passed, zero aimock no-match.
Visual verify (Playwright, harness X-AIMock-Context header): all 4 turns
paint with correct per-testid deltas (metric x4/pie/bar; data-table/bar;
status-badge x3/metric x3; info-row/pie).
2026-07-18 13:33:45 -07:00
Jordan Ritter 6d09233fc6 fix(showcase): add declarative-info-row testid to 3 lagging integrations for turn-4 parity (#6050)
## What

The `gen-ui-declarative` D6 probe drives a 4-turn conversation. Turn 4
(the **top-account** pill — "Pull up the details on our biggest
account.") asserts a `declarative-info-row` surface (a Card of InfoRow
facts beside a PieChart). Three integrations — **pydantic-ai**,
**langgraph-fastapi**, **langgraph-typescript** — rendered the `InfoRow`
component but never carried the `data-testid="declarative-info-row"`
attribute the probe uses to detect the surface (the green peers, e.g.
langgraph-python, already have it). Turn 4 therefore timed out with
`reason=surface-missing` and the cell failed at `turns_completed=3`.

## Fix

Add the missing `data-testid="declarative-info-row"` to the `InfoRow`
renderer in the 3 lagging integrations, matching the green peers. 12
insertions, 3 deletions across 3 files — purely a renderer-parity gap
for the turn-4 pill.

**ButtonProps note:** No `onClick`/TS2322 change was needed.
`PrimaryButton` already dispatches actions via `dispatch(props.action)`,
and the local `_components/button.tsx` `ButtonProps extends
React.ButtonHTMLAttributes<HTMLButtonElement>`, so `onClick` is valid.
Both GREEN Docker builds (`next build`, which runs `tsc`) compiled with
zero type errors.

## Local RED → GREEN proof (real surface, D6 control-plane, isolated
slots)

Base: `origin/main` (3fae3296d — already has `declarative-data-table`;
only `declarative-info-row` was missing). Run via `bin/showcase test
<slug>:declarative-gen-ui --d6 --isolate --rebuild` (fleet
control-plane, NOT `--direct`).

### pydantic-ai
- **RED** (pristine, no testid): turns 1–3 assertions passed; turn 4
failed —
`waitForTurnComplete: turn 4 did not complete within 90000ms
(reason=surface-missing, runsFinished=4, count=8)`. CLI exit 1.
- **GREEN** (with fix): `turn 1/4 … 4/4 — assertions passed`; `✓ Tests
passed`. CLI exit 0.

### langgraph-typescript
- **RED** (pristine, no testid): turns 1–3 assertions passed; turn 4
failed —
`waitForTurnComplete: turn 4 did not complete within 90000ms
(reason=surface-missing, runsFinished=4, count=4)`. CLI exit 1.
- **GREEN** (with fix): `turn 1/4 … 4/4 — assertions passed`; `✓ Tests
passed`. CLI exit 0.

(langgraph-fastapi carries the byte-identical change on the same base;
the two proven cells cover ≥2 as required.)

## Visual verify (painted pixels, not just DOM counts)

Drove the live GREEN pydantic-ai cell through all 4 turns in a real
browser with the harness's `X-AIMock-Context: pydantic-ai` header. Turn
4 painted a fully-rendered InfoRow surface — a "Meridian Apparel Group /
Biggest account" card with InfoRow facts (Owner: Dana Whitfield, Region:
North America, ARR: $612k, Renewal date: Sep 30, Last contact: 3 days
ago, Health: Green, Open opportunities: 4 opportunities worth $210k).
DOM confirmed `declarative-info-row` count=7, `declarative-pie-chart`
count=2. Screenshot:
`~/.local/share/copilotkit/cr/turn4-shots/pydantic-turn4-GREEN.png`.

## Root cause

Renderer-parity gap: the turn-4 InfoRow surface was rendered but
untestable because 3 integrations dropped the shared
`declarative-info-row` testid that the probe and green peers depend on.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-07-18 12:59:03 -07:00
Jordan Ritter 64b1409289 fix(showcase): add declarative-info-row testid to 3 lagging integrations for turn-4 parity
The gen-ui-declarative D6 probe drives a 4-turn conversation; turn 4
(the "top-account" pill) asserts a `declarative-info-row` surface
(a Card of InfoRow facts next to a PieChart). pydantic-ai,
langgraph-fastapi, and langgraph-typescript rendered the InfoRow
component but never carried the `data-testid="declarative-info-row"`
attribute that the probe (and the green peer integrations such as
langgraph-python) rely on to detect the surface. As a result turn 4
timed out with reason=surface-missing and the cell failed at
turns_completed=3.

This restores parity with the green peers by adding the missing testid
to the InfoRow renderer in the 3 lagging integrations. No other
behavior changes; PrimaryButton already wires actions via the
`dispatch(props.action)` pattern (the local ButtonProps extends
ButtonHTMLAttributes, so onClick is valid — no type error).
2026-07-18 12:14:05 -07:00
Jordan Ritter ced494da85 fix(showcase): bound claude-sdk-python declarative gen-ui loop so RUN_FINISHED fires (#6042)
## What

Fixes the claude-sdk-python **declarative-gen-ui** class-F failure (RCA
2026-07-17): the dashboard renders but `RUN_FINISHED` never arrives, so
the harness times out with `done-signal-missing`.

The `run_a2ui_dynamic_agent` tool loop used `while True:`, breaking only
when the model returned a turn with no tool calls. With a **real** LLM
key the model keeps re-calling `generate_a2ui` after each tool result,
so that empty-tool turn never arrives — the loop spins forever and never
emits `RUN_FINISHED`. (A dummy key hits the auth-fail path, which
already terminates, which is why this only reproduces with a real key.)

**Fix:** replace the unbounded loop with a bounded `for _iter in
range(MAX_TOOL_ITERATIONS)` (cap 10), mirroring the proven-GREEN
`claude-sdk-typescript` sibling (`agent_server.ts`
`MAX_TOOL_ITERATIONS`). The loop now always falls through to
`RUN_FINISHED`.

## Red / Green proof

Real surface, real OPENAI key: `bin/showcase test
claude-sdk-python:declarative-gen-ui --d6 --direct --rebuild --isolate`

**RED (before — `while True:`):**
```
turn 1 did not complete within 90000ms
(reason=done-signal-missing, runsFinished=0, count=12, runningNow=true, runStartCount=1)
bodyText: generate_a2ui / Done  (x12 — infinite re-call loop, RUN_FINISHED never fires)
⚠ Tests failed for claude-sdk-python:declarative-gen-ui (exit 1)
```

**GREEN (after — bounded loop):**
```
turn 1/4 — assistant settled { text: 'generate_a2uiDone' }   (single call, run terminates)
turn 2 diagnostics: runsFinished=2, runningNow=false          (RUN_FINISHED now fires, runs complete)
bodyText: QUARTERLY REVENUE $4.2M / Revenue by Region / NA·EMEA·APAC·LATAM  (dashboard renders)
```

`runsFinished` 0 → 2 and `runningNow` true → false confirms the run now
terminates. The class-F hang is fixed.

## Scope note

The remaining turn-2 `surface-missing` on this cell is a **separate**
RCA class-A defect (missing `DataTable` renderer in the per-integration
frontend catalog), owned by a different fix and out of scope here.
2026-07-18 11:47:35 -07:00
Jordan Ritter e3b3d2f14c fix(showcase): pin ANTHROPIC_BASE_URL aimock serviceRef for claude-sdk-python (SSOT drift-proof)
The claude-sdk-python agent routes its LLM traffic through ANTHROPIC_BASE_URL
(see src/agents/claude_agent_sdk_adapter.py and the aimock-wiring probe's
claude-sdk pattern), but the railway-envs SSOT only declared an OPENAI_BASE_URL
serviceRef. Add the ANTHROPIC_BASE_URL -> aimock serviceRef so the Stage-2 Ruby
promote preflight asserts it prod->prod (never copies) and refuses a cross-env
leak. The var is already set correctly on the live service; this is SSOT
hygiene that makes the pin drift-proof. Regenerated railway-envs.generated.json
via the repo generator (oxfmt-canonical, emit --check clean).
2026-07-18 11:16:09 -07:00
Jordan Ritter 81410e0c2c fix(showcase): bound claude-sdk-python declarative gen-ui agent loop so RUN_FINISHED always fires
The a2ui_dynamic declarative agent drove its tool loop with `while True:`,
breaking only when the model returned a turn with no tool calls. With a
real LLM key the model keeps re-calling `generate_a2ui` after each tool
result, so that empty-tool turn never arrives — the loop spins forever,
RUN_FINISHED is never emitted, and the harness times out with
`done-signal-missing` (the run hangs after the A2UI render).

Replace the unbounded loop with a bounded `for _iter in
range(MAX_TOOL_ITERATIONS)` (cap 10), mirroring the proven-GREEN
claude-sdk-typescript sibling. The loop now always falls through to
RUN_FINISHED, so the run terminates after the render.

Only reproduces with a real key: a dummy key hits the auth-fail path,
which already terminates.
2026-07-17 23:25:45 -07:00
Jordan Ritter 2b9c3fe779 fix(showcase): add declarative DataTable renderer to 4 missing integrations
Commit 1e0d200f5 added the team-performance pill to d5-gen-ui-declarative,
which requires `[data-testid="declarative-data-table"]` to mount. It added
the DataTable renderer + Zod definition to langgraph-python and 6 others,
but missed 4 integrations whose declarative-gen-ui catalogs were drifted
copies from an earlier snapshot: claude-sdk-typescript, pydantic-ai,
langgraph-fastapi, langgraph-typescript.

Root cause: all 4 integrations serve a `next start` production build whose
`renderers.tsx` defines only Card/StatusBadge/Metric/InfoRow/PrimaryButton/
PieChart/BarChart — no DataTable. The backend SSE stream returns a valid
`render_a2ui` payload containing a DataTable component; with no client
renderer it is silently dropped → declarative probe turn 2 times out with
reason=surface-missing.

Decision: per-integration real files (not symlinks — confirmed by file size
diff: 12042 B vs 13515 B canonical). Added DataTable renderer + definition
to each integration's `declarative-gen-ui/a2ui/` matching their existing
ShadCN/card-based style (sourced from strands-typescript, which is the
correct peer, not the inline-style langgraph-python canonical).

Red-green value-test:
- pydantic-ai: RED (turn 2 surface-missing, 90s timeout, data-table=0) →
  GREEN (turn 2 assertions passed, "Here's how the team is tracking...")
- langgraph-typescript: RED (turn 2 surface-missing) →
  GREEN (turn 2 assertions passed, probe advances to turn 3/4)
- claude-sdk-typescript: RED confirmed (turn 2 surface-missing); GREEN
  blocked locally by separate aimock strict-mode miss on turn 1 — unrelated
  class B backend fixture issue, not DataTable. Fix is structurally identical
  to pydantic-ai/langgraph-typescript and confirmed correct by Docker build.
- langgraph-fastapi: container not running locally; fix structurally identical.
2026-07-17 23:22:17 -07:00
Jordan Ritter 2d7dbecb47 fix(showcase): rewrite gen-ui-agent probe to per-pill content assertion
The previous probe relied on a fragile cross-pill-difference heuristic:
it fingerprinted the rendered step text and used inter-pill differences
as a settling signal, accepting any render with >=2 rows at the deadline.
That heuristic false-greened a real pill-3 stale-card regression, because
a stale render (pill 3 still showing pill 1's content) still satisfied
">=2 rows present" and the dedup was only a wait mechanism, never a hard
gate.

This rewrites the assertion to check EXPECTED CONTENT per pill. Each pill
carries a small set of low-brittleness content markers derived from its
step titles in the d5 fixture (product-launch -> launch/marketing,
team-offsite -> venue/agenda, competitor-research -> competitor/weakness).
The assertion polls the swap window until the card shows >=2 NON-EMPTY
step rows whose joined text contains ALL of that pill's markers; otherwise
it hard-fails. Marker matching is partial and case-insensitive so it stays
robust to live-LLM (--direct) nondeterminism while still proving the RIGHT
pill's content rendered.

Verified with a dynamic-fake red-green plus three retained false-green
guards: identical-across-pills canned steps, stale non-adjacent content
(pill 3 showing pill 1), and empty/whitespace-only rows all turn RED;
distinct-per-pill content passes.

NOTE: this EXPOSES a genuine pill-3 stale-state regression on
agno/langroid/crewai-crews. Those cells are legitimately RED under the
corrected probe until that backend/frontend bug is fixed (separate
follow-up). The langgraph-python reference passes.
2026-07-17 22:37:15 -07:00
Aria Zhao e5c1af418a fix(react-core): expose isReady from useAgent so subscriptions can target the real agent (#5000)
`useAgent` always returns a fully-constructed `AbstractAgent`: a provisional
stand-in while the runtime is still connecting (or in an error state), swapped
for the real agent once the `/info` sync resolves. The returned type claimed
`agent` was always the real agent, giving consumers no way to tell the two
apart — so one-time subscriptions (e.g. `onRunFinalized`) registered during the
provisional window landed on the placeholder and missed events until the effect
re-ran after the swap.

Add an `isReady` flag to the return value: `false` while the agent is
provisional, `true` once the real (or locally-registered) agent is bound.
Additive and backward compatible.

Also fix the docs' "Event Subscription" example, which used an empty
`useEffect` dependency array and therefore never re-subscribed when the agent
reference changed.

Note: the original crash from #5000 ("Cannot read properties of undefined
(reading 'subscribers')") no longer reproduces on `main` — the provisional-agent
work (#5533/#5635) guarantees a fully-constructed agent, so `subscribe()` is
always safe. The added tests lock in that no-crash behavior and cover the new
`isReady` transition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 04:39:46 +00:00
Jordan Ritter d9ac09f83c fix(harness): exclude starter-* and harness-workers from aimock-wiring probe
The aimock_wiring:global probe went red on the residual-6 live services
(harness-workers + 5 starters). Root cause is EXCLUDE naming drift after
the egress/private-networking migration: EXCLUDE_SERVICES keyed starters
as showcase-starter-<framework> (matching only starter-<framework>), but
live Railway names are bare starter-<framework>[-lang] (e.g.
starter-strands-python, starter-langgraph-js) — no match, so they fell
through to being checked, landed in unwired, and kept the probe red.
harness-workers had no exclude entry at all.

Fix: exclude the whole starter-* family by prefix in isExcluded (starters
are contributor scaffolds, categorically not wired through aimock; safe
because no showcase-* backend name starts with starter-, so it never
over-excludes a real backend), and add bare harness-workers to the infra
exclude set. Superseded showcase-starter-* literals removed; inert
showcase-shell-* legacy literals retained to keep the diff minimal.

The 20 showcase-* LLM backends were already re-wired via Railway
AIMOCK_URL; this is a naming/exclusion fix only (no starter is repointed).
2026-07-17 14:57:36 -07:00
Benjamin Taylor a6768cf1e6 docs: add Thread & History Lifecycle to docs-render expected nav order
The new Threads page shifts the expected navigation order; update the
expected array in docs-render.test.ts to include "Thread & History
Lifecycle" after "Overview" so the shell-docs suite passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 12:25:30 -05:00
Benjamin Taylor fa319dffe5 docs: address CR on threads-lifecycle guide (agentId prop, per-framework nav, persistence caveat)
Addresses samjulien's review on #5988:
- Use `agentId` (not `agent`) in both <CopilotChat> snippets — `agent` is
  not a v2 prop.
- Add threads-lifecycle to every authored-framework Threads nav group
  (built-in-agent, mastra, crewai-flows, llamaindex, agno, ag2,
  pydantic-ai, microsoft-agent-framework, deepagents). Extracted the page
  body into a shared snippet and made the root + per-framework pages thin
  wrappers, matching the existing threads/headless-threads/threads-import
  single-source convention.
- Qualify the "Run" glance statement: server-side persistence/replay
  depends on a configured store (Enterprise Intelligence or a persisting
  AgentRunner); a runtime with no persistence layer keeps nothing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 12:02:30 -05:00