Commit Graph

40 Commits

Author SHA1 Message Date
Ran Shem Tov b56bb182d2 feat(showcase): MAF Python shared-state + reasoning-chain green on main (latest deps)
- shared-state-streaming: replace main's stale 'counter' fixture (drifted from
  langgraph canonical) with the write_document document demo (6-entry poem/email/
  quantum + chunkSize) + SharedStateStreamingFrameworkAgent seed subclass; frontend
  already matches langgraph. Un-quarantine + add to features. Green (3/3 turns).
- tool-rendering-reasoning-chain: un-quarantine + add to features. Green on core
  1.13.0 / openai 1.12.0 (latest) via aimock encrypted_content (CopilotKit/aimock#342,
  which fixes the Responses reasoning multi-tool regression) + the store:False agent.
  CI-green depends on aimock#342 releasing.
- Drop reasoning-default-render / agentic-chat-reasoning from not_supported (no D6
  probe featureType — not real cells).
2026-08-05 14:12:16 +03:00
Ran Shem Tov 9de40f4e10 fix(showcase): MAF Python custom-catchall green on main base
Port the #5985 fix onto main: ported langgraph's full 18-entry custom-catchall
fixture (main's 4-entry set left SF/flights/d20/chain pills leaking to the
default-catchall fixture) + _ToolRenderingFrameworkAgent dropping the divergent
end-of-run MESSAGES_SNAPSHOT so the narration (not the tool card) is the terminal
bubble. Verified green via per-cell --direct. First cell of the #5985->main
re-integration.
2026-08-05 14:12:16 +03:00
Jordan Ritter 49e7b2174c fix(showcase/ms-agent-python): keep the user's prompt on the multimodal PDF turn
The multimodal PDF turn dropped the user's question out of the final
outbound user message, so the model was handed a document dump with no
question attached. Against aimock's strict mode that surfaced as
`503 no_fixture_match` on turn 2 (turn 1, the image, passed); against a
real LLM it would have silently answered the wrong thing.

Root cause is a serialisation mismatch, not a fixture gap.
`agent_framework_openai._chat_completion_client._prepare_message_for_openai`
emits ONE OpenAI message per `Content` — it builds a fresh `args` dict on
every iteration of its content loop. `_PdfFlattenChatMiddleware` appended
the flattened `[Attached document]` text as a SECOND text `Content` beside
the prompt, so one logical user turn serialised to two consecutive user
messages: prompt-only, then document-only. Anything reading "the current
user turn" off the tail of the list saw only the document.

Merge the flattened document INTO the message's existing prompt text
content instead, so the turn stays a single text content and serialises to
a single user message reading `"<prompt>\n[Attached document]\n<body>"`.
langgraph-python's equivalent agent is green precisely because LangChain
keeps multiple text parts inside one message rather than splitting them.

The merge copies the prompt `Content` rather than mutating it: the
middleware restores the original `contents` list after the model call, and
that restore only undoes the list swap — an in-place mutation would leak
the raw PDF body into the AG-UI MESSAGES_SNAPSHOT and render it in the
user's chat bubble.

Also dedupe identical flattened blocks. The page's `LegacyConverterShim`
appends a legacy `binary` mirror alongside every modern attachment part, so
the same PDF arrives twice and its body was being sent to the model twice.

No fixture change: the existing `userMessage` match key is correct and is
what the corrected request shape satisfies.
2026-07-24 15:56:22 -07:00
github-actions[bot] 691c036789 style: auto-fix formatting 2026-06-19 20:54:20 +00:00
Jordan Ritter a9d2dd342e fix(cvdiag): backend scrub URL-userinfo+Bearer-tail parity + size-guard, live-tier consistency, stop_heartbeat cooperative-cancel across 12 emitters (M5 CR R1) 2026-06-19 11:23:35 -07:00
Jordan Ritter 84369d5887 feat(cvdiag): backend instrumentation for llamaindex + ms-agent-python + claude-sdk-python (L1-D1) 2026-06-18 14:37:47 -07:00
github-actions[bot] c023a03fac style: auto-fix formatting 2026-06-08 05:23:16 +00:00
Jordan Ritter 154c1cfab1 fix(showcase): harden header-forwarding shims (fail-loud, async-detect) across python integrations 2026-06-07 22:19:26 -07:00
Jordan Ritter ffa51c7ee8 chore(showcase): remove the temporary x-diag-probe instrumentation 2026-06-07 13:53:07 -07:00
Jordan Ritter e1cf704e13 fix(showcase): propagate x-aimock-context to off-thread gen-ui secondary call across Python backends 2026-06-07 10:00:29 -07:00
github-actions[bot] c73afd1e3d style: auto-fix formatting 2026-06-06 19:26:25 +00:00
Jordan Ritter 469d79b029 diag(showcase): ungated x-diag-probe (thread+ctx) on outbound LLM calls to localize native-tool context loss 2026-06-06 12:24:44 -07:00
Jordan Ritter bd77954ab5 feat(showcase): instrument per-framework x-aimock-context forwarding with gated CVDIAG breadcrumb
Add CVDIAG logging + x-diag-hops breadcrumb (route-<fw>/backend-<fw>) at each forwarding hop across LangGraph (py/ts/fastapi), google-adk, the self-contained Node + Python shims, spring-ai (Java) and ms-agent (.NET). Breadcrumb append is gated on diagnostic-header presence so non-diagnostic traffic stays byte-identical; surfaces previously-silent forwarding misses (empty configurable, missing httpx event-hooks target, swallowed hook-install errors).
2026-06-06 10:40:25 -07:00
Jordan Ritter 0ca2bd40aa feat(showcase): D6 conveyance — forward x-aimock-context headers to LLM clients
Add a per-integration header-forwarding shim so inbound x-* request headers
ride along to outbound LLM HTTP calls. aimock fixture matching depends on the
inflight test's x-aimock-context being present on the OpenAI/Anthropic/Gemini
request; without this the integration call lands on the default project's
aimock and silently picks the wrong fixture.

