Skip to content

Commit ade82d4

Browse files
committed
fix(providers): drop the provider ceiling changes and close the audit findings
A six-agent line-by-line audit against the vendors' live docs found the `models.ts` ceiling work was not the strict improvement it was written as, so all of it is reverted: - bedrock's 4.5 MB cap broke video. Converse takes image, document AND video blocks, and video is allowed 25 MB base64 — a single `maxBytes` cannot express three content classes, and every 4.5-10 MiB `.mp4` that works today would have started failing. - openai's combined 50 MB cap is the FILE-input limit. Image inputs are governed separately at 512 MB / 1500 images, so summing every attachment rejected eight 8 MB PNGs that OpenAI documents as legal. - fireworks' per-file ceiling was unreachable behind the request budget, while the upload picker went on advertising it — a size the UI accepts and execution always rejects. - The whole `perRequestMaxBytes` feature goes with them: it summed raw bytes against caps that are variously on encoded bytes, on one content class, or on a body that carries only URLs, and it double-counted a file referenced from several messages even though the uploader dedupes by key. Only openai's per-file `maxBytes` stays corrected, to decimal 50,000,000 — the one number a vendor states unambiguously and writes no MiB against. Also fixed, all found by the same audit: The hydration cap stopped short of where `remote-url` actually switches over, so 6-10 MiB attachments on anthropic/openrouter/xai/groq/together/baseten/vllm had neither base64 nor a handle and failed outright — the very band this branch exists to fix. Both decisions now come from one function so they cannot drift. Eight more sites where the mechanical rewrite computed a filtered array and then read the unfiltered one (deepseek, sakana, nvidia, kimi), leaving those providers without the narrowing they appear to have. `isFunctionToolCall` threw on a null or primitive `tool_calls` entry, because `in` requires an object — reachable exactly on the self-hosted gateways this filter was added for. It is now total, and all 32 test mocks match it rather than being quietly more permissive. `checkForForcedToolUsage` in utils/litellm/mistral evaluated the response before the `tool_choice` test, turning a tolerated malformed body into a TypeError on a path that never used to touch it. Gemini: `satisfies` restores the excess-property checking the dropped annotations removed, the poll loop recognises the terminal statuses v2 added instead of spinning for an hour and reporting a timeout, and the streaming doc block no longer names five events that were renamed six lines below it.
1 parent 7790d30 commit ade82d4

47 files changed

Lines changed: 169 additions & 205 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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ vi.mock('@/lib/tokenization/estimators', () => ({
4444
}))
4545

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const {
1717
}))
1818

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const {
1919
}))
2020

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const {
1919
}))
2020

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

apps/sim/blocks/utils.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ vi.mock('@/providers/models', () => ({
4545
}))
4646

4747
vi.mock('@/providers/utils', () => ({
48-
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
48+
isFunctionToolCall: (toolCall: unknown) =>
49+
typeof toolCall === 'object' && toolCall !== null && 'function' in toolCall,
4950
getProviderFromModel: vi.fn(() => 'openai'),
5051
}))
5152

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

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

6868
vi.mock('@/providers/utils', () => ({
69-
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
69+
isFunctionToolCall: (toolCall: unknown) =>
70+
typeof toolCall === 'object' && toolCall !== null && 'function' in toolCall,
7071
getProviderFromModel: mockGetProviderFromModel,
7172
}))
7273

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ 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,
33+
isFunctionToolCall: (toolCall: unknown) =>
34+
typeof toolCall === 'object' && toolCall !== null && 'function' in toolCall,
3435
getProviderFromModel: vi.fn().mockReturnValue('mock-provider'),
3536
transformBlockTool: vi.fn(),
3637
getBaseModelProviders: vi.fn().mockReturnValue({ openai: {}, anthropic: {} }),

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ import { buildAPIUrl, buildAuthHeaders } from '@/executor/utils/http'
5252
import { stringifyJSON } from '@/executor/utils/json'
5353
import { resolveVertexCredential } from '@/executor/utils/vertex-credential'
5454
import { executeProviderRequest } from '@/providers'
55+
import { shouldUseLargeFilePath, supportsFileAttachments } from '@/providers/attachments'
5556
import {
56-
INLINE_ATTACHMENT_THRESHOLD_BYTES,
57-
LARGE_FILE_PATH_THRESHOLD_BYTES,
58-
shouldUseLargeFilePath,
59-
supportsFileAttachments,
60-
} from '@/providers/attachments'
61-
import { canUseProviderLargeFilePath } from '@/providers/file-attachments.server'
57+
canUseProviderLargeFilePath,
58+
getInlineHydrationMaxBytes,
59+
} from '@/providers/file-attachments.server'
6260
import { isAutoModel, SIM_AUTO_MODEL_ID } from '@/providers/models'
6361
import { getProviderFromModel, transformBlockTool } from '@/providers/utils'
6462
import type { SerializedBlock } from '@/serializer/types'
@@ -948,14 +946,7 @@ export class AgentBlockHandler implements BlockHandler {
948946
const requestId = ctx.executionId || ctx.workflowId || 'agent-files'
949947
const nextMessages = [...messages]
950948

951-
/**
952-
* Stop hydrating base64 early only where an upload can actually take over. Where it cannot —
953-
* an inline-only provider, or any deployment without cloud storage — base64 stays the only
954-
* delivery path, so it has to be hydrated all the way to the inline ceiling.
955-
*/
956-
const inlineMaxBytes = canUseProviderLargeFilePath(providerId)
957-
? LARGE_FILE_PATH_THRESHOLD_BYTES
958-
: INLINE_ATTACHMENT_THRESHOLD_BYTES
949+
const inlineMaxBytes = getInlineHydrationMaxBytes(providerId)
959950

960951
for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
961952
const message = messages[messageIndex]

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ vi.mock('@/lib/api-key/byok', () => ({
1818
getBYOKKey: mockGetBYOKKey,
1919
}))
2020
vi.mock('@/providers/utils', () => ({
21-
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
21+
isFunctionToolCall: (toolCall: unknown) =>
22+
typeof toolCall === 'object' && toolCall !== null && 'function' in toolCall,
2223
calculateCost: mockCalculateCost,
2324
shouldBillModelUsage: mockShouldBill,
2425
}))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ vi.mock('@/providers/pi-providers', () => ({
7777
resolvePiModelId: mockResolvePiModelId,
7878
}))
7979
vi.mock('@/providers/utils', () => ({
80-
isFunctionToolCall: (toolCall: { function?: unknown }) => toolCall?.function != null,
80+
isFunctionToolCall: (toolCall: unknown) =>
81+
typeof toolCall === 'object' && toolCall !== null && 'function' in toolCall,
8182
getProviderFromModel: mockGetProviderFromModel,
8283
}))
8384
vi.mock('@/blocks/utils', () => ({

0 commit comments

Comments
 (0)