Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-jsonschema-init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/ai-chat": patch
---

Fix jsonSchema not initialized error when calling getAITools() in onChatMessage
3 changes: 3 additions & 0 deletions packages/ai-chat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ export class AIChatAgent<
// Wrap onMessage
const _onMessage = this.onMessage.bind(this);
this.onMessage = async (connection: Connection, message: WSMessage) => {
// Ensure jsonSchema is initialized for getAITools() (matches base Agent pattern)
await this.mcp.ensureJsonSchema();

// Handle AIChatAgent's internal messages first
if (typeof message === "string") {
let data: IncomingMessage;
Expand Down
Loading