Skip to content

Commit fd8c0d0

Browse files
waleedlatif1claude
andauthored
feat(providers): make the agent tool-call ceiling configurable (#7430)
* feat(providers): make the agent tool-call ceiling configurable MAX_TOOL_ITERATIONS is now read from an env var of the same name and defaults to 20, so self-hosted deployments can raise the agent tool loop without a custom build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lm2sCA6iswCvNT33eNRrix * chore(helm): bump chart version for the new env-var default Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lm2sCA6iswCvNT33eNRrix --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8ee3abf commit fd8c0d0

6 files changed

Lines changed: 27 additions & 2 deletions

File tree

apps/docs/content/docs/platform/self-hosting/environment-variables.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ import { Callout } from 'fumadocs-ui/components/callout'
6363
In Docker, use `OLLAMA_URL=http://host.docker.internal:11434` for host-machine Ollama.
6464
</Callout>
6565

66+
<Callout type="info">
67+
**Agent tool-call depth.** An Agent block ends its run after 20 model round trips of tool calling. Raise the ceiling with `MAX_TOOL_ITERATIONS` (for example `MAX_TOOL_ITERATIONS=50`). Every extra iteration is another model call, so raise it deliberately.
68+
</Callout>
69+
6670
### AWS Bedrock
6771

6872
| Variable | Description |

apps/sim/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,7 @@ CRON_SECRET=your_cron_secret # Use `openssl rand -hex 32` to generate. Authentic
227227
# TABLE_DISPATCH_CONCURRENCY_FREE=20 # Rows one table run executes in parallel on free tier
228228
# TABLE_DISPATCH_CONCURRENCY_PAID=50 # Rows one table run executes in parallel on paid tiers (billing disabled uses this)
229229
# FREE_STORAGE_LIMIT_GB=5 # File storage quota in GB
230+
231+
# Agent tool-call loop (Optional). Model round trips one Agent block takes before it
232+
# must answer. Defaults to 20; raise it for agents that chain many tool calls.
233+
# MAX_TOOL_ITERATIONS=20

apps/sim/lib/core/config/env.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ export const env = createEnv({
416416
EXECUTION_TIMEOUT_ASYNC_TEAM: z.string().optional().default('5400'), // 90 minutes
417417
EXECUTION_TIMEOUT_ASYNC_ENTERPRISE: z.string().optional().default('5400'), // 90 minutes
418418

419+
// Agent Tool-Call Loop
420+
MAX_TOOL_ITERATIONS: z.string().optional(), // Max model round trips per Agent block tool-call loop (default 20)
421+
419422
// Isolated-VM Worker Pool Configuration
420423
IVM_POOL_SIZE: z.string().optional().default('4'), // Max worker processes in pool
421424
IVM_MAX_CONCURRENT: z.string().optional().default('10000'), // Max concurrent executions globally

apps/sim/providers/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createLogger } from '@sim/logger'
22
import { toError } from '@sim/utils/errors'
33
import { getApiKeyWithBYOK } from '@/lib/api-key/byok'
4+
import { env, envNumber } from '@/lib/core/config/env'
45
import { filterModelSafeWorkspaceFileAttachments } from '@/lib/uploads/contexts/workspace/workspace-file-secret-provenance'
56
import type { StreamingExecution } from '@/executor/types'
67
import {
@@ -76,11 +77,21 @@ async function omitUnsafeProviderFileAttachments(
7677
}
7778
}
7879

80+
/** Round trips an Agent block's tool loop takes before it is forced to answer. */
81+
const DEFAULT_MAX_TOOL_ITERATIONS = 20
82+
7983
/**
8084
* Maximum number of iterations for tool call loops to prevent infinite loops.
8185
* Used across all providers that support tool/function calling.
86+
*
87+
* Self-hosted deployments that need longer agent runs raise it with the
88+
* `MAX_TOOL_ITERATIONS` env var; a value that is not a positive integer falls
89+
* back to {@link DEFAULT_MAX_TOOL_ITERATIONS}.
8290
*/
83-
export const MAX_TOOL_ITERATIONS = 20
91+
export const MAX_TOOL_ITERATIONS = envNumber(env.MAX_TOOL_ITERATIONS, DEFAULT_MAX_TOOL_ITERATIONS, {
92+
min: 1,
93+
integer: true,
94+
})
8495

8596
/**
8697
* Normalizes a model-tuning level that may have arrived from a variable or block reference

helm/sim/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: sim
33
description: A Helm chart for Sim - the open-source AI workspace where teams build, deploy, and manage AI agents
44
type: application
5-
version: 1.8.0
5+
version: 1.8.1
66
appVersion: "v0.8.18"
77
kubeVersion: ">=1.25.0-0"
88
home: https://sim.ai

helm/sim/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ app:
400400
EXECUTION_TIMEOUT_ASYNC_TEAM: "5400" # Team tier async timeout (90 minutes)
401401
EXECUTION_TIMEOUT_ASYNC_ENTERPRISE: "5400" # Enterprise tier async timeout (90 minutes)
402402

403+
# Agent tool-call loop
404+
# MAX_TOOL_ITERATIONS: "20" # Model round trips per Agent block tool-call loop
405+
403406
# Table Feature Limits (per workspace, per plan)
404407
# FREE_TABLES_LIMIT: "3" # Opt-in; unset means no cap on a self-host
405408
# FREE_TABLE_ROWS_LIMIT: "1000" # Opt-in; unset means no cap on a self-host

0 commit comments

Comments
 (0)