Skip to content

Commit 1db0bd7

Browse files
committed
fix(showcase): resolve agent-not-found errors across integrations
- ms-agent-dotnet auth: V1→V2 CopilotKit import for proper agent discovery - ms-agent-python: register interrupt agents (array declared but never iterated) - claude-sdk-python: register hitl-in-chat-booking agent + fix stale dates - ag2 + langgraph-python: declarative-gen-ui routes use default agent with runtime auto-injection instead of custom backend a2ui agents - google-adk: hoist copilotRuntimeNextJSAppRouterEndpoint to module scope (per-request invocation caused race condition in agent Promise chain) - langgraph-fastapi: remove AgentConfigLangGraphAgent that caused HTTP 400 with LangGraph 0.6.0+; add default alias for open-gen-ui
1 parent 60d8139 commit 1db0bd7

14 files changed

Lines changed: 141 additions & 226 deletions

File tree

  • showcase/integrations
    • ag2/src/app/api/copilotkit-declarative-gen-ui
    • claude-sdk-python/src/app
    • google-adk/src/app/api
    • langgraph-fastapi/src/app/api
    • langgraph-python/src/app/api/copilotkit-declarative-gen-ui
    • ms-agent-dotnet/src/app/demos/auth
    • ms-agent-python/src/app/api/copilotkit

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

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// Dedicated runtime for the Declarative Generative UI (A2UI — Dynamic Schema)
2-
// cell. Splitting into its own endpoint (mirroring beautiful-chat in the
3-
// langgraph-python reference) lets us set `a2ui.injectA2UITool: false` —
4-
// the backend AG2 agent owns the `generate_a2ui` tool itself, so double-binding
5-
// from the runtime would duplicate the tool slot and confuse the LLM.
6-
//
7-
// Reference:
8-
// - showcase/integrations/langgraph-python/src/app/api/copilotkit-declarative-gen-ui/route.ts
9-
// - src/agents/a2ui_dynamic.py (the AG2 backend)
2+
// cell. Mirrors the working claude-sdk-typescript reference pattern: the
3+
// backend is the default pass-through ConversableAgent, 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.
108

