import { Agent } from './agent'; import { AgentOutputSchema } from './agent-outputs'; import { InputGuardrail, InputGuardrailResult, OutputGuardrail, OutputGuardrailResult } from './guardrails'; import { HandoffInputFilter } from './handoffs'; import { TResponseInputItem } from './items'; import { RunHooks } from './lifecycle'; import { ModelSettings } from './models/model-settings'; import { Model, ModelProvider } from './models/interface'; import { RunResult, RunResultStreaming } from './result'; import { StreamEvent } from './stream-events'; import { QueueCompleteSentinel } from './_run-impl'; declare module './result' { interface RunResultStreaming { _input_guardrails_task?: Promise | null; _output_guardrails_task?: Promise | null; _event_queue: AsyncQueue; _input_guardrail_queue: AsyncQueue; _current_agent_output_schema?: AgentOutputSchema | null; } } /** * Configures settings for the entire agent run. */ export declare class RunConfig { /** * The model to use for the entire agent run. If set, will override the model set on every * agent. The model_provider passed in below must be able to resolve this model name. */ model?: string | Model; /** * The model provider to use when looking up string model names. Defaults to OpenAI. */ modelProvider: ModelProvider; /** * Configure global model settings. Any non-null values will override the agent-specific model * settings. */ modelSettings?: ModelSettings; /** * A global input filter to apply to all handoffs. If `Handoff.input_filter` is set, then that * will take precedence. The input filter allows you to edit the inputs that are sent to the new * agent. See the documentation in `Handoff.input_filter` for more details. */ handoffInputFilter?: HandoffInputFilter; /** * A list of input guardrails to run on the initial run input. */ inputGuardrails?: InputGuardrail[]; /** * A list of output guardrails to run on the final output of the run. */ outputGuardrails?: OutputGuardrail[]; /** * Whether tracing is disabled for the agent run. If disabled, we will not trace the agent run. */ tracingDisabled?: boolean; /** * Whether we include potentially sensitive data (for example: inputs/outputs of tool calls or * LLM generations) in traces. If False, we'll still create spans for these events, but the * sensitive data will not be included. */ traceIncludeSensitiveData?: boolean; /** * The name of the run, used for tracing. Should be a logical name for the run, like * "Code generation workflow" or "Customer support agent". */ workflowName?: string; /** * A custom trace ID to use for tracing. If not provided, we will generate a new trace ID. */ traceId?: string; /** * A grouping identifier to use for tracing, to link multiple traces from the same conversation * or process. For example, you might use a chat thread ID. */ groupId?: string; /** * An optional dictionary of additional metadata to include with the trace. */ traceMetadata?: Record; constructor(config?: Partial); } /** * The Runner class handles running agents and managing their lifecycle. */ export declare class Runner { /** * Run a workflow starting at the given agent. The agent will run in a loop until a final * output is generated. The loop runs like so: * 1. The agent is invoked with the given input. * 2. If there is a final output (i.e. the agent produces something of type * `agent.output_type`, the loop terminates. * 3. If there's a handoff, we run the loop again, with the new agent. * 4. Else, we run tool calls (if any), and re-run the loop. * * In two cases, the agent may raise an exception: * 1. If the max_turns is exceeded, a MaxTurnsExceeded exception is raised. * 2. If a guardrail tripwire is triggered, a GuardrailTripwireTriggered exception is raised. * * Note that only the first agent's input guardrails are run. */ static run(startingAgent: Agent, input: string | TResponseInputItem[], options?: { context?: TContext; maxTurns?: number; hooks?: RunHooks; runConfig?: RunConfig; previousResponseId?: string; }): Promise; /** * Run a workflow synchronously, starting at the given agent. Note that this just wraps the * `run` method, so it will not work if there's already an event loop. */ static runSync(startingAgent: Agent, input: string | TResponseInputItem[], options?: { context?: TContext; maxTurns?: number; hooks?: RunHooks; runConfig?: RunConfig; }): RunResult; /** * Run a workflow starting at the given agent in streaming mode. The returned result object * contains a method you can use to stream semantic events as they are generated. */ static runStreamed(startingAgent: Agent, input: string | TResponseInputItem[], options?: { context?: TContext; maxTurns?: number; hooks?: RunHooks; runConfig?: RunConfig; previousResponseId?: string; }): RunResultStreaming; /** * Get the output schema for an agent */ private static _getOutputSchema; /** * Get all handoffs for an agent */ private static _getHandoffs; /** * Get all tools for an agent */ private static _getAllTools; /** * Get the model for an agent */ private static _getModel; /** * Run input guardrails */ private static _runInputGuardrails; /** * Run output guardrails */ private static _runOutputGuardrails; /** * Run a single turn of the agent (non-streaming) */ private static _runSingleTurn; /** * Get a new response from the model */ private static _getNewResponse; /** * Get a single step result from a response */ private static _getSingleStepResultFromResponse; /** * Run a workflow in streaming mode - Implementation */ private static _runStreamedImpl; /** Helper to run input guardrails and stream results for runStreamed */ private static _runInputGuardrailsWithQueue; /** Helper async generator to yield settled promises like asyncio.as_completed */ private static _yieldResults; /** Run a single turn for streaming mode */ private static _runSingleTurnStreamed; }