Skip to content

Commit ac91d78

Browse files
authored
fix(anthropic): use anthropic sdk to transform malformed response schemas to anthropic format (#2988)
* fix(anthropic): use anthropic sdk to transform malformed response schemas to anthropic format * copy internal transformJSONSchema from anthropic * remove dep update * use built-in func from anthropic
1 parent 6f0a093 commit ac91d78

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

apps/sim/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"@a2a-js/sdk": "0.3.7",
27-
"@anthropic-ai/sdk": "^0.39.0",
27+
"@anthropic-ai/sdk": "0.71.2",
2828
"@aws-sdk/client-bedrock-runtime": "3.940.0",
2929
"@aws-sdk/client-dynamodb": "3.940.0",
3030
"@aws-sdk/client-rds-data": "3.940.0",

apps/sim/providers/anthropic/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Anthropic from '@anthropic-ai/sdk'
2+
import { transformJSONSchema } from '@anthropic-ai/sdk/lib/transform-json-schema'
23
import { createLogger } from '@sim/logger'
34
import type { StreamingExecution } from '@/executor/types'
45
import { MAX_TOOL_ITERATIONS } from '@/providers'
@@ -185,13 +186,10 @@ export const anthropicProvider: ProviderConfig = {
185186
const schema = request.responseFormat.schema || request.responseFormat
186187

187188
if (useNativeStructuredOutputs) {
188-
const schemaWithConstraints = {
189-
...schema,
190-
additionalProperties: false,
191-
}
189+
const transformedSchema = transformJSONSchema(schema)
192190
payload.output_format = {
193191
type: 'json_schema',
194-
schema: schemaWithConstraints,
192+
schema: transformedSchema,
195193
}
196194
logger.info(`Using native structured outputs for model: ${modelId}`)
197195
} else {

bun.lock

Lines changed: 22 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)