119
import { NextRequest, NextResponse } from "next/server";
1210
import {
@@ -18,23 +16,12 @@ import { HttpAgent } from "@ag-ui/client";
1816

1917
const AGENT_URL = process.env.AGENT_URL || "http://localhost:8000";
2018

21-
const declarativeGenUiAgent = new HttpAgent({
22-
url: `${AGENT_URL}/declarative-gen-ui/`,
23-
});
24-
2519
const runtime = new CopilotRuntime({
2620
// @ts-ignore -- see main route.ts
27-
agents: { "declarative-gen-ui": declarativeGenUiAgent },
28-
a2ui: {
29-
// The backend agent owns `generate_a2ui` explicitly (see
30-
// src/agents/a2ui_dynamic.py), so the runtime MUST NOT auto-inject its
31-
// own A2UI tool on top. The A2UI middleware still runs — it serialises
32-
// the registered client catalog into the agent's `copilotkit.context` so
33-
// the secondary LLM inside `generate_a2ui` knows which components to emit
34-
// — and it still detects the `a2ui_operations` container in the tool
35-
// result and streams rendered surfaces to the frontend.
36-
injectA2UITool: false,
37-
},
21+
agents: { "declarative-gen-ui": new HttpAgent({ url: `${AGENT_URL}/` }) },
22+
// `injectA2UITool` defaults to true — the runtime injects the A2UI tool
23+
// and the default ConversableAgent receives it via AG-UI, matching the
24+
// working claude-sdk-typescript reference pattern.
3825
});
3926

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

showcase/integrations/claude-sdk-python/src/app/api/copilotkit/route.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ const dedicatedAgentPaths: Record<string, string> = {
5757
"reasoning-default-render": "/reasoning",
5858
"tool-rendering-reasoning-chain": "/tool-rendering-reasoning-chain",
5959
"hitl-in-chat": "/hitl-in-chat",
60-
// Interrupt-adapted scheduling agent — both gen-ui-interrupt and
61-
// interrupt-headless share the same backend; only the frontend UX differs
62-
// (inline in chat vs. external popup).
60+
"hitl-in-chat-booking": "/hitl-in-chat",
6361
"gen-ui-interrupt": "/interrupt-adapted",
6462
"interrupt-headless": "/interrupt-adapted",
6563
};

showcase/integrations/claude-sdk-python/src/app/demos/hitl-in-chat/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { TimePickerCard, TimeSlot } from "./time-picker-card";
1212

1313
// @region[time-slots]
1414
const DEFAULT_SLOTS: TimeSlot[] = [
15-
{ label: "Tomorrow 10:00 AM", iso: "2026-04-19T10:00:00-07:00" },
16-
{ label: "Tomorrow 2:00 PM", iso: "2026-04-19T14:00:00-07:00" },
17-
{ label: "Monday 9:00 AM", iso: "2026-04-21T09:00:00-07:00" },
18-
{ label: "Monday 3:30 PM", iso: "2026-04-21T15:30:00-07:00" },
15+
{ label: "Tomorrow 10:00 AM", iso: "2026-04-30T10:00:00-07:00" },
16+
{ label: "Tomorrow 2:00 PM", iso: "2026-04-30T14:00:00-07:00" },
17+
{ label: "Monday 9:00 AM", iso: "2026-05-04T09:00:00-07:00" },
18+
{ label: "Monday 3:30 PM", iso: "2026-05-04T15:30:00-07:00" },
1919
];
2020
// @endregion[time-slots]
2121

showcase/integrations/google-adk/src/app/api/copilotkit-a2ui-fixed-schema/route.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
// Dedicated runtime for the A2UI — Fixed Schema demo. Mirrors
2-
// langgraph-python/src/app/api/copilotkit-a2ui-fixed-schema:
3-
// `a2ui.injectA2UITool: false` because the backend agent's `display_flight`
4-
// tool emits its own `a2ui_operations` container — the runtime should not
5-
// auto-inject a `render_a2ui` tool on top.
1+
// Dedicated runtime for the A2UI — Fixed Schema cell. Splitting into its
2+
// own endpoint lets us set `a2ui.injectA2UITool: false` — the backend ADK
3+
// agent owns the `display_flight` tool which emits its own
4+
// `a2ui_operations` container directly in the tool result.
5+
//
6+
// Reference:
7+
// - showcase/integrations/langgraph-python/src/app/api/copilotkit-a2ui-fixed-schema/route.ts
8+
// - src/agents/a2ui_fixed_agent.py (the ADK backend)
69

710
import { NextRequest, NextResponse } from "next/server";
811
import {
@@ -19,23 +22,33 @@ const a2uiFixedSchemaAgent = new HttpAgent({
1922
});
2023

2124
const runtime = new CopilotRuntime({
22-
// @ts-expect-error -- see main route.ts
25+
// @ts-expect-error -- Published CopilotRuntime agents type wraps Record in
26+
// MaybePromise<NonEmptyRecord<...>> which rejects plain Records;
27+
// fixed in source, pending release.
2328
agents: { "a2ui-fixed-schema": a2uiFixedSchemaAgent },
24-
a2ui: { injectA2UITool: false },
29+
a2ui: {
30+
// The backend agent emits its own `a2ui_operations` container inside
31+
// `display_flight` (see src/agents/a2ui_fixed_agent.py). We still run
32+
// the A2UI middleware so it detects the container in tool results and
33+
// forwards surfaces to the frontend — but we do NOT inject a runtime
34+
// `render_a2ui` tool on top of the agent's existing tools.
35+
injectA2UITool: false,
36+
},
37+
});
38+
39+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
40+
endpoint: "/api/copilotkit-a2ui-fixed-schema",
41+
serviceAdapter: new ExperimentalEmptyAdapter(),
42+
runtime,
2543
});
2644

2745
export const POST = async (req: NextRequest) => {
2846
try {
29-
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
30-
endpoint: "/api/copilotkit-a2ui-fixed-schema",
31-
serviceAdapter: new ExperimentalEmptyAdapter(),
32-
runtime,
33-
});
3447
return await handleRequest(req);
3548
} catch (error: unknown) {
36-
console.error("[copilotkit-a2ui-fixed-schema]", error);
49+
const e = error as { message?: string; stack?: string };
3750
return NextResponse.json(
38-
{ error: "Internal server error" },
51+
{ error: e.message, stack: e.stack },
3952
{ status: 500 },
4053
);
4154
}

showcase/integrations/google-adk/src/app/api/copilotkit-byoc-hashbrown/route.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ const runtime = new CopilotRuntime({
2020
agents: { "byoc-hashbrown-demo": byocHashbrownAgent },
2121
});
2222

23+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
24+
endpoint: "/api/copilotkit-byoc-hashbrown",
25+
serviceAdapter: new ExperimentalEmptyAdapter(),
26+
runtime,
27+
});
28+
2329
export const POST = async (req: NextRequest) => {
2430
try {
25-
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
26-
endpoint: "/api/copilotkit-byoc-hashbrown",
27-
serviceAdapter: new ExperimentalEmptyAdapter(),
28-
runtime,
29-
});
3031
return await handleRequest(req);
3132
} catch (error: unknown) {
32-
console.error("[copilotkit-byoc-hashbrown]", error);
33+
const e = error as { message?: string; stack?: string };
3334
return NextResponse.json(
34-
{ error: "Internal server error" },
35+
{ error: e.message, stack: e.stack },
3536
{ status: 500 },
3637
);
3738
}

showcase/integrations/google-adk/src/app/api/copilotkit-byoc-json-render/route.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ const runtime = new CopilotRuntime({
2222
agents: { "byoc-json-render-demo": byocJsonRenderAgent },
2323
});
2424

25+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
26+
endpoint: "/api/copilotkit-byoc-json-render",
27+
serviceAdapter: new ExperimentalEmptyAdapter(),
28+
runtime,
29+
});
30+
2531
export const POST = async (req: NextRequest) => {
2632
try {
27-
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
28-
endpoint: "/api/copilotkit-byoc-json-render",
29-
serviceAdapter: new ExperimentalEmptyAdapter(),
30-
runtime,
31-
});
3233
return await handleRequest(req);
3334
} catch (error: unknown) {
34-
console.error("[copilotkit-byoc-json-render]", error);
35+
const e = error as { message?: string; stack?: string };
3536
return NextResponse.json(
36-
{ error: "Internal server error" },
37+
{ error: e.message, stack: e.stack },
3738
{ status: 500 },
3839
);
3940
}

showcase/integrations/google-adk/src/app/api/copilotkit-declarative-gen-ui/route.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,19 @@ const runtime = new CopilotRuntime({
3030
a2ui: { injectA2UITool: false },
3131
});
3232

33+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
34+
endpoint: "/api/copilotkit-declarative-gen-ui",
35+
serviceAdapter: new ExperimentalEmptyAdapter(),
36+
runtime,
37+
});
38+
3339
export const POST = async (req: NextRequest) => {
3440
try {
35-
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
36-
endpoint: "/api/copilotkit-declarative-gen-ui",
37-
serviceAdapter: new ExperimentalEmptyAdapter(),
38-
runtime,
39-
});
4041
return await handleRequest(req);
4142
} catch (error: unknown) {
42-
console.error("[copilotkit-declarative-gen-ui]", error);
43+
const e = error as { message?: string; stack?: string };
4344
return NextResponse.json(
44-
{ error: "Internal server error" },
45+
{ error: e.message, stack: e.stack },
4546
{ status: 500 },
4647
);
4748
}

showcase/integrations/google-adk/src/app/api/copilotkit-mcp-apps/route.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ const runtime = new CopilotRuntime({
5151
});
5252
// @endregion[runtime-mcpapps-config]
5353

54+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
55+
endpoint: "/api/copilotkit-mcp-apps",
56+
serviceAdapter: new ExperimentalEmptyAdapter(),
57+
runtime,
58+
});
59+
5460
export const POST = async (req: NextRequest) => {
5561
try {
56-
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
57-
endpoint: "/api/copilotkit-mcp-apps",
58-
serviceAdapter: new ExperimentalEmptyAdapter(),
59-
runtime,
60-
});
6162
return await handleRequest(req);
6263
} catch (error: unknown) {
6364
const e = error as { message?: string; stack?: string };

showcase/integrations/google-adk/src/app/api/copilotkit-ogui/route.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@ const runtime = new CopilotRuntime({
3434
// @endregion[advanced-runtime-config]
3535
// @endregion[minimal-runtime-flag]
3636

37+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
38+
endpoint: "/api/copilotkit-ogui",
39+
serviceAdapter: new ExperimentalEmptyAdapter(),
40+
runtime,
41+
});
42+
3743
export const POST = async (req: NextRequest) => {
3844
try {
39-
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
40-
endpoint: "/api/copilotkit-ogui",
41-
serviceAdapter: new ExperimentalEmptyAdapter(),
42-
runtime,
43-
});
4445
return await handleRequest(req);
4546
} catch (error: unknown) {
46-
console.error("[copilotkit-ogui]", error);
47+
const e = error as { message?: string; stack?: string };
4748
return NextResponse.json(
48-
{ error: "Internal server error" },
49+
{ error: e.message, stack: e.stack },
4950
{ status: 500 },
5051
);
5152
}

0 commit comments

Comments
 (0)