UNPKG

@mastra/core

Version:
50 lines • 2.27 kB
import type { AgentBackgroundConfig, BackgroundExecutionDisposition, BackgroundTaskManagerConfig, ToolBackgroundConfig } from './types.js'; export interface ResolvedBackgroundConfig { runInBackground: boolean; disposition: BackgroundExecutionDisposition; timeoutMs: number; maxRetries: number; } /** * Resolves whether a tool call should run in the background, and with what config. * * Resolution order (highest to lowest priority): * 1. LLM per-call override (`_background` field in tool args) * 2. Agent-level backgroundTasks.tools config * 3. Tool-level background config * 4. Default for eligible tools: the configured `defaultDisposition` * (deferred when unset); non-eligible tools always run foreground * * Strips the `_background` field from args (mutates the args object). */ export declare function resolveBackgroundConfig({ llmBgOverrides, toolName, toolConfig, agentConfig, managerConfig, }: { llmBgOverrides: Record<string, unknown>; toolName: string; toolConfig?: ToolBackgroundConfig; agentConfig?: AgentBackgroundConfig; managerConfig?: BackgroundTaskManagerConfig; }): ResolvedBackgroundConfig; /** * Whether a tool is background-eligible: i.e. whether `resolveBackgroundConfig` * could ever dispatch it to the background. This is the same base-enabled * expression the runtime resolver uses (the LLM `_background` override is a * modifier only, never a standalone opt-in — see issue #16783), so advertising * paths (schema injection, system prompt) and dispatch cannot disagree. */ export declare function isToolBackgroundEligible({ toolName, toolConfig, agentConfig, }: { toolName: string; toolConfig?: ToolBackgroundConfig; agentConfig?: AgentBackgroundConfig; }): boolean; /** * The disposition an eligible tool resolves to when a call carries no * `_background` override. Mirrors the fallback chain in * `resolveBackgroundConfig` so advertising paths (system prompt) and dispatch * cannot disagree. */ export declare function resolveDefaultDisposition({ toolName, toolConfig, agentConfig, }: { toolName: string; toolConfig?: ToolBackgroundConfig; agentConfig?: AgentBackgroundConfig; }): 'foreground' | 'deferred'; //# sourceMappingURL=resolve-config.d.ts.map