Tool Config

Govern how a single tool call runs: timeout, retries, output limits.

toolConfig governs how each tool call runs — a timeout, a retry policy, output truncation, and where unknown tool names are resolved.

Diagram
graph LR
    C[🔧 tool call] --> T{timeout?}
    T -->|exceeded| F[⏱️ timed out after Ns]
    T -->|ok| R{retry policy?}
    R -->|error| B[🔁 backoff & retry]
    R -->|success| O[✂️ truncate output]

    classDef call fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef step fill:#189AB4,stroke:#7C90A0,color:#fff

    class C call
    class T,R,B,O,F step

Quick Start

  1. Cap a tool and retry it
    typescript
    import { Agent } from 'praisonai';
    
    const agent = new Agent({
      instructions: 'Use tools',
      tools: [search],
      toolConfig: {
        timeout: 10,
        retryPolicy: { maxAttempts: 3, initialDelay: 1, backoffFactor: 2, maxDelay: 30 },
      },
    });
  2. Use the defaults
    typescript
    const agent = new Agent({ instructions: 'x', tools: [search], toolConfig: true });

Fields

FieldTypeDefaultEffect
timeoutnumbernoneSeconds a tool may run. On exceed the tool result is Tool "<name>" timed out after Ns.
retryPolicy{ maxAttempts, initialDelay, backoffFactor, maxDelay }noneExponential backoff between attempts. Defaults: 3 / 1 / 2 / 30.
outputLimitnumber16000Maximum bytes of tool output kept; extra is dropped with [... N bytes truncated ...].
outputDirection`’head’ \‘tail’ \‘both’`'both'Which end(s) survive truncation.
allowGlobalToolsbooleanfalseResolve a tool name missing from the agent’s tools via the process-global registry (lazily loaded).
parallelbooleannot setRun a round’s tool calls concurrently. Forwarded as parallel_tool_calls on the OpenAI-compatible backend; the AI SDK backend emits a notice (partial).

Observable effects

typescript
import { Agent } from 'praisonai';

const slow = () => new Promise((r) => setTimeout(() => r('done'), 60_000));

const agent = new Agent({
  instructions: 'Use the slow tool',
  tools: [slow],
  toolConfig: { timeout: 2, outputLimit: 500, outputDirection: 'tail' },
});
// The slow tool's result becomes: Tool "slow" timed out after 2s

Related