Skip to content

Commit 3786320

Browse files
committed
chore(deps): upgrade openai to 7.0.0
v5 is the only major with real breaking changes for us; v6 widened a Responses output type and v7 only raised the Node floor to 22, which apps/sim already requires. Three things needed fixing: `ChatCompletionMessageToolCall` became a union of function and custom tool calls, and the custom variant has no `function` field — 43 unguarded `.function` accesses across the OpenAI-compatible providers. Narrow once at each `message.tool_calls` read through a shared `isFunctionToolCall` guard rather than casting at every use. That guard deliberately tests for the `function` payload instead of `type === 'function'`. Many OpenAI-compatible vendors omit `type` on tool calls entirely — our own fixtures do — so discriminating on it type-checks perfectly and then silently drops every tool call those providers return. `ChatCompletionCreateParams.verbosity` narrowed from `string` to a literal union, and the Responses API's output and input item unions now diverge on members Sim never emits (computer-use call outputs, whose `status` admits `failed`, and the `AdditionalTools` escape hatch). Echoing output back as input is what a tool loop is supposed to do, so that conversion is asserted once in convertResponseOutputToInputItems and the streaming loop now routes through it instead of pushing raw output items. The hand-rolled multipart upload in file-attachments.server.ts can now be replaced with the SDK's typed `expires_after` — left for a follow-up so this commit stays a pure upgrade.
1 parent 8549328 commit 3786320

56 files changed

Lines changed: 223 additions & 96 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/sim/app/api/knowledge/search/route.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ vi.mock('@/lib/tokenization/estimators', () => ({
4444
}))
4545

4646
vi.mock('@/providers/utils', () => ({
47+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
4748
calculateCost: vi.fn().mockReturnValue({
4849
input: 0.00001042,
4950
output: 0,

apps/sim/app/api/providers/baseten/models/route.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const {
1717
}))
1818

1919
vi.mock('@/providers/utils', () => ({
20+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
2021
filterBlacklistedModels: mockFilterBlacklistedModels,
2122
isProviderBlacklisted: mockIsProviderBlacklisted,
2223
}))

apps/sim/app/api/providers/ollama-cloud/models/route.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const {
1919
}))
2020

2121
vi.mock('@/providers/utils', () => ({
22+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
2223
filterBlacklistedModels: mockFilterBlacklistedModels,
2324
isProviderBlacklisted: mockIsProviderBlacklisted,
2425
}))

apps/sim/app/api/providers/together/models/route.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const {
1919
}))
2020

2121
vi.mock('@/providers/utils', () => ({
22+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
2223
filterBlacklistedModels: mockFilterBlacklistedModels,
2324
isProviderBlacklisted: mockIsProviderBlacklisted,
2425
}))

apps/sim/blocks/utils.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ vi.mock('@/providers/models', () => ({
4545
}))
4646

4747
vi.mock('@/providers/utils', () => ({
48+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
4849
getProviderFromModel: vi.fn(() => 'openai'),
4950
}))
5051

apps/sim/ee/access-control/utils/permission-check.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ vi.mock('@/lib/permission-groups/types', () => ({
6666
}))
6767

6868
vi.mock('@/providers/utils', () => ({
69+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
6970
getProviderFromModel: mockGetProviderFromModel,
7071
}))
7172

apps/sim/executor/handlers/agent/agent-handler.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { executeTool } from '@/tools'
3030
process.env.NEXT_PUBLIC_APP_URL = 'http://localhost:3000'
3131

3232
vi.mock('@/providers/utils', () => ({
33+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
3334
getProviderFromModel: vi.fn().mockReturnValue('mock-provider'),
3435
transformBlockTool: vi.fn(),
3536
getBaseModelProviders: vi.fn().mockReturnValue({ openai: {}, anthropic: {} }),

apps/sim/executor/handlers/pi/keys.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ vi.mock('@/lib/api-key/byok', () => ({
1818
getBYOKKey: mockGetBYOKKey,
1919
}))
2020
vi.mock('@/providers/utils', () => ({
21+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
2122
calculateCost: mockCalculateCost,
2223
shouldBillModelUsage: mockShouldBill,
2324
}))

apps/sim/executor/handlers/pi/pi-handler.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ vi.mock('@/providers/pi-providers', () => ({
7777
resolvePiModelId: mockResolvePiModelId,
7878
}))
7979
vi.mock('@/providers/utils', () => ({
80+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
8081
getProviderFromModel: mockGetProviderFromModel,
8182
}))
8283
vi.mock('@/blocks/utils', () => ({

apps/sim/lib/api-key/byok.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ vi.mock('@/providers/models', () => ({
4242
}))
4343

4444
vi.mock('@/providers/utils', () => ({
45+
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
4546
PROVIDER_PLACEHOLDER_KEY: 'placeholder',
4647
}))
4748

0 commit comments

Comments
 (0)