Skip to content

Commit 96725d0

Browse files
committed
feat: claude-sdk-python adds hitl-in-chat, declarative-gen-ui, a2ui-fixed-schema, gen-ui-tool-based manifest
- hitl-in-chat (+ booking alias): frontend useHumanInTheLoop book_call tool; basic Claude SDK chat agent forwards AG-UI tool defs and lets standard tool-call lifecycle resolve the user's choice. - declarative-gen-ui: backend a2ui_dynamic agent owns generate_a2ui tool (calls secondary OpenAI client bound to render_a2ui), dedicated runtime route with injectA2UITool: false. - a2ui-fixed-schema: backend a2ui_fixed ships flight_schema.json and the display_flight tool emitting a2ui_operations directly; dedicated runtime route with injectA2UITool: false. - gen-ui-tool-based: manifest entry for the existing haiku demo (useFrontendTool + useRenderTool). - Per-demo READMEs documenting the architectural choice for each cell.
1 parent 025c9a2 commit 96725d0

23 files changed

Lines changed: 2333 additions & 0 deletions

File tree

showcase/integrations/claude-sdk-python/manifest.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ generative_ui:
1717
- constrained-explicit
1818
- a2ui-fixed-schema
1919
- a2ui-dynamic-schema
20+
- declarative-schema
2021
interaction_modalities:
2122
- sidebar
2223
- embedded
@@ -55,6 +56,11 @@ features:
5556
- tool-rendering-reasoning-chain
5657
- mcp-apps
5758
- beautiful-chat
59+
- gen-ui-tool-based
60+
- hitl-in-chat
61+
- hitl-in-chat-booking
62+
- declarative-gen-ui
63+
- a2ui-fixed-schema
5864
not_supported_features:
5965
- gen-ui-interrupt
6066
- interrupt-headless
@@ -426,3 +432,65 @@ demos:
426432
highlight:
427433
- src/app/demos/beautiful-chat/page.tsx
428434
- src/app/api/copilotkit/route.ts
435+
- id: gen-ui-tool-based
436+
name: Tool-Based Generative UI
437+
description: Agent uses tools to trigger UI generation (haiku generator via useFrontendTool + useRenderTool)
438+
tags:
439+
- generative-ui
440+
route: /demos/gen-ui-tool-based
441+
animated_preview_url:
442+
highlight:
443+
- src/agents/agent.py
444+
- src/app/demos/gen-ui-tool-based/page.tsx
445+
- src/app/api/copilotkit/route.ts
446+
- id: hitl-in-chat
447+
name: In-Chat HITL (useHumanInTheLoop — ergonomic API)
448+
description: Interactive approval/decision surface rendered inline in the chat via the high-level `useHumanInTheLoop` hook
449+
tags:
450+
- interactivity
451+
route: /demos/hitl-in-chat
452+
animated_preview_url:
453+
highlight:
454+
- src/agents/hitl_in_chat_agent.py
455+
- src/app/demos/hitl-in-chat/page.tsx
456+
- src/app/demos/hitl-in-chat/time-picker-card.tsx
457+
- src/app/api/copilotkit/route.ts
458+
- id: hitl-in-chat-booking
459+
name: In-Chat HITL (Booking)
460+
description: Time-picker card rendered inline via useHumanInTheLoop for a booking flow
461+
tags:
462+
- interactivity
463+
route: /demos/hitl-in-chat
464+
animated_preview_url:
465+
highlight:
466+
- src/agents/hitl_in_chat_agent.py
467+
- src/app/demos/hitl-in-chat/page.tsx
468+
- src/app/demos/hitl-in-chat/time-picker-card.tsx
469+
- src/app/api/copilotkit/route.ts
470+
- id: declarative-gen-ui
471+
name: Declarative Generative UI (A2UI)
472+
description: Canonical A2UI BYOC — custom catalog (Card/StatusBadge/Metric/InfoRow/PrimaryButton/PieChart/BarChart) wired via a2ui.catalog on the provider; backend agent owns the `generate_a2ui` tool with injectA2UITool false
473+
tags:
474+
- generative-ui
475+
route: /demos/declarative-gen-ui
476+
animated_preview_url:
477+
highlight:
478+
- src/agents/a2ui_dynamic.py
479+
- src/app/demos/declarative-gen-ui/page.tsx
480+
- src/app/demos/declarative-gen-ui/a2ui/catalog.ts
481+
- src/app/demos/declarative-gen-ui/a2ui/definitions.ts
482+
- src/app/demos/declarative-gen-ui/a2ui/renderers.tsx
483+
- src/app/api/copilotkit-declarative-gen-ui/route.ts
484+
- id: a2ui-fixed-schema
485+
name: Declarative Generative UI (A2UI — Fixed Schema)
486+
description: A2UI rendering against a known client-side schema; the backend ships flight_schema.json and only streams data via display_flight
487+
tags:
488+
- generative-ui
489+
route: /demos/a2ui-fixed-schema
490+
animated_preview_url:
491+
highlight:
492+
- src/agents/a2ui_fixed.py
493+
- src/agents/a2ui_schemas/flight_schema.json
494+
- src/app/demos/a2ui-fixed-schema/page.tsx
495+
- src/app/demos/a2ui-fixed-schema/a2ui/catalog.ts
496+
- src/app/api/copilotkit-a2ui-fixed-schema/route.ts

