From bf29af30831d0c7bc3b11d3dbd60cad1d27f510d Mon Sep 17 00:00:00 2001 From: Ramnique Singh <30795890+ramnique@users.noreply.github.com> Date: Thu, 14 Aug 2025 21:15:56 +0530 Subject: [PATCH] use strict compatibility in createOpenAI When using createOpenAI() from @ai-sdk/openai w/o provider override, token usage info is sent as 0 or null. Enforcing compatibilty fixes this. --- apps/rowboat/app/lib/agents.ts | 5 +++-- apps/rowboat/app/lib/copilot/copilot.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/rowboat/app/lib/agents.ts b/apps/rowboat/app/lib/agents.ts index fafcd588..54b5b416 100644 --- a/apps/rowboat/app/lib/agents.ts +++ b/apps/rowboat/app/lib/agents.ts @@ -1,5 +1,5 @@ // External dependencies -import { Agent, AgentInputItem, run, Tool } from "@openai/agents"; +import { Agent, AgentInputItem, run, RunRawModelStreamEvent, Tool } from "@openai/agents"; import { RECOMMENDED_PROMPT_PREFIX } from "@openai/agents-core/extensions"; import { aisdk } from "@openai/agents-extensions"; import { createOpenAI } from "@ai-sdk/openai"; @@ -78,6 +78,7 @@ interface AgentState { const openai = createOpenAI({ apiKey: PROVIDER_API_KEY, baseURL: PROVIDER_BASE_URL, + compatibility: "strict", }); const ZOutMessage = z.union([ @@ -734,7 +735,7 @@ function maybeInjectGiveUpControlInstructions( // Handle raw model stream events async function* handleRawModelStreamEvent( - event: any, + event: RunRawModelStreamEvent, agentConfig: Record>, agentName: string, turnMsgs: z.infer[], diff --git a/apps/rowboat/app/lib/copilot/copilot.ts b/apps/rowboat/app/lib/copilot/copilot.ts index 80984874..e729caf5 100644 --- a/apps/rowboat/app/lib/copilot/copilot.ts +++ b/apps/rowboat/app/lib/copilot/copilot.ts @@ -34,6 +34,7 @@ const SYSTEM_PROMPT = [ const openai = createOpenAI({ apiKey: PROVIDER_API_KEY, baseURL: PROVIDER_BASE_URL, + compatibility: "strict", }); const ZTextEvent = z.object({