@corti/ai-sdk-adapter package provides utilities to connect Corti’s A2A (Agent-to-Agent) agents with the Vercel AI SDK. It converts between AI SDK’s UI message format and Corti’s A2A format, so you can use familiar patterns like useChat to build chat interfaces powered by Corti agents.
Package: @corti/ai-sdk-adapter on npm | Source: GitHub
convertToParams()— convertsCortiUIMessage[]to A2AMessageSendParamstoUIMessageStream()— converts an A2A stream to a UI message streamcreateA2AClientFactory()— creates an A2A client factory configured with Corti authentication
Installation
Quick start
Server: streaming API route (Next.js)
Create an API route that receives messages from the client, converts them to A2A format, streams the response from a Corti agent, and returns a UI message stream.app/api/chat/route.ts
Client: React chat component
Use the Vercel AI SDKuseChat hook with the CortiUIMessage type to render agent responses.
app/chat.tsx
How it works
Context and task continuity
The adapter automatically manages conversation context and task continuity:contextId— maintains conversation context across multiple messages. Automatically inferred from the last assistant message.taskId— continues an existing task when the agent requires more input. Only included when the last assistant message hasstate: 'input-required'.- Credentials — only sent on the first message (when no
taskIdis present).
convertToParams() function handles all of this automatically — you just pass the messages array from useChat.
Stream callbacks
ThetoUIMessageStream() function accepts a StreamConversionOptions object with optional callbacks to monitor stream progress:
Runtime support
This package supports:- Node.js (18+)
- Edge runtimes (Vercel Edge, Cloudflare Workers)