Skip to content

Commit 960dbb9

Browse files
committed
feat(claude-sdk-python): add reasoning + tool-rendering-reasoning-chain demos
1 parent 26039c5 commit 960dbb9

16 files changed

Lines changed: 1408 additions & 0 deletions

File tree

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ features:
5050
- voice
5151
- agent-config
5252
- auth
53+
- agentic-chat-reasoning
54+
- reasoning-default-render
55+
- tool-rendering-reasoning-chain
5356
demos:
5457
- id: cli-start
5558
name: CLI Start Command
@@ -346,6 +349,44 @@ demos:
346349
- src/app/demos/agent-config/config-card.tsx
347350
- src/app/demos/agent-config/use-agent-config.ts
348351
- src/app/api/copilotkit-agent-config/route.ts
352+
- id: agentic-chat-reasoning
353+
name: Agentic Chat (Reasoning)
354+
description: Visible reasoning / thinking chain rendered via a custom messageView slot
355+
tags:
356+
- chat-ui
357+
route: /demos/agentic-chat-reasoning
358+
animated_preview_url:
359+
highlight:
360+
- src/agents/reasoning_agent.py
361+
- src/app/demos/agentic-chat-reasoning/page.tsx
362+
- src/app/demos/agentic-chat-reasoning/reasoning-block.tsx
363+
- src/app/api/copilotkit/route.ts
364+
- id: reasoning-default-render
365+
name: Reasoning (Default Render)
366+
description: Reasoning rendered via CopilotKit's built-in collapsible card with zero custom config
367+
tags:
368+
- chat-ui
369+
route: /demos/reasoning-default-render
370+
animated_preview_url:
371+
highlight:
372+
- src/agents/reasoning_agent.py
373+
- src/app/demos/reasoning-default-render/page.tsx
374+
- src/app/api/copilotkit/route.ts
375+
- id: tool-rendering-reasoning-chain
376+
name: Tool Rendering (Reasoning Chain)
377+
description: Sequential tool calls combined with visible reasoning steps
378+
tags:
379+
- generative-ui
380+
route: /demos/tool-rendering-reasoning-chain
381+
animated_preview_url:
382+
highlight:
383+
- src/agents/tool_rendering_reasoning_chain_agent.py
384+
- src/app/demos/tool-rendering-reasoning-chain/page.tsx
385+
- src/app/demos/tool-rendering-reasoning-chain/weather-card.tsx
386+
- src/app/demos/tool-rendering-reasoning-chain/flight-list-card.tsx
387+
- src/app/demos/tool-rendering-reasoning-chain/custom-catchall-renderer.tsx
388+
- src/app/demos/tool-rendering-reasoning-chain/reasoning-block.tsx
389+
- src/app/api/copilotkit/route.ts
349390
- id: auth
350391
name: Authentication
351392
description: Framework-native request auth via the V2 runtime's `onRequest` hook; missing bearer token returns 401

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@
4747
from agents.byoc_json_render_agent import BYOC_JSON_RENDER_SYSTEM_PROMPT
4848
from agents.multimodal_agent import SYSTEM_PROMPT as MULTIMODAL_SYSTEM_PROMPT
4949
from agents.multimodal_agent import convert_part_for_claude
50+
from agents.reasoning_agent import run_reasoning_agent
5051
from agents.shared_state_read_write_agent import (
5152
run_shared_state_read_write_agent,
5253
)
5354
from agents.subagents_agent import run_subagents_agent
55+
from agents.tool_rendering_reasoning_chain_agent import (
56+
run_tool_rendering_reasoning_chain_agent,
57+
)
5458

5559
load_dotenv()
5660

@@ -181,6 +185,53 @@ async def event_stream() -> AsyncIterator[str]:
181185
)
182186

183187

188+
@app.post("/reasoning")
189+
async def reasoning_endpoint(request: Request) -> StreamingResponse:
190+
"""Reasoning demo backend — emits AG-UI REASONING_MESSAGE_* events.
191+
192+
Shared by the agentic-chat-reasoning and reasoning-default-render
193+
demos. Both demos hit the same backend; the difference is purely
194+
on the frontend slot configuration.
195+
"""
196+
body = await request.json()
197+
input_data = RunAgentInput(**body)
198+
199+
async def event_stream() -> AsyncIterator[str]:
200+
async for chunk in run_reasoning_agent(input_data):
201+
yield chunk
202+
203+
return StreamingResponse(
204+
event_stream(),
205+
media_type="text/event-stream",
206+
headers={
207+
"Cache-Control": "no-cache",
208+
"X-Accel-Buffering": "no",
209+
},
210+
)
211+
212+
213+
@app.post("/tool-rendering-reasoning-chain")
214+
async def tool_rendering_reasoning_chain_endpoint(
215+
request: Request,
216+
) -> StreamingResponse:
217+
"""Sequential tool calls + visible reasoning chain."""
218+
body = await request.json()
219+
input_data = RunAgentInput(**body)
220+
221+
async def event_stream() -> AsyncIterator[str]:
222+
async for chunk in run_tool_rendering_reasoning_chain_agent(input_data):
223+
yield chunk
224+
225+
return StreamingResponse(
226+
event_stream(),
227+
media_type="text/event-stream",
228+
headers={
229+
"Cache-Control": "no-cache",
230+
"X-Accel-Buffering": "no",
231+
},
232+
)
233+
234+
184235
@app.post("/subagents")
185236
async def subagents_endpoint(request: Request) -> StreamingResponse:
186237
"""Sub-agents demo — supervisor delegates to research/writing/critique."""

0 commit comments

Comments
 (0)