Skip to content

Stability Plugins

timeoutPlugin

Warns when tool execution exceeds the time limit.

typescript
import { timeoutPlugin } from '@airmcp-dev/core';
use: [timeoutPlugin(5_000)]   // 5 seconds

Signature: timeoutPlugin(timeoutMs?: number) — default: 30000 (30s)

Internal: sets meta._timeoutMs in before, checks elapsed time in after. Over-limit calls get a stderr warning:

[air:timeout] search took 12500ms (limit: 5000ms)

retryPlugin

Retries failed calls with exponential backoff.

typescript
import { retryPlugin } from '@airmcp-dev/core';
use: [retryPlugin({ maxRetries: 3, delayMs: 200 })]
// 200ms → 400ms → 800ms
OptionTypeDefaultDescription
maxRetriesnumber3Max retry attempts
delayMsnumber200Initial delay (doubles each retry)
retryOn(error: Error) => boolean() => trueError filter
typescript
use: [retryPlugin({
  maxRetries: 3,
  retryOn: (error) => error.message.includes('ECONNREFUSED'),
})]

Internal: onError hook tracks meta._retryCount, re-invokes handler directly.

circuitBreakerPlugin

Blocks calls after consecutive failures (prevents cascade failure).

typescript
import { circuitBreakerPlugin } from '@airmcp-dev/core';
use: [circuitBreakerPlugin({ failureThreshold: 5, resetTimeoutMs: 30_000, perTool: true })]
OptionTypeDefaultDescription
failureThresholdnumber5Consecutive failures before open
resetTimeoutMsnumber30000Time before half-open
perToolbooleantrueIndependent circuit per tool (false = global)

States: Closed (normal) → Open (all rejected) → Half-Open (1 test call).

fallbackPlugin

Calls an alternate tool when the primary fails. Maps tool name → fallback tool name.

typescript
import { fallbackPlugin } from '@airmcp-dev/core';
use: [fallbackPlugin({
  'search_primary': 'search_backup',
  'fetch_api': 'fetch_cached',
})]

Signature: fallbackPlugin(fallbacks: Record<string, string>)

[air:fallback] "search_primary" failed, trying "search_backup"

Released under the Apache-2.0 License.