Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ export const globalSettingsSchema = z.object({
* Tools in this list will be excluded from prompt generation and rejected at execution time.
*/
disabledTools: z.array(toolNamesSchema).optional(),

/**
* Whether to enable programmatic tool calling.
* When enabled, supported models can generate Python code that calls multiple tools
* within a single sandboxed code execution, reducing round-trips to the model.
* Tools still require individual approval before execution.
* @default false
*/
enableProgrammaticToolCalling: z.boolean().optional(),
})

export type GlobalSettings = z.infer<typeof globalSettingsSchema>
Expand Down
7 changes: 7 additions & 0 deletions packages/types/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ export const modelInfoSchema = z.object({
// These tools will be added if they belong to an allowed group in the current mode
// Cannot force-add tools from groups the mode doesn't allow
includedTools: z.array(z.string()).optional(),
/**
* Whether the model supports programmatic tool calling.
* When true, the model can generate Python code that calls tool functions,
* enabling multiple tool calls within a single code execution in a sandbox.
* Currently supported by Anthropic Claude models.
*/
supportsProgrammaticToolCalling: z.boolean().optional(),
/**
* Service tiers with pricing information.
* Each tier can have a name (for OpenAI service tiers) and pricing overrides.
Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const anthropicModels = {
cacheWritesPrice: 3.75, // $3.75 per million tokens
cacheReadsPrice: 0.3, // $0.30 per million tokens
supportsReasoningBudget: true,
supportsProgrammaticToolCalling: true,
// Tiered pricing for extended context (requires beta flag 'context-1m-2025-08-07')
tiers: [
{
Expand All @@ -38,6 +39,7 @@ export const anthropicModels = {
cacheWritesPrice: 3.75, // $3.75 per million tokens
cacheReadsPrice: 0.3, // $0.30 per million tokens
supportsReasoningBudget: true,
supportsProgrammaticToolCalling: true,
// Tiered pricing for extended context (requires beta flag 'context-1m-2025-08-07')
tiers: [
{
Expand All @@ -59,6 +61,7 @@ export const anthropicModels = {
cacheWritesPrice: 6.25, // $6.25 per million tokens
cacheReadsPrice: 0.5, // $0.50 per million tokens
supportsReasoningBudget: true,
supportsProgrammaticToolCalling: true,
// Tiered pricing for extended context (requires beta flag)
tiers: [
{
Expand All @@ -80,6 +83,7 @@ export const anthropicModels = {
cacheWritesPrice: 6.25, // $6.25 per million tokens
cacheReadsPrice: 0.5, // $0.50 per million tokens
supportsReasoningBudget: true,
supportsProgrammaticToolCalling: true,
},
"claude-opus-4-1-20250805": {
maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false.
Expand All @@ -91,6 +95,7 @@ export const anthropicModels = {
cacheWritesPrice: 18.75, // $18.75 per million tokens
cacheReadsPrice: 1.5, // $1.50 per million tokens
supportsReasoningBudget: true,
supportsProgrammaticToolCalling: true,
},
"claude-opus-4-20250514": {
maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false.
Expand All @@ -102,6 +107,7 @@ export const anthropicModels = {
cacheWritesPrice: 18.75, // $18.75 per million tokens
cacheReadsPrice: 1.5, // $1.50 per million tokens
supportsReasoningBudget: true,
supportsProgrammaticToolCalling: true,
},
"claude-3-7-sonnet-20250219:thinking": {
maxTokens: 128_000, // Unlocked by passing `beta` flag to the model. Otherwise, it's 64k.
Expand Down
14 changes: 14 additions & 0 deletions src/api/transform/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type ApiStreamChunk =
| ApiStreamToolCallDeltaChunk
| ApiStreamToolCallEndChunk
| ApiStreamToolCallPartialChunk
| ApiStreamCodeExecutionChunk
| ApiStreamError

export interface ApiStreamError {
Expand Down Expand Up @@ -107,6 +108,19 @@ export interface ApiStreamToolCallPartialChunk {
arguments?: string
}

/**
* Code execution chunk from programmatic tool calling.
* The model generates Python code that calls tool functions in a sandboxed environment.
* This chunk contains the code to execute and, once executed, the results.
*/
export interface ApiStreamCodeExecutionChunk {
type: "code_execution"
/** Unique identifier for this code execution block */
id: string
/** The Python code generated by the model */
code: string
}

export interface GroundingSource {
title: string
url: string
Expand Down
Loading
Loading