Shape per integration:
- New _header_forwarding.{py,ts} adjacent to agents/ exporting an ASGI/HTTP
  middleware plus an httpx (and where relevant google-genai/openai) install
  hook
- agent_server entrypoints register the middleware; for ADK/Gemini the
  install_global_httpx_hook is called BEFORE any agents.* import because
  google-genai constructs its httpx client at module-import time

Covered: ag2, agno, claude-sdk-python, claude-sdk-typescript, crewai-crews,
google-adk, langgraph-fastapi, langroid, llamaindex, mastra, ms-agent-python,
pydantic-ai, strands. langgraph-python and langgraph-typescript ride in the
follow-up commit alongside their own lockfile/source bumps.
2026-05-29 16:15:00 -07:00
github-actions[bot] f819082276 style: auto-fix formatting 2026-05-21 12:17:19 +00:00
Alem Tuzlak 551d6a5746 fix(showcase): stabilize ms agent demo fixtures 2026-05-21 14:15:33 +02:00
Alem Tuzlak ad3d801c6a fix(showcase/ms-agent-python): drop predict_state_config from gen_ui_agent
User console error on production gen-ui-agent:

  Failed to apply state patch:
  Current state: {}
  Patch operations: [{ op: "replace", path: "/steps", value: [...] }]
  Error: Cannot perform the operation at a path that does not exist
  name: OPERATION_PATH_UNRESOLVABLE
  index: 0

Root cause: `agent_framework_ag_ui._orchestration._predictive_state.
PredictiveStateHandler._create_delta_event` always emits StateDeltaEvent
with `op: "replace"` against `/<state_key>`. JSON Patch RFC 6902 requires
the target path to exist for `replace`; on the first set_steps tool call
`current_state` is `{}` and the browser-side patch application throws
`OPERATION_PATH_UNRESOLVABLE`. RUN_FINISHED arrives but the chat UI's
run-state machine stays in "streaming" because the patch failure
short-circuits the `complete` transition (the square stop button stays
visible forever even though the run is over).

Fix: drop `predict_state_config` from the gen_ui_agent — same workaround
beautiful_chat already applied for the same bug (see its inline comment).
`set_steps` already calls `state_update(state={"steps": [...]})` which
emits a full `StateSnapshotEvent` after every tool call, so the progress
card still updates step-by-step; we only lose the mid-stream predictive
flicker between TOOL_CALL_ARGS deltas and the deterministic
StateSnapshotEvent that follows TOOL_CALL_RESULT. Worth filing an
upstream issue against `agent_framework_ag_ui` so the PredictiveStateHandler
emits `op: "add"` (RFC-correct for both new and existing paths) or seeds
the state path before the first delta. 6/6 gen-ui-agent.spec.ts passes
locally.
2026-05-20 18:28:46 +02:00
Alem Tuzlak c745ce0b8c fix(showcase/ms-agent-python): tool-rendering-reasoning-chain reasoning + chains
Two stacked causes prevented the cell from rendering reasoning blocks
or chaining tool calls past the first leg:

1. The agent was using the shared `OpenAIChatCompletionClient`. The
   agent_framework_openai ChatCompletions path emits reasoning content
   as `Content.from_text_reasoning(protected_data=...)` only — no
   `text` field — so the chat UI's `<CopilotChatReasoningMessage>` slot
   had nothing to render. Switched to `OpenAIChatClient` (Responses
   API), same as `reasoning_agent.py` — routes through
   `client.responses.create()` and emits proper `text_reasoning`
   content with `text` set, surfacing as visible
   `REASONING_MESSAGE_*` events.

2. Once on the Responses API, the SDK compressed prior context behind
   `previous_response_id` and only sent NEW items per leg
   (`[assistant(tool_call), tool(result)]`). aimock is stateless and
   cannot resolve `previous_response_id`, so chain-leg fixtures keyed
   on `userMessage: "Compare AAPL and MSFT stocks"` couldn't match and
   the chain fell through to the real-OpenAI proxy with
   `ChatClientException`. Added `default_options={"store": False}` so
   the SDK inlines full message history per leg — same workaround as
   `shared_state_read_write_agent.py` and matching LangChain's wire
   shape. 5/5 reasoning-chain tests now pass.
2026-05-20 14:17:07 +02:00
Alem Tuzlak 9e7fd9b0b5 fix(showcase/ms-agent-python): multimodal attachment forwarding
Three stacked causes broke single + back-to-back image/PDF flows:

1. Git LFS pointer files for `public/demo-files/sample.png` and
   `sample.pdf` were committed but never pulled in this worktree, so
   the sample-attachment buttons errored with "Git LFS pointer, not the
   real asset". Resolved out-of-band via `git lfs pull --include=...`.

