Skip to content

Commit fbe882e

Browse files
authored
fix(showcase): restore langgraph-python declarative-gen-ui to a2ui_dynamic graph (CopilotKit#4553)
## Summary PR CopilotKit#4542 incorrectly changed the langgraph-python declarative-gen-ui route from `graphId: "a2ui_dynamic"` to `graphId: "sample_agent"` and removed `injectA2UITool: false`. This caused a regression from 31/31 green to red. The `a2ui_dynamic` graph owns the `generate_a2ui` tool itself — the runtime must NOT auto-inject its own A2UI tool on top (`injectA2UITool: false`). The `sample_agent` graph is a generic chat agent with no tools, which can never produce A2UI surfaces. ## Test plan - [ ] langgraph-python returns to D5 green (31/31)
2 parents fc854c0 + 738a85c commit fbe882e

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

  • showcase/integrations/langgraph-python/src/app/api/copilotkit-declarative-gen-ui

showcase/integrations/langgraph-python/src/app/api/copilotkit-declarative-gen-ui/route.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// Dedicated runtime for the Declarative Generative UI (A2UI — Dynamic Schema)
2-
// cell. Mirrors the working claude-sdk-typescript reference pattern: the
3-
// backend is the neutral default graph (sample_agent), and the runtime
4-
// auto-injects the `render_a2ui` tool (injectA2UITool defaults to true).
5-
// The A2UI middleware serialises the registered client catalog into
6-
// `copilotkit.context` and detects `a2ui_operations` in the tool result,
7-
// streaming rendered surfaces to the frontend.
8-
//
9-
// Reference:
10-
// - showcase/integrations/claude-sdk-typescript/src/app/api/copilotkit-declarative-gen-ui/route.ts
2+
// cell. Splitting into its own endpoint (mirroring beautiful-chat) lets us set
3+
// `a2ui.injectA2UITool: false` — the backend agent owns the `generate_a2ui`
4+
// tool itself, so double-binding from the runtime would duplicate the tool
5+
// slot and confuse the LLM.
116

12-
import { NextRequest, NextResponse } from "next/server";
7+
import type { NextRequest } from "next/server";
8+
import { NextResponse } from "next/server";
139
import {
1410
CopilotRuntime,
1511
ExperimentalEmptyAdapter,
@@ -20,18 +16,18 @@ import { LangGraphAgent } from "@copilotkit/runtime/langgraph";
2016
const LANGGRAPH_URL =
2117
process.env.LANGGRAPH_DEPLOYMENT_URL || "http://localhost:8123";
2218

19+
const declarativeGenUiAgent = new LangGraphAgent({
20+
deploymentUrl: LANGGRAPH_URL,
21+
graphId: "a2ui_dynamic",
22+
langsmithApiKey: process.env.LANGSMITH_API_KEY || "",
23+
});
24+
2325
const runtime = new CopilotRuntime({
2426
// @ts-ignore -- see main route.ts
25-
agents: {
26-
"declarative-gen-ui": new LangGraphAgent({
27-
deploymentUrl: LANGGRAPH_URL,
28-
graphId: "sample_agent",
29-
langsmithApiKey: process.env.LANGSMITH_API_KEY || "",
30-
}),
27+
agents: { "declarative-gen-ui": declarativeGenUiAgent },
28+
a2ui: {
29+
injectA2UITool: false,
3130
},
32-
// `injectA2UITool` defaults to true — the runtime injects the A2UI tool
33-
// and the default graph receives it via CopilotKit middleware, matching
34-
// the working claude-sdk-typescript reference pattern.
3531
});
3632

3733
export const POST = async (req: NextRequest) => {

0 commit comments

Comments
 (0)