showcase/integrations/claude-sdk-python/src/agent_server.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@
4444
from fastapi.middleware.cors import CORSMiddleware
4545
from fastapi.responses import StreamingResponse
4646

47+
from agents.a2ui_dynamic import run_a2ui_dynamic_agent
48+
from agents.a2ui_fixed import run_a2ui_fixed_agent
4749
from agents.agent import create_app, run_agent
4850
from agents.agent_config_agent import build_system_prompt, read_properties
4951
from agents.byoc_hashbrown_agent import BYOC_HASHBROWN_SYSTEM_PROMPT
5052
from agents.byoc_json_render_agent import BYOC_JSON_RENDER_SYSTEM_PROMPT
53+
from agents.hitl_in_chat_agent import run_hitl_in_chat_agent
5154
from agents.mcp_apps_agent import run_mcp_apps_agent
5255
from agents.multimodal_agent import SYSTEM_PROMPT as MULTIMODAL_SYSTEM_PROMPT
5356
from agents.multimodal_agent import convert_part_for_claude
@@ -283,6 +286,66 @@ async def event_stream() -> AsyncIterator[str]:
283286
)
284287

285288

289+
@app.post("/hitl-in-chat")
290+
async def hitl_in_chat_endpoint(request: Request) -> StreamingResponse:
291+
"""In-Chat HITL demo — frontend `book_call` tool via `useHumanInTheLoop`."""
292+
body = await request.json()
293+
input_data = RunAgentInput(**body)
294+
295+
async def event_stream() -> AsyncIterator[str]:
296+
async for chunk in run_hitl_in_chat_agent(input_data):
297+
yield chunk
298+
299+
return StreamingResponse(
300+
event_stream(),
301+
media_type="text/event-stream",
302+
headers={
303+
"Cache-Control": "no-cache",
304+
"X-Accel-Buffering": "no",
305+
},
306+
)
307+
308+
309+
@app.post("/declarative-gen-ui")
310+
async def declarative_gen_ui_endpoint(request: Request) -> StreamingResponse:
311+
"""Declarative Generative UI (A2UI Dynamic Schema) demo."""
312+
body = await request.json()
313+
input_data = RunAgentInput(**body)
314+
315+
async def event_stream() -> AsyncIterator[str]:
316+
async for chunk in run_a2ui_dynamic_agent(input_data):
317+
yield chunk
318+
319+
return StreamingResponse(
320+
event_stream(),
321+
media_type="text/event-stream",
322+
headers={
323+
"Cache-Control": "no-cache",
324+
"X-Accel-Buffering": "no",
325+
},
326+
)
327+
328+
329+
@app.post("/a2ui-fixed-schema")
330+
async def a2ui_fixed_schema_endpoint(request: Request) -> StreamingResponse:
331+
"""A2UI Fixed Schema demo — backend ships flight_schema.json."""
332+
body = await request.json()
333+
input_data = RunAgentInput(**body)
334+
335+
async def event_stream() -> AsyncIterator[str]:
336+
async for chunk in run_a2ui_fixed_agent(input_data):
337+
yield chunk
338+
339+
return StreamingResponse(
340+
event_stream(),
341+
media_type="text/event-stream",
342+
headers={
343+
"Cache-Control": "no-cache",
344+
"X-Accel-Buffering": "no",
345+
},
346+
)
347+
348+
286349
def main() -> None:
287350
"""Run the uvicorn server."""
288351
port = int(os.getenv("AGENT_PORT", "8000"))

0 commit comments

Comments
 (0)