Skip to content

Commit 0359798

Browse files
committed
feat: allow tool_call to be object for granular capabilities
- Update schema to accept boolean OR object for tool_call - Add streaming, parallel, and coerces_types optional fields - Update meta.llama3-3-70b-instruct-v1:0 as example - Documents Bedrock streaming limitation and type coercion Default semantics (do the least harm): - streaming: undefined → true (matches current tool_call=true assumption) - parallel: undefined → false (safer, not universally supported) - coerces_types: undefined → false (most models work correctly) Addresses provider-specific tool calling limitations: - Streaming incompatibility (AWS Bedrock non-Anthropic models) - Type coercion issues (Bedrock integer handling) - Parallel tool calling tracking (addresses #202) Evidence: - AWS re:Post: streaming errors, integer coercion - langchain-aws #140, #354: streaming validation issues - pydantic-ai #1649: response format problems - req_llm: agentjido/req_llm#163 100% backward compatible at TOML level - existing tool_call = true/false still valid
1 parent 8379242 commit 0359798

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

packages/core/src/schema.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,21 @@ export const Model = z
77
attachment: z.boolean(),
88
reasoning: z.boolean(),
99
temperature: z.boolean(),
10-
tool_call: z.boolean(),
10+
tool_call: z
11+
.union([
12+
z.boolean(),
13+
z
14+
.object({
15+
supported: z.boolean(),
16+
streaming: z.boolean().optional(),
17+
parallel: z.boolean().optional(),
18+
coerces_types: z.boolean().optional(),
19+
})
20+
.strict(),
21+
])
22+
.describe(
23+
"Supports tool calling. Can be a boolean or an object for granular capabilities.",
24+
),
1125
knowledge: z
1226
.string()
1327
.regex(/^\d{4}-\d{2}(-\d{2})?$/, {
@@ -71,7 +85,7 @@ export const Model = z
7185
{
7286
message: "Cannot set cost.reasoning when reasoning is false",
7387
path: ["cost", "reasoning"],
74-
}
88+
},
7589
);
7690

7791
export type Model = z.infer<typeof Model>;
@@ -87,7 +101,7 @@ export const Provider = z
87101
.string()
88102
.min(
89103
1,
90-
"Please provide a link to the provider documentation where models are listed"
104+
"Please provide a link to the provider documentation where models are listed",
91105
),
92106
models: z.record(Model),
93107
})
@@ -103,6 +117,6 @@ export const Provider = z
103117
message:
104118
"'api' field is required if and only if npm is '@ai-sdk/openai-compatible'",
105119
path: ["api"],
106-
}
120+
},
107121
);
108122
export type Provider = z.infer<typeof Provider>;

providers/amazon-bedrock/models/meta.llama3-3-70b-instruct-v1:0.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ attachment = false
55
reasoning = false
66
temperature = true
77
knowledge = "2023-12"
8-
tool_call = true
98
open_weights = true
109

10+
[tool_call]
11+
supported = true
12+
streaming = false
13+
coerces_types = true
14+
1115
[cost]
1216
input = 0.72
1317
output = 0.72

0 commit comments

Comments
 (0)