Files
Alem Tuzlak c9a304ec4e fix(showcase/langgraph-python): force JSON mode for byoc-json-render agent
Root cause: gpt-4o-mini occasionally answered "Show me the sales
dashboard with metrics and a revenue chart" with a prose preamble
or clarifying question instead of the JSON spec the `@json-render`
renderer expects, which made the frontend fall back to
CopilotChatAssistantMessage (plain text) rather than a MetricCard +
BarChart tree. The single-component prompts (Revenue by category,
Expense trend) were terse enough that the model usually complied,
but the multi-component Sales Dashboard prompt was where it drifted.

Fix:

- Pass response_format={"type": "json_object"} via model_kwargs so
  the OpenAI response is guaranteed to be a single JSON object,
  removing any possibility of a plain-text fallback.
- Tighten the system prompt so every user turn is answered with JSON
  (no clarifying questions, no prose) and components are referenced
  by their exact case-sensitive names.
- Extend the Sales Dashboard worked example to include two MetricCards
  plus a BarChart so the model has a concrete multi-component pattern
  to mirror - the round-1 children forwarding in the registry wrapper
  already supports arbitrarily many siblings under the root MetricCard.
2026-04-24 19:22:19 +02:00
..