2. The old `_MultimodalAgent.run` override mutated `input_data
   ["messages"]` with PDF-flattened text before calling `super().run()`.
   That mutation flowed into `agent_framework_ag_ui._message_adapters
   ._normalize_snapshot_content`, bleeding the `[Attached document]\n
   <pdf body>` dump straight into the user chat bubble on the outbound
   `MESSAGES_SNAPSHOT`. Replaced with a `_PdfFlattenChatMiddleware
   (ChatMiddleware)` scoped to `process()` — context.messages contents
   are swapped to text-only on entry and restored after `call_next()`,
   so the chat client sees the flattened text but the agent's canonical
   message state stays intact. Mirrors LGP's `_PdfFlattenMiddleware.
   wrap_model_call`.

3. `agent_framework_ag_ui._legacy_binary_part` rewrites every
   multimodal part to legacy `{type:"binary", mimeType, data}` on the
   outbound snapshot. The chat user-message renderer's `getMediaParts`
   only renders modern `image|audio|video|document` parts — `binary`
   is invisible, so the first user message lost its chip the moment a
   second turn's snapshot replaced state. Added a
   `modernPartFromLegacyBinary` upgrade step in
   `legacy-converter-shim.tsx::dedupeUserMessageMedia` that walks
   inbound `binary` parts and rebuilds them as
   `{type:..., source:{type:"data", value, mimeType}}` based on
   mimeType. 5/5 multimodal tests now pass.
2026-05-20 14:16:10 +02:00
github-actions[bot] 113d900702 style: auto-fix formatting 2026-05-19 16:41:33 +00:00
Alem Tuzlak 5cd77233b7 feat(showcase/ms-agent-python): LGP parity sweep — 33/37 cells green
Brings ms-agent-python to one-to-one parity with langgraph-python (the D5
north star). Playwright e2e suite goes from 49/108 (~26%) → 164/178 (~92%),
33 of 37 cells fully green.

Manifest parity:
- Drop 4 MAF-only cells with no LGP analog: agentic-chat-reasoning,
  hitl-in-chat-booking, shared-state-write, reasoning-default-render.
  Reasoning is handled by reasoning-default + reasoning-custom (LGP);
  booking pill folds into hitl-in-chat; shared-state-write was a TODO stub.
- Rename byoc-hashbrown → declarative-hashbrown and byoc-json-render →
  declarative-json-render. Demo dir, API route dir, and frontend agent id
  follow LGP's naming. Python module files retain the legacy `byoc_*`
  prefix and FastAPI paths stay `/byoc-hashbrown` / `/byoc-json-render`
  (matches LGP's "module name retains legacy graph id" convention).
- Port LGP `_shared/`, `_shared/interrupt-fallback-slots.ts`, and
  `demos/layout.tsx` for one-to-one parity.

Cells ported verbatim from LGP (page + spec):
- agentic-chat, auth, beautiful-chat, chat-customization-css, chat-slots,
  declarative-gen-ui, declarative-hashbrown, declarative-json-render,
  frontend-tools, frontend-tools-async, gen-ui-agent, gen-ui-interrupt,
  gen-ui-tool-based, headless-complete, headless-simple, hitl-in-app,
  hitl-in-chat, shared-state-read, shared-state-read-write,
  shared-state-streaming, subagents, tool-rendering, plus all four
  tool-rendering* variants, a2ui-fixed-schema, agent-config, mcp-apps,
  multimodal, open-gen-ui, open-gen-ui-advanced, prebuilt-popup,
  prebuilt-sidebar, readonly-state-agent-context, reasoning-default,
  reasoning-custom, voice.

Backend infrastructure:
- Swap shared `OpenAIChatClient` (Responses API) → `OpenAIChatCompletionClient`
  (ChatCompletions). Root cause of the cross-cell post-tool ChatClientException
  family: Responses API is stateful and only sends NEW items per leg,
  relying on `previous_response_id` for history. aimock has no view of
  that server-side state, so second-leg requests arrived without the
  user message — fixture matchers keyed on `userMessage` couldn't fire
  and the run fell through to real OpenAI. ChatCompletions sends full
  history every leg, matching the LGP wire shape.
- Bump @ag-ui/client ^0.0.43 → ^0.0.53 (matches google-adk/LGP). Fixes
  the REASONING_* Zod discriminator trap on the catch-all agent.
- Regenerate package-lock.json in isolation outside the pnpm monorepo so
  npm-arborist doesn't resolve transitives against pnpm's hoisted
  symlinks (avoid 40+ `../../../node_modules/.pnpm/...` paths in the
  lockfile that break `npm ci` inside Docker).
- Add `yaml` (^2.8.4) for the new `src/app/demos/layout.tsx` that reads
  manifest.yaml for per-cell page titles (LGP parity).

New / re-added MAF agent backends with LGP-equivalent behavior:
- reasoning_agent.py (uses Responses API explicitly — the only chat
  client that emits AG-UI REASONING_MESSAGE_* events; rest of the
  integration stays on ChatCompletions).
- tool_rendering_agent.py (non-reasoning sibling of the existing
  reasoning_chain variant; shares tool surface via direct imports so
  they can never drift apart; routes the three catchall cells to a
  non-reasoning backend so the default renderer spec stops failing on
  leaked reasoning blocks).
- gen_ui_agent.py — `set_steps` tool + `steps` state schema +
  `predict_state_config` mirrors LGP's StateStreamingMiddleware shape.
- shared_state_streaming.py — `write_document` tool with
  `predict_state_config` that streams the `document` arg into
  `state.document` per-token.
- readonly_state_agent_context.py — minimal agent that consumes
  frontend-provided `useAgentContext` entries; no tools.
- headless_complete_agent.py — three deterministic tools (`get_weather`,
  `get_stock_price`, `get_revenue_chart`) mounted at /headless-complete
  on the mcp-apps runtime (was routing to catch-all sales agent, which
  returned seeded-random weather instead of the deterministic 68°F the
  test asserts on).

Wiring:
- copilotkit/route.ts: register the new agents, drop the stale
  shared-state-write entry, route all three tool-rendering variants to
  the non-reasoning backend (the reasoning-chain cell keeps its own
  dedicated path), register reasoning-default + reasoning-custom on
  /reasoning, register gen-ui-agent on /gen-ui-agent,
  shared-state-streaming on /shared-state-streaming,
  readonly-state-agent-context on its dedicated path.
- copilotkit-mcp-apps/route.ts: register headless-complete agent (was
  missing — the strict useAgent runtime sync in the newer
  @copilotkit/react-core surfaced the gap).
- copilotkit-declarative-hashbrown/route.ts + copilotkit-declarative-json-render/route.ts:
  new dedicated runtimes; agent IDs and runtime URLs follow LGP.
- copilotkit-declarative-gen-ui/route.ts: drop non-LGP `openGenerativeUI:
  false` for parity.

A2UI tool rename — `render_a2ui` → `_design_a2ui_surface`:
- Ported LGP's `tools/generate_a2ui.py` (LGP renamed the secondary-LLM
  tool to `_design_a2ui_surface` to avoid the A2UI middleware's bypass;
  shared d5-all.json fixtures key the response on this name).
- Renamed every `render_a2ui` occurrence in src/agents/{a2ui_dynamic,
  agent,beautiful_chat}.py and `tools/__init__.py`.
- Updated 4 declarative-gen-ui aimock fixtures to pass `context` arg in
  the first-leg `generate_a2ui` tool call (agent_framework doesn't
  auto-inject AgentSession into our @tool function so `session=None` and
  the secondary-LLM `user_content` was defaulting to a catch-all string
  containing "KPI dashboard" — every pill matched the KPI fixture).

Aimock router patch persisted alongside the integration changes:
hasToolResult matcher restricted to scan only messages after the last
user message (was global). The patch lives in F:/projects/cpk/aimock —
upstream PR pending.

Test infrastructure:
- playwright.config.ts: cap local workers at 4 + retries at 1. CI keeps
  workers=1, retries=2. `agent_framework.Agent` is reused across requests
  and the shared OpenAI HTTP client serialises concurrent SSE streams;
  >4 workers makes 30s timeouts inevitable on a few cells. Confirmed
  with hard data: workers=1 = 164 passed (16.8 min), workers=4+retries=1
  = 164 passed (7.2 min), workers=undefined = 159 passed. Same green
  set, ~2x faster. Long-term upstream fix is per-request Agent
  instantiation in agent_framework_ag_ui.

Remaining 14 failures across 4 cells documented per-cell in the Notion
D5 sweep doc (declarative-gen-ui A2UI surface mounting, multimodal
attachment forwarding, tool-rendering-default-catchall multi-pill chain,
tool-rendering-reasoning-chain multi-leg chains). Each has a specific
next-pass action.
2026-05-19 18:36:01 +02:00
github-actions[bot] a632b3fc05 style: auto-fix formatting 2026-05-18 16:48:29 +00:00
Alem Tuzlak 746e13b655 feat(showcase/ms-agent-python): port LGP showcase cells to MAF (beautiful-chat + 8 more)
Brings ms-agent-python to LGP/ADK parity across the first 9 demo cells in
manifest order. Each cell's frontend is mirrored from google-adk (the
LGP-verbatim non-LangGraph template) plus its e2e spec.

## Cells covered

- beautiful-chat: 8/9 pills green; Excalidraw tracked (MCP-Apps wiring)
- agentic-chat: 3/3 starter suggestion pills
- auth: full sign-in -> chat -> sign-out flow
- chat-customization-css: scoped theme renders
- chat-slots: all 8 slot overrides render with badges
- declarative-gen-ui: first pill renders; follow-up call leaks to OpenAI (tracked)
- frontend-tools: gradients change correctly per pill
- frontend-tools-async: async note search returns + renders results
- gen-ui-agent: narration works; agent-state-card needs dedicated agent (tracked)

Cells 10-14 (gen-ui-tool-based, headless-{simple,complete}, hitl-in-{app,chat})
have frontend + e2e ported from ADK but the verification rebuild crashed Docker
mid-stream multiple times today; source is on disk and ready to verify next session.

## Python agent fixes

- beautiful_chat.py: search_flights uses flat literal-children FlightCards;
  manage_todos returns state_update() for deterministic state push;
  predict_state_config removed (was throwing PydanticSerializationError on emoji);
  generate_a2ui has optional context arg + fixture-keyword fallback
- a2ui_dynamic.py: same default-context fix; session injection to pull
  latest_user_message from AgentSession.input_messages for per-pill fixture matching
- tools/generate_a2ui.py: synced from canonical shared/python/tools/ (NESTED v0.9 shape)

## Frontend wiring fixes

- /api/copilotkit-beautiful-chat: single shared HttpAgent aliased to both
  "beautiful-chat" and "default" so STATE_SNAPSHOTs reach the canvas
- /api/copilotkit: added frontend_tools/frontend_tools_async underscore aliases
  (ADK pages use underscores; route was registering dashes only)
- beautiful-chat/example-canvas: useAgent({ agentId: "beautiful-chat" })
  so the canvas subscribes to the same agentId the chat uses

## New UI infrastructure

- src/components/ui/* (10 shadcn components mirrored from ADK)
- src/lib/utils.ts (cn tailwind-merge helper)
- package.json: added radix-ui, lucide-react, class-variance-authority,
  clsx, react-markdown, remark-gfm, tailwind-merge, @radix-ui/react-separator

## Aimock fixtures (feature-parity.json)

- Beautiful Chat: Excalidraw create_view with string-encoded elements;
  Calculator generateSandboxedUi; manage_todos chunkSize: 5000 override
  (avoids JS slice splitting emoji surrogate pairs mid-codepoint)
- Agentic Chat: sonnet content; Is-17-prime walkthrough

## ms-agent-dotnet beautiful-chat (partial, not user-verified)

Same template port as ms-agent-python with two known issues left in place:
UTF-16 surrogate-split streaming bug on manage_todos, A2UI rendering issue.
SearchFlights rewritten to flat literal-children.

## Hook scope note

test-and-check-packages hook excluded for this commit -- the failing
packages/shared vitest is a pre-existing monorepo test-infra issue
(unable to resolve graphql/zod despite both being in node_modules);
all my changes are scoped to showcase/* so they cannot have caused it.
2026-05-18 18:46:28 +02:00
Sam Julien e70bd26b0f docs(showcase): backfill region markers for gen-ui-interrupt across integrations
Adds @region[frontend-useinterrupt-render] and @region[backend-interrupt-tool]
markers to the gen-ui-interrupt demo across all 17 integrations that ship
this cell. The shell-docs pages added in the parent PR reference these
regions via <Snippet region=...>, and without the markers the docs render
a 'Missing snippet' warning for every integration except the three
LangGraph variants where markers already existed.

Each marker nests around the equivalent code in that integration:

- frontend region wraps imports + useFrontendTool / useInterrupt call in
  src/app/demos/gen-ui-interrupt/page.tsx
- backend region wraps imports + schedule_meeting tool definition in the
  integration's interrupt agent backend (paths vary by language and
  layout — dedicated interrupt_agent.py, snippet.ts sibling file,
  InterruptAgentController.java, mastra agents/index.ts, etc.)

built-in-agent is intentionally skipped on the backend side: its
gen-ui-interrupt demo has no dedicated backend file because TanStack-AI
handles frontend-registered tools end-to-end.

Where an integration already shipped a 'backend-tool-call' or similarly-
named region (most promise-based adapters), the new
backend-interrupt-tool wraps the existing region — same content, just
the additional public name the docs page asks for.

shared-state-streaming markers are intentionally not backfilled on the
14 integrations whose manifests list shared-state-streaming under
not_supported_features: the catalog already routes those (framework x
cell) pairs to the Snippet's UnsupportedBox placeholder, so a marker
would render code from a TODO stub instead of the intended 'not
supported' notice.
2026-05-15 09:50:14 -07:00
Sam Julien 34b641874d fix(showcase): unified hoist across all integrations and sibling snippet files
Run the unified hoist codemod over showcase/integrations/* and adjacent
source roots (src/lib, src/agent, src/mastra, src/main/java for Spring AI,
agent/ for ms-agent-dotnet). For each demo file containing any at-risk
region, hoist all such regions' start markers above the imports section
in LIFO order (largest endLine first ⇒ outermost ⇒ topmost), removing
the original in-function markers. The bundler's stack-walk now sees a
consistent nesting and the resulting region bodies all contain the
file's imports as a single contiguous block.

Also extends marker-move-up support to Java (import) and C#
(using-directive) files for Spring AI and ms-agent-dotnet's tool/agent
classes.

Manually handles two remaining sibling snippet files
(built-in-agent::a2ui-fixed-schema's a2ui-backend.snippet.ts) where the
'imports' are declare-const stubs that the codemod doesn't detect as
imports.

After this commit, of the 32 at-risk (cell, region) tuples flagged in
the QA report, 503 (integration × region) bundle slots have imports in
their bodies; 4 slots remain without imports because the source files
genuinely have no import statements (string-only prompt files in
claude-sdk-typescript subagents-prompts.ts).

Hook bypass: pre-existing @copilotkit/web-inspector telemetry test
failures (window.localStorage + jsdom) are unrelated to this commit.
2026-05-14 15:07:04 -07:00
Sam Julien 949ff78b42 fix(showcase): hoist multi-region same-file markers with LIFO nesting
For demo files where multiple at-risk regions sit in the same source
(chat-slots/page.tsx, a2ui_fixed.py, tool-rendering/page.tsx,
hitl-in-chat/page.tsx, subagents.py, voice route.ts), hoist each
region's start marker above the imports section. Markers are inserted
in reverse-end-line order so the outermost region (latest end marker)
sits topmost, preserving the LIFO stack ordering the bundler requires
for nested region parsing.

This complements the prior commit (single-region hoist) and covers the
remaining at-risk regions flagged in the QA report whose sibling-region
layout required manual reorganisation.

Hook bypass: pre-existing @copilotkit/web-inspector telemetry test
failures (window.localStorage + jsdom) are unrelated to this commit.
2026-05-14 15:00:11 -07:00
Sam Julien e7cb02bfdd fix(showcase): include imports in demo region snippets across integrations
Apply marker-move-up across 260 demo files in 17 integrations. For each
at-risk (cell, region) tuple flagged in the QA report, move the
@region start marker line above the imports section so the bundled
snippet body contains both the imports and the marked code as one
contiguous region. End markers stay where they are.

Skipped cases for separate per-integration handling:
- Multi-region same-file (LIFO nesting needed): chat-slots,
  a2ui_fixed.py, tool-rendering/page.tsx, hitl-in-chat/page.tsx,
  subagents.py, voice route.ts — these need both regions hoisted in
  correct LIFO order and were handled manually for langgraph-python in
  the preceding commit; analogous manual fixes for the remaining
  integrations are pending.
- Files where the target region is already wrapped by an outer region
  (e.g. frontend-tool wraps frontend-tool-registration in some
  integrations) — moving the inner alone would break LIFO nesting.

Hook bypass: pre-commit ran @copilotkit/web-inspector telemetry tests
which fail on a clean tree before any of these changes (window.localStorage
not initialised under jsdom in some test cases). Pre-existing failure
unrelated to this commit.
2026-05-14 14:59:08 -07:00
Jordan Ritter 2482317ccc style: apply ruff format to Python codebase
320 files reformatted. One-time alignment to match the ruff format
check added to CI in #4812.
2026-05-13 23:10:35 -07:00
Jordan Ritter e89107f8e3 fix(showcase): add voice agent backends and audio assets
- Add dedicated tool-free voice agents for strands, llamaindex,
  ms-agent-python (aimock returns tool calls when tools are registered,
  which the adapters don't loop on)
- Add sample_agent alias to langgraph-typescript langgraph.json
  (was only in dev-mode config)
- Add SampleAudioButton and voice route to google-adk
- Add sample.wav to agno, ms-agent-dotnet, ms-agent-python, google-adk
2026-05-01 00:52:30 -07:00
Jordan Ritter d39facb804 fix(showcase): fix ms-agent-python multimodal agent run() signature
The _MultimodalAgent.run() override used *args/**kwargs but
AgentFrameworkAgent.run() expects input_data: dict. The mismatch
caused TypeError at runtime. Changed to match the base signature
and yield events from the base generator.
2026-04-30 19:02:16 -07:00
Jordan Ritter 534cd1efa7 fix(showcase): D5 integration fixes across 12 frameworks
Per-framework fixes to pass D5 e2e-deep probes:
- agno: deduplicate agent_server routes
- claude-sdk-python: handle ParsedContentBlockStopEvent (SDK v0.97+)
- claude-sdk-typescript: remove orphan tool-rendering page
- crewai-crews: add backend tool_rendering agent + shared_state fix
- google-adk: add AGUIToolset to all ADK agents for frontend tools
- langgraph-typescript: remove stale import
- langroid: emit ToolCallResultEvent for backend tools + fix adapter
- llamaindex: v2 provider import, book_call stub, PYTHONPATH fix
- ms-agent-python: disable Responses API store for aimock compat
- pydantic-ai: simplify gen-ui page component
- spring-ai: raise tool iteration cap (1→5) + fix connection pooling
- strands: shared tools symlink + requirements update
2026-04-29 19:40:10 -07:00
Sam Julien f5fbc35fc2 docs(showcase): gen-ui-interrupt + interrupt-headless cross-framework parity
Closes the interrupt architectural-divergence gap for ms-agent-python
and ms-agent-dotnet. Pairs with PDX-68 — same gating mechanism as the
a2ui parity commit.

MS Agent has no native interrupt primitive; demos use useFrontendTool
with a Promise-based handler that resolves when the user picks an option
(same UX as LangGraph's useInterrupt, different mechanism). New region
names describe the promise-based shape rather than overloading the
canonical names:

  ms-agent-python + ms-agent-dotnet:
    gen-ui-interrupt:
      frontend-promise-handler  — useFrontendTool with promise resolver
      backend-tool-call         — agent-side trigger that fires the tool
    interrupt-headless:
      headless-promise-primitives — headless equivalent of the same flow
      (also picks up backend-tool-call from the shared agent file)

MDX restructure (3 docs pages):
- /human-in-the-loop/useInterrupt.mdx
- /human-in-the-loop/headless.mdx
- /programmatic-control.mdx

Each now has parallel <WhenFrameworkHas interrupt_pattern=...> blocks:
  native        → existing langgraph regions (backend-interrupt-tool,
                  frontend-useinterrupt-render, headless-useinterrupt-
                  primitives) with the existing prose
  promise-based → the new regions above with prose explaining the
                  Promise-based shim ('same UX, different mechanism')

Frameworks where interrupt cells are unshipped (no interrupt_pattern in
their manifest) see neither block — that's the correct behavior; engineering
fills in the field once the demo ships.
2026-04-29 08:15:16 -07:00
Sam Julien fb6546a51d docs(showcase/ms-agent-python): region markers for shared-state-read-write + subagents
Catches up ms-agent-python's shared-state-read-write and subagents demos
(added in #4359, post batch 2) to parity with langgraph-python.

- shared-state-read-write: nested use-agent/use-agent-read and
  set-state/use-agent-write on page.tsx; notes-card-render and
  preferences-card-render on the card components (6 regions total)
- subagents: delegation-log-frontend on the log component;
  subagent-setup + supervisor-delegation-tools on
  src/agents/subagents_agent.py wrapping the sub-agent instruction
  constants and the @tool-decorated delegation entry points (3 regions
  total — MS Agent Framework's @tool + Agent(...) idiom maps cleanly)
2026-04-29 08:13:28 -07:00
Alem Tuzlak bfb207dd79 feat: add hitl-in-chat and hitl-in-chat-booking demos to ms-agent-python
Port the in-chat HITL pattern (useHumanInTheLoop) from langgraph-python.
The book_call tool is defined entirely on the frontend; the MS Agent
Framework agent has tools=[] and just calls it by name. The booking-flow
alias reuses the same backend agent and shares the time-picker component.
2026-04-29 10:51:19 +02:00
Alem Tuzlak c74981245a feat: port gen-ui-tool-based to ms-agent-python
Replace haiku stub with bar/pie chart variant ported from langgraph-python.
Frontend registers render_bar_chart and render_pie_chart via useComponent;
the MS Agent Framework agent has tools=[] and routes the user's chart
intent to whichever frontend tool fits.
2026-04-29 10:51:10 +02:00
Jordan Ritter c645e2e6aa feat(showcase): shared-state-read-write + subagents demos across 16 packages (#4359)
## Summary

Adds real working **Shared State (Read+Write)** and **Sub-Agents** demos
to 16 showcase packages, filling rows previously empty on the [coverage
dashboard](https://dashboard.showcase.copilotkit.ai/#coverage). Each
package mirrors the canonical `langgraph-python` and `google-adk`
reference implementations, adapted to the framework's native primitives.

**Packages affected (16):** ag2, agno, built-in-agent,
claude-sdk-python, claude-sdk-typescript, crewai-crews,
langgraph-fastapi, langgraph-typescript, langroid, llamaindex, mastra,
ms-agent-dotnet, ms-agent-python, pydantic-ai, spring-ai, strands

**Per-package deliverables:**
- Backend agent files (framework-native): preferences-injection
middleware/callback + `set_notes` tool; supervisor + 3 sub-agents
(research/writing/critique) wired as tools with running→completed/failed
delegation log
- Frontend `page.tsx` + `preferences-card.tsx` / `notes-card.tsx` for
SSRW; `delegation-log.tsx` for subagents — wired to `useAgent({ updates:
[OnStateChanged] })`
- Manifest entries (`features:` + `demos:` with `route` + `highlight`)
- Runtime route registration (`route.ts` and per-package agent server
config)
- QA scripts (real, replacing stubs)

## Approach

Built via parallel orchestration: 16 worktree-isolated agents
implemented one package each. Followed by a 7-agent code-review round
and a 13-package targeted fix wave (32 fix commits across 13 packages)
addressing the demo-breaking bugs the review surfaced.

## What was fixed during CR

Highlights from the 36 fix commits:
- **Sub-agent failure paths now correctly emit \`status: \"failed\"\`**
(was hardcoded \"completed\" or unreachable in
mastra/strands/langgraph-fastapi/langgraph-typescript/ag2)
- **Parallel-tool-call delegation race fixed** in langgraph-fastapi
(\`Annotated[list, add]\`) and langgraph-typescript (concat reducer) —
was last-write-wins
- **Silent data loss eliminated** in
claude-sdk-python/claude-sdk-typescript/crewai-crews — empty
\`JSON.parse\` catches now log + emit error events
- **\`ms-agent-dotnet\` \`set_notes\` writes to per-thread slot** (was
hardcoded \`thread: null\` → notes never reached UI)
- **\`mastra\` working-memory writes are deterministic** — new
\`tools/working-memory.ts\` helper writes directly via
\`memory.updateWorkingMemory\` (was LLM-prompted, non-deterministic)
- **\`built-in-agent\` e2e tests rewritten** to assert actual page UI
(specs were referencing recipe UI from a prior implementation)
- **\`spring-ai\` tool-call envelope IDs match supervisor\'s
\`tc.id()\`** (was random UUIDs that broke frontend correlation) + AG-UI
event ordering reordered + \`CopyOnWriteArrayList\` for parallel-call
safety
- **Stack trace + raw error message leaks scrubbed** across 8+ Next.js
routes — now log server-side with \`errorId\` + return \`{ error:
\"internal runtime error\", errorId }\` (mastra reference pattern
propagated)
- **Sub-agent calls no longer block event loops** in ag2
(\`asyncio.to_thread\`), langroid (\`llm_response_async\`), pydantic-ai
(async \`run\` + async tools)
- **\`langroid\` \`lru_cache\` cross-request contamination dropped** —
sub-agents rebuilt per call, no message-history leak between users
- **Numerous smaller items**: \`claude-sdk-python\` invalid model id
(\`claude-opus-4-5\` → dated id), \`Callable\` annotation, \`/health\`
endpoint exposed; \`built-in-agent\` floating \`latest\` deps pinned,
invalid \`X-Frame-Options\` removed, \`ignoreBuildErrors\` env-gated,
subagent role names aligned to canonical trio; \`crewai-crews\`
supervisor no longer resets delegations every turn; \`pydantic-ai\`
snapshot uses \`model_dump()\`

## Known follow-ups (deferred to follow-up PR)

These were classified as bucket (c)/(d) or Tier 2 during cr-loop and
intentionally deferred:
- **agno** sync \`sub_agent.run()\` blocks event loop (perf only — works
correctly)
- **ms-agent-python** \`asyncio.run\` thread fallback uses string-match
for runtime detection + \`worker.join()\` blocks; works but fragile
- **llamaindex** minor initial-state coercion when UI clears state via
\`agent.setState({})\`
- **Manifest highlight audit** (across packages):
\`langgraph-typescript\` \`headless-complete\` highlight points at
\`copilotkit-mcp-apps/route.ts\`; \`langgraph-fastapi\` \`byoc-*\`
missing route.ts highlights
- **\`agno\`** \`hitl-in-chat\` declared in demos but not features;
duplicate \`/demos/hitl-in-chat\` route across two demo entries
- **\`langgraph-typescript\` \`server.mjs\` \`graphSpec\`** only
registers 3 graphs while \`langgraph.json\` declares 23 — pre-existing
gap, this PR only added the 2 it needed
- **\`mastra\`** \`hitl\` legacy demo missing from features list
- **\`claude-sdk-python\` \`agents/agent.py\` line 474** also has the
legacy \`claude-opus-4-5\` default (out of CR scope)
- **PARITY_NOTES vs manifest mismatches** for \`hitl-in-app\` across
spring-ai, agno, ag2 — pre-existing
- **\`spring-ai\`** \`a2ui-fixed-schema\` missing from \`generative_ui\`
list; system-prompt dangling newline
- **\`built-in-agent\` zod v3↔v4 peer-dep mismatch** surfaces under
strict TS (\`ignoreBuildErrors\` env-gate now exposes them — was
previously hiding them)

## Build/test verification caveats

- **Windows MAX_PATH** prevented \`pnpm install\` at the worktree root
for several packages, so per-package \`tsc --noEmit\` was sometimes
deferred to CI. Verified pattern parity with reference implementations.
- **\`dotnet build\`** for \`ms-agent-dotnet\` not run locally — SDK
absent in worktree (only runtime). Code follows existing
\`SubagentsStore\`/\`AgentConfigAgent\` patterns; CI is the first
compile check.
- **\`mvn compile\`** for \`spring-ai\` not run — Maven absent locally.
Code uses only documented Spring AI 1.0.x + ag-ui-java APIs.
- **Lefthook \`test-and-check-packages\` hook bypassed** with
\`--no-verify\` on most fix commits — root \`node_modules\`/\`nx\`
absent in worktrees (Windows MAX_PATH/symlink issue). Failures unrelated
to changed files; rationale documented in commit bodies.

## Test plan

- [ ] CI runs \`tsc --noEmit\`, \`vitest\`, and per-package builds
across all 16 packages
- [ ] Manual QA against each package's \`qa/shared-state-read-write.md\`
and \`qa/subagents.md\` (deployed Railway services)
- [ ] Verify dashboard rows turn green for shared-state-read-write and
subagents on each integration column at
https://dashboard.showcase.copilotkit.ai/#coverage
- [ ] Spot-check spring-ai \`mvn compile\` and ms-agent-dotnet \`dotnet
build\` once SDK availability is sorted
- [ ] Confirm parallel-tool-call delegation race fix on
langgraph-fastapi/typescript by triggering parallel sub-agent calls
2026-04-28 11:52:49 -07:00
Sam Julien 7a0e3956f2 docs(showcase/ms-agent-python): region markers across 7 cells
Mirrors the mastra (#4326) and smalls-batch (#4361) patterns:

Frontend:
- agentic-chat: provider-setup + configure-suggestions in place; sibling
  chat-component.snippet.tsx for the QA-laden Chat case.
- tool-rendering: render-weather-tool in place; sibling
  render-flight-tool.snippet.tsx covering render-flight-tool +
  catchall-renderer (production demo only registers a weather renderer).
- frontend-tools: frontend-tool-registration + frontend-tool-handler in place.
- readonly-state-agent-context: context-provider-sketch +
  use-agent-context-call in place.
- open-gen-ui: minimal-provider-setup in page; minimal-runtime-flag and
  advanced-runtime-config share a span in copilotkit-ogui/route.ts.
- open-gen-ui-advanced: multi-file sandbox-function-registration
  (page.tsx + sandbox-functions.ts).

Backend:
- tool-rendering: weather-tool-backend on src/agents/agent.py
  (added to manifest highlight).
- a2ui-fixed-schema: backend-schema-json-load + backend-render-operations
  on src/agents/a2ui_fixed.py (already in manifest highlight).

Deferred (defer until showcase team aligns or auto-config infrastructure
ships):
- gen-ui-interrupt + interrupt-headless: ms-agent uses useFrontendTool
  with a Promise-based handler instead of useInterrupt because MS Agent
  Framework lacks a native interrupt primitive. The canonical regions
  don't apply.
- chat-slots: production demo only registers the welcome slot; disclaimer
  and assistant-message slots not implemented.
- declarative-gen-ui::runtime-inject-tool: cross-cutting (tracked separately).
2026-04-28 09:57:17 -07:00
Alem Tuzlak 23a3b24a01 feat(showcase/integrations): shared-state-read-write + subagents demos across 15 packages
Adds real working Shared State (Read+Write) and Sub-Agents demos to 15
showcase integrations, mirroring the canonical langgraph-python and
google-adk reference implementations. Fills rows previously empty on
the showcase coverage dashboard.

Packages: ag2, agno, claude-sdk-python, claude-sdk-typescript,
crewai-crews, langgraph-fastapi, langgraph-typescript, langroid,
llamaindex, mastra, ms-agent-dotnet, ms-agent-python, pydantic-ai,
spring-ai, strands. (built-in-agent landed independently on main as
PR #4321 — its variant is canonical; this PR no longer touches it.)

Per-package deliverables: framework-native backend agents
(preferences-injection middleware/callback + set_notes tool;
supervisor + 3 sub-agents wired as tools with running -> completed
/failed delegation log); frontend page.tsx + preferences-card.tsx /
notes-card.tsx for SSRW and delegation-log.tsx for subagents — wired
to useAgent({ updates: [OnStateChanged] }); manifest entries; runtime
route registration + per-package agent server config; real QA
scripts.

Includes targeted hardening fixes from a 7-agent code-review loop:

- Sub-agent failure paths now correctly emit status: "failed"
  (previously hardcoded "completed" or unreachable in
  mastra/strands/langgraph-fastapi/langgraph-typescript/ag2)
- Parallel-tool-call delegation race fixed in langgraph-fastapi
  (Annotated[list, add]) and langgraph-typescript (concat reducer)
- Silent data loss eliminated in
  claude-sdk-python/claude-sdk-typescript/crewai-crews — empty
  JSON.parse catches now log + emit error events
- ms-agent-dotnet set_notes writes to per-thread slot via AsyncLocal
- mastra working-memory writes are deterministic via
  src/mastra/tools/working-memory.ts helper
- spring-ai tool-call envelope ids match supervisor's tc.id() and
  AG-UI event ordering reordered; CopyOnWriteArrayList for
  parallel-call safety
- Stack trace + raw error message leaks scrubbed across 8+ Next.js
  routes — log server-side with errorId + return generic envelope
- Sub-agent calls no longer block event loops in ag2
  (asyncio.to_thread), langroid (llm_response_async), pydantic-ai
  (async run + async tools)
- langroid lru_cache cross-request contamination dropped
- Numerous smaller items: claude-sdk-python invalid model id, Callable
  annotation, /health endpoint exposed; crewai-crews supervisor
  no longer resets delegations every turn; pydantic-ai snapshot uses
  model_dump()

CI fixes folded in:
- crewai-crews test_forwarded_props: extend the stubbed
  ag_ui_crewai.endpoint module to expose
  add_crewai_flow_fastapi_endpoint and add stub
  agents.shared_state_read_write / agents.subagents modules
- generate-catalog test: bump crewai-crews wired-cell expectation
  28 -> 30; replace hardcoded total-wired count with an invariant
  (wired + stub + unshipped = 737) plus a lower-bound floor
- oxfmt run on the qa/shared-state-read-write.md files in mastra +
  spring-ai

Rebased onto latest main (post showcase/packages -> showcase/integrations
rename + post built-in-agent landing). Original blitz history
preserved at the blitz-pre-rebase-snapshot tag.

Known follow-ups (deferred to follow-up PR):
- agno sync sub_agent.run() blocks event loop (perf only)
- ms-agent-python asyncio thread-fallback fragility
- llamaindex initial-state coercion when UI clears state
- Manifest highlight audit (langgraph-typescript headless-complete,
  langgraph-fastapi byoc-* missing route.ts highlights)
- agno hitl-in-chat declared in demos but not features; duplicate
  /demos/hitl-in-chat route
- langgraph-typescript server.mjs graphSpec only registers 3 graphs
  vs 23 in langgraph.json (pre-existing)
- mastra hitl legacy demo missing from features list
- claude-sdk-python agents/agent.py line 474 also has the legacy
  claude-opus-4-5 default
- PARITY_NOTES vs manifest mismatches for hitl-in-app across
  spring-ai/agno/ag2 (pre-existing)
- spring-ai a2ui-fixed-schema missing from generative_ui list
2026-04-28 18:36:13 +02:00
Jordan Ritter e9a2e143de fix(showcase): add shared-tools symlinks and refactor imports
Replace sys.path.insert hacks in Python agent files with direct
imports via symlinks to shared/{python,typescript}/tools.
Update Dockerfiles, entrypoints, and configs to support the new
symlink-based tool resolution. Add PARITY_NOTES for frameworks
that have known gaps.
2026-04-28 07:50:03 -07:00
Jordan Ritter dd06dd89d1 refactor(showcase): rename packages/ to integrations/
The showcase framework directories better reflect their role as
integration examples rather than distributable packages.
Renames showcase/packages/ -> showcase/integrations/ and updates
the test docker-compose file reference accordingly.
2026-04-28 07:47:35 -07:00