Skip to content

fix(showcase): repair ms-agent .NET real-LLM demo defects - #6224

Merged
AlemTuzlak merged 1 commit into
mainfrom
fix/ms-agent-dotnet-showcase-demo-bugs
Jul 29, 2026
Merged

AlemTuzlak merged 1 commit into
mainfrom
fix/ms-agent-dotnet-showcase-demo-bugs

Conversation

@AlemTuzlak

Copy link
Copy Markdown
Contributor

Summary

Fixes staging click-through failures on ms-agent-dotnet and ms-agent-harness-dotnet demos. Same class of bug as #6200 (GOTCHAS #8): aimock D6 was green while real LLMs failed.

Root causes & fixes

Demo Symptom Fix
beautiful-chat Sales Dashboard Catalog not found: sales_dashboard Force page-registered catalogId; stronger secondary design prompt
declarative-gen-ui KPI / pie / bar / status Loader never resolves; without a type; SummaryCard missing id Sanitize + normalize flat A2UI components; drop invalid entries; force declarative-gen-ui-catalog
shared-state-read-write Remember something Notes panel never updates AsyncLocal store write misses (tool EC); mirror writes + read fallback; wire dead deterministic reply path for the pill
subagents left panel Chat works, side UI empty Same AsyncLocal store bug for state.delegations
open-gen-ui-advanced calculator / ping host Form/input calculator; ping no-ops System prompt for clickable keypad + notifyHost / evaluateExpression wiring
beautiful-chat calculator Buttons do nothing OGUI guidance: type=button, no form, click handlers

Voice auth error

Not a code defect in the voice route: GuardedOpenAITranscriptionService correctly fails when OPENAI_API_KEY is missing on the Next.js process. Staging needs that env var on the showcase frontend service (transcription hits real OpenAI, not aimock).

MCP Excalidraw empty iframe

Left as follow-up — likely external MCP host / sandbox CSP; no agent-side bug found in wiring.

Test plan

  • dotnet test ms-agent-dotnet (79/79) in Docker SDK 9 — includes new A2UI force-catalog / type-as-key / drop-invalid tests
  • harness agent build + cvdiag tests (5/5)
  • Staging click-through after deploy:
    • /react/ms-agent-dotnet/beautiful-chat — Sales Dashboard paints; calculator interactive
    • /react/ms-agent-harness-dotnet/declarative-gen-ui — all four pills paint without A2UI errors
    • /react/ms-agent-harness-dotnet/shared-state-read-write — Remember something updates notes
    • /react/ms-agent-harness-dotnet/subagents — left panel shows running/completed delegations
    • /react/ms-agent-harness-dotnet/open-gen-ui-advanced — calculator keypad + ping host
    • Voice: confirm OPENAI_API_KEY present on staging frontend, then mic works

Staging click-through on ms-agent-dotnet / ms-agent-harness-dotnet hit
several GOTCHAS #8 defects: aimock D6 was green while live LLMs failed.

A2UI (beautiful-chat sales dashboard, declarative-gen-ui pills):
- Force the page-registered catalogId (models invent "sales_dashboard").
- Sanitize/normalize flat components; salvage type-as-key nests; drop
  entries missing id/component (SummaryCard without id, charts without type).
- Strengthen secondary design prompts with the flat catalog contract.

Shared state + subagents side panels:
- Tool invocation drops AsyncLocal set by SetActiveThread, so writes landed
  in the global slot while snapshots keyed by AgentSession/AgentThread.
  Mirror writes and fall back on read (same pattern as D5ParityAgents).
- Wire the dead TryBuildDeterministicReply path for the "Remember something"
  pill so notes update without relying on the model calling set_notes.

Open generative UI advanced + beautiful-chat calculator:
- Prompt for clickable keypad (not form/submit) and notifyHost ping wiring.

Verified: ms-agent-dotnet unit suite 79/79 green in Docker SDK 9; harness
agent builds clean and cvdiag tests 5/5.
@github-actions

Copy link
Copy Markdown
Contributor

Production Digest-Pinning Audit

All 41 services digest-pinned.

Run 2026-07-29 02:43:29 PDT — 0 finding(s).

@AlemTuzlak
AlemTuzlak marked this pull request as ready for review July 29, 2026 09:44
@AlemTuzlak
AlemTuzlak merged commit 75fc766 into main Jul 29, 2026
23 checks passed
@AlemTuzlak
AlemTuzlak deleted the fix/ms-agent-dotnet-showcase-demo-bugs branch July 29, 2026 09:51
AlemTuzlak added a commit that referenced this pull request Jul 29, 2026
…real LLM (#6228)

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

- Sibling real-LLM-vs-aimock fix: #6226
- Same class as #6224 (ms-agent .NET real-LLM demo defects)

## Checklist

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants