Skip to content

Commit 4652def

Browse files
committed
fix(shell-docs): replace ... placeholder + add missing handler in a2a route.ts snippet
Section 3 "Configure the A2A middleware" had a literal ... ellipsis where the imports should go, and the code block ended at runtime definition with no POST handler — pasted code would not compile. Add the imports the block actually uses (HttpAgent, A2AMiddlewareAgent, CopilotRuntime, ExperimentalEmptyAdapter, copilotRuntimeNextJSAppRouterEndpoint, NextRequest) and the canonical Next.js App Router POST handler that hands requests to the runtime. Pattern matches the ms-agent-framework quickstart route.ts.
1 parent 8789210 commit 4652def

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

  • showcase/shell-docs/src/content/docs/agentic-protocols

showcase/shell-docs/src/content/docs/agentic-protocols/a2a.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ To use A2A agents with CopilotKit, you need to first install the CopilotKit midd
7474
<Step>
7575
### Configure the A2A middleware
7676
```tsx title="app/api/copilotkit/route.ts"
77-
78-
...
77+
import {
78+
CopilotRuntime,
79+
ExperimentalEmptyAdapter,
80+
copilotRuntimeNextJSAppRouterEndpoint,
81+
} from "@copilotkit/runtime";
82+
import { HttpAgent } from "@ag-ui/client";
83+
import { A2AMiddlewareAgent } from "@ag-ui/a2a-middleware";
84+
import { NextRequest } from "next/server";
7985

8086
// These first two are the urls to the a2a agents
8187
const researchAgentUrl = process.env.RESEARCH_AGENT_URL || "http://localhost:9001";
@@ -140,7 +146,17 @@ To use A2A agents with CopilotKit, you need to first install the CopilotKit midd
140146
},
141147
});
142148

149+
// Standard Next.js App Router handler that hands requests to the runtime.
150+
const serviceAdapter = new ExperimentalEmptyAdapter();
143151

152+
export const POST = async (req: NextRequest) => {
153+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
154+
runtime,
155+
serviceAdapter,
156+
endpoint: "/api/copilotkit",
157+
});
158+
return handleRequest(req);
159+
};
144160
```
145161

146162
</Step>

0 commit comments

Comments
 (0)