Skip to content

fix(showcase): unbreak gen-ui-agent and declarative-json-render on a real LLM - #6228

Merged
AlemTuzlak merged 2 commits into
mainfrom
fix/built-in-agent-real-llm-demos
Jul 29, 2026
Merged

AlemTuzlak merged 2 commits into
mainfrom
fix/built-in-agent-real-llm-demos

Conversation

@AlemTuzlak

Copy link
Copy Markdown
Contributor

What does this PR do?

Two built-in-agent demos were broken against a real model while their D5/D6 rows stayed green — d5:built-in-agent/gen-ui-agent, d5:built-in-agent/byoc and both e2e: rows all pass. Neither failure is reachable under aimock, so the fixtures could never have caught them (showcase/GOTCHAS.md #8). Both root causes were confirmed against the live OpenAI API.

1. gen-ui-agent stopped mid-plan on every run

@tanstack/ai's chat() applies maxIterations(5) when no agentLoopStrategy is passed (@tanstack/[email protected], src/activities/chat/index.ts: config.params.agentLoopStrategy || maxIterationsStrategy(5)). Nothing errors when the budget runs out — the run just ends. GEN_UI_AGENT_PROMPT scripts 7 set_steps calls (1 initial + in_progress/completed per step × 3) plus a closing message, so the walk died two calls short with the last step pinned at pending and no narration.

Captured from the staging SSE stream:

TOOL_CALL_START: 5,  STATE_DELTA: 5,  TEXT_MESSAGE_*: 0
call 5 (final): step1 completed, step2 completed, step3 pending

Reproduced locally with the real model, the real prompt and the real set_steps tool:

budget set_steps calls final statuses narration
default (5) 5 completed, completed, pending none
maxIterations(25) 7 completed, completed, completed 333 chars

Every demo factory now passes the shared DEMO_AGENT_LOOP_STRATEGY (25 — several times the longest scripted walk, still bounded, since each iteration is a model call). The two non-streaming tool-free chat() calls (subagent-tools, a2ui-factory's secondary designer) keep the default: they have no loop to exhaust.

2. declarative-json-render rendered nothing at all

RUN_STARTED → RUN_FINISHED, zero events between, no console error, no error banner.

text.format: { type: "json_object" } has a server-side precondition that the word "json" appear in the request's input. The adapter sends systemPrompts as instructions and only messages as input, so with the JSON directive living solely in SYSTEM_PROMPT the API rejected every single run:

400 Response input messages must contain the word 'json' in some form
    to use 'text.format' of type 'json_object'.   (param: input)

The directive now rides in messages — as role: "user", because TanStackChatMessage admits only user | assistant | tool and the runtime deliberately hoists system messages into systemPrompts, the very half that is not input. It is invisible in the UI (the chat renders from AG-UI events, not from what the backend sends the model). json_object enforcement is kept; verified live that the run then streams a complete, JSON.parse-able spec.

That 400 was invisible because the hand-rolled converters forward a whitelist of chunk types and dropped RUN_ERROR — every one except reasoning-factory. The type: "tanstack" factories were already fine (the runtime's convertTanStackStream rethrows, tanstack.ts:419), so the four type: "custom" converters now call the shared throwOnRunError. This is why a fleet-wide silent failure went unnoticed, and it is fixed independently of the JSON-mode bug.

3. The progress card stopped claiming completion it doesn't have

InlineAgentStateCard printed All ${total} steps complete whenever status === "complete", ignoring the step data — so a truncated run announced completion above a list that visibly showed step 3 unstarted, which is what made an agent stopping early read as a UI glitch. The wording now derives from the steps (describeProgress, extracted as a pure function so it is testable without a DOM), a stalled run says so, and the check-mark icon is gated on the data too.

Verification

  • 18 new unit tests, all green: agent-loop budget sized off the prompt itself, throwOnRunError, the json_object input precondition + converter behaviour, and the card's wording across running / done / stalled / empty
  • oxlint 0 warnings 0 errors on the changed dirs; oxfmt clean
  • Live end-to-end runs against real OpenAI for both root causes (tables above)
  • Pre-existing and unrelated: this integration is not a pnpm-workspace member, so tsc --noEmit here reports 73 errors from version skew in a standalone install (gpt-5.4 outside the pinned adapter's model union, @ag-ui/client not exposed as a direct dep). Both hit untouched files and untouched lines; my two real type errors were fixed. CI runs vitest only in showcase/scripts and showcase/harness, so these tests are developer-local, same as the pre-existing tanstack-factory.test.ts beside them.

Related PRs and Issues

Checklist

  • I have read the Contribution Guide
  • If the PR changes or adds functionality, I have updated the relevant documentation (showcase/GOTCHAS.md — two new entries)
  • "Allow edits by maintainers" is checked

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Production Digest-Pinning Audit

All 41 services digest-pinned.

Run 2026-07-29 06:32:00 PDT — 0 finding(s).

@AlemTuzlak
AlemTuzlak marked this pull request as ready for review July 29, 2026 12:59
@AlemTuzlak
AlemTuzlak enabled auto-merge July 29, 2026 13:10
mme
mme previously approved these changes Jul 29, 2026
…real LLM

Two built-in-agent demos were broken against a real model while their D5/D6
rows stayed green, because aimock exercises neither failure. Both root causes
were confirmed against the live OpenAI API.

gen-ui-agent stopped mid-plan on every run. `@tanstack/ai`'s `chat()` applies
`maxIterations(5)` when no `agentLoopStrategy` is passed, and nothing errors
when the budget runs out — the run just ends. GEN_UI_AGENT_PROMPT scripts 7
`set_steps` calls (1 initial + in_progress/completed per step x 3) plus a
closing message, so the walk died two calls short with the last step pinned at
`pending` and no narration. Reproduced with the real model and the real prompt:

  default budget -> 5 calls, "completed, completed, pending", no message
  maxIterations(25) -> 7 calls, all completed, 333-char summary

Every demo factory now passes the shared DEMO_AGENT_LOOP_STRATEGY (25 —
several times the longest scripted walk, still bounded). The two non-streaming
tool-free `chat()` calls keep the default: they have no loop to exhaust.

declarative-json-render rendered nothing at all: RUN_STARTED -> RUN_FINISHED,
no events, no console error, no banner. `text.format: { type: "json_object" }`
has a server-side precondition that the word "json" appear in the request
`input`, but the adapter sends `systemPrompts` as `instructions` and only
`messages` as `input` — so with the JSON directive living solely in
SYSTEM_PROMPT the API rejected every run with

  400 Response input messages must contain the word 'json' in some form to
      use 'text.format' of type 'json_object'.   (param: input)

The directive now rides in `messages` (as `user`, since TanStackChatMessage
admits no `system` role and the runtime hoists system messages into
systemPrompts — the half that is not input). json_object enforcement is kept;
verified live that the run then streams a complete, JSON.parse-able spec.

That 400 was invisible because the hand-rolled converters forward a whitelist
of chunk types and dropped RUN_ERROR — every one except reasoning-factory. The
`type: "tanstack"` factories were fine (the runtime's converter rethrows), so
the four `type: "custom"` converters now call the shared throwOnRunError.

Also: the gen-ui-agent progress card announced "All N steps complete" whenever
the RUN ended, ignoring the step data, so a truncated run read as a UI glitch
instead of an agent that stopped early. The wording is now derived from the
steps (`describeProgress`, extracted pure so it is testable without a DOM) and
a stalled run says so.

Both gotchas recorded in showcase/GOTCHAS.md.
@AlemTuzlak
AlemTuzlak force-pushed the fix/built-in-agent-real-llm-demos branch from 85df6c8 to 5c89395 Compare July 29, 2026 13:31
@pkg-pr-new

pkg-pr-new Bot commented Jul 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

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

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/agentcore-runner@6228

@copilotkit/angular

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

@copilotkit/channels

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

@copilotkit/channels-core

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-core@6228

@copilotkit/channels-discord

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-discord@6228

@copilotkit/channels-intelligence

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-intelligence@6228

@copilotkit/channels-slack

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-slack@6228

@copilotkit/channels-teams

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-teams@6228

@copilotkit/channels-telegram

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-telegram@6228

@copilotkit/channels-ui

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-ui@6228

@copilotkit/channels-whatsapp

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-whatsapp@6228

@copilotkit/core

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

@copilotkit/react-core

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

@copilotkit/react-native

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/react-native@6228

@copilotkit/react-textarea

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

@copilotkit/react-ui

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

@copilotkit/runtime

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

@copilotkit/runtime-client-gql

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

@copilotkit/sdk-js

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

@copilotkit/shared

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

@copilotkit/sqlite-runner

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

@copilotkit/voice

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

@copilotkit/vue

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

@copilotkit/web-components

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/web-components@6228

@copilotkit/web-inspector

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

commit: 5c89395

@AlemTuzlak
AlemTuzlak merged commit d4314dd into main Jul 29, 2026
1 check passed
@AlemTuzlak
AlemTuzlak deleted the fix/built-in-agent-real-llm-demos branch July 29, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants