Skip to content

Conversation

@safina57
Copy link
Contributor

@safina57 safina57 commented Oct 19, 2025

Closes #3098

Heyy @DouweM, Hope ur're doing well

I have started working on the integrating of OpenAI's ChatKit framework with Pydantic AI.

ChatKit operates differently from other UI protocols in several key ways:

Unlike simple request-response patterns, ChatKit works with persistent threads where each conversation is considered a sequence of different thread items (user messages, assistant messages, tool calls, widgets, etc.).

It supports advanced UI elements beyond text:

  • Widgets: Interactive components with real-time updates
  • Progress Updates: Live feedback during agent reasoning

It also already provides comprehensive TypeScript definitions on the frontend and Python types in their official library, which I'm leveraging for type safety.

I've started implementing the adapter by importing types directly from the official chatkit Python library:

The core adapter structure follows Pydantic AI's BaseAdapter pattern but with ChatKit-specific considerations:

  • Request validation: Handles multiple ChatKit request formats
  • Message conversion: Transforms ChatKit's thread items to Pydantic AI's ModelMessage format (currently in progress)

Before continuing the implementation, I have some questions about the desired scope and approach:

1. Session Management Responsibility

Since we're making Pydantic AI agents ChatKit-protocol compatible, who should handle session management?

Option A: Full ChatKit Backend Implementation

  • Implement our own version of ChatKit's ChatKitServer
  • Manage conversation persistence
  • Provide full API compatibility

Option B: Adapter-Only Approach

  • Focus solely on protocol translation (ChatKit ↔ Pydantic AI)
  • Leave session management to the user

2. Memory Store Integration

ChatKit's server implementation includes a MemoryStore interface for persisting conversations. Should we:

Option A: Provide ChatKit-Compatible Memory Store

Option B: Custom State Management

  • Let users implement their own persistence layer

3. Protocol Compatibility Level

How closely should we follow ChatKit's backend implementation?

  • Full Compatibility: Implement all ChatKit behaviors
  • Minimal: Basic request/response translation

I would greatly appreciate your advice on the best path forward and on which specific ChatKit features or behaviors we should prioritize

Thanks in advance ^^!

@safina57 safina57 changed the base branch from main to vercel-ai-chat October 19, 2025 20:31
@DouweM
Copy link
Collaborator

DouweM commented Oct 21, 2025

@safina57 I may have to dive deeper into ChatKit to see exactly how it differs from AG-UI and Vercel AI when it comes to persistence and extra features like widgets. But I'm inclined to say that anything to do with persistence is out of scope, and up to the user. Would the user be able to store the regular list of ModelRequest | ModelResponse messages, or does it need to be some ChatKit-specific representation with additional (meta)data?

I'd like to be able to support all ChatKit features, if feasible. How are things like widget and progress implemented? Just by streaming custom events to the frontend? Would that work with #2382 / #3114?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants