Skip to content

feat(ux-demos): add dynamic UI rendering sample in Python and TypeScript - #341

Merged
arronbailiss merged 2 commits into
strands-agents:mainfrom
arronbailiss:feat/dynamic-ui-sample
Nov 3, 2026
Merged

arronbailiss merged 2 commits into
strands-agents:mainfrom
arronbailiss:feat/dynamic-ui-sample

Conversation

@arronbailiss

@arronbailiss arronbailiss commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Human Overview

Add a sample focused on dynamic agent-driven UI generation

Description

Adds a sample, in both Python and TypeScript, of an agent that answers with UI components rather than just text. The app defines a component catalog as a schema (Pydantic in Python, Zod in TypeScript), and that schema is the input of a render_ui tool. The model can only produce components the app supports, and Strands validates them before the app sees them. A shared plain HTML and JavaScript client renders each component type and sends form submits and button clicks back to the agent, which acts on them and renders again.

The existing AG-UI sample maps each tool to a predefined React component. Here the agent chooses the components and lays them out itself, with no frontend framework or build step, so the pattern can be lifted into any app.

  • python/07-ux-demos/dynamic-ui: FastAPI server
  • typescript/03-ux-demos/dynamic-ui: Express server, in a new TypeScript UX Demos category

Both samples use the same web client, dataset, components and prompts.

Testing

  • Ran both samples locally against Amazon Bedrock and drove the UI in headless Chrome: summary, runs table, log-a-workout form, submit, and the updated view. Totals come from a summarize_workouts tool and match the dataset.
  • Python passes ruff check and ruff format --check; TypeScript passes tsc.
  • node generate-samples-manifest.mjs --check and node --test generate-samples-manifest.test.mjs pass.
  • Imported both READMEs with the docs site's sample importer (site/scripts/samples/sync.ts in harness-sdk). Both guide pages build, and the screenshot and cross-sample links resolve.
  • Both servers listen on 127.0.0.1 only.

Both prompts have the agent call render_ui before its final reply. Without that, the TypeScript SDK could fail on an empty final turn from Bedrock (strands-agents/harness-sdk#5763, fix in strands-agents/harness-sdk#5762).

An agent that answers with UI components chosen from an app-defined catalog. The catalog (Pydantic / Zod) is the render_ui tool's input schema, so the model can only emit supported components and Strands validates them. A shared no-build web client renders each component type and sends form and button interactions back to the agent.
Use the template's heading case, move the prompts into Example Queries, and add Additional Resources.
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Latest scan for commit: 953bf29 | Updated: 2026-11-03 01:52:29 UTC

✅ Security Scan Report (PR Files Only)

Scanned Files

  • python/07-ux-demos/dynamic-ui/README.md
  • python/07-ux-demos/dynamic-ui/agent.py
  • python/07-ux-demos/dynamic-ui/catalog.py
  • python/07-ux-demos/dynamic-ui/data/workouts.json
  • python/07-ux-demos/dynamic-ui/images/demo.png
  • python/07-ux-demos/dynamic-ui/requirements.txt
  • python/07-ux-demos/dynamic-ui/server.py
  • python/07-ux-demos/dynamic-ui/tools.py
  • python/07-ux-demos/dynamic-ui/web/app.js
  • python/07-ux-demos/dynamic-ui/web/index.html
  • ... and 18 more files

Security Scan Results

Critical High Medium Low Info
0 0 0 0 0

Threshold: High

No security issues detected in your changes. Great job!

This scan only covers files changed in this PR.

@arronbailiss
arronbailiss marked this pull request as ready for review November 3, 2026 01:53
@arronbailiss
arronbailiss enabled auto-merge (squash) November 3, 2026 01:53
@arronbailiss
arronbailiss merged commit 3c9ebca into strands-agents:main Nov 3, 2026
2 checks passed
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