跳转到内容

Handoff

此内容尚不支持你的语言。

Type Parameter Default type

TContext

UnknownContext

TOutput extends AgentOutputType

TextOutput

new Handoff<TContext, TOutput>(agent, onInvokeHandoff): Handoff<TContext, TOutput>;
Parameter Type

agent

Agent<TContext, TOutput>

onInvokeHandoff

(context, args) => | Agent<TContext, TOutput> | Promise<Agent<TContext, TOutput>>

Handoff<TContext, TOutput>

agent: Agent<TContext, TOutput>;

The agent that is being handed off to.


agentName: string;

The name of the agent that is being handed off to.


optional inputFilter: HandoffInputFilter;

A function that filters the inputs that are passed to the next agent. By default, the new agent sees the entire conversation history. In some cases, you may want to filter inputs e.g. to remove older inputs, or remove tools from existing inputs.

The function will receive the entire conversation hisstory so far, including the input item that triggered the handoff and a tool call output item representing the handoff tool’s output.

You are free to modify the input history or new items as you see fit. The next agent that runs will receive `handoffInputData.allItems


inputJsonSchema: JsonObjectSchema<any>;

The JSON schema for the handoff input. Can be empty if the handoff does not take an input


isEnabled: HandoffEnabledFunction<TContext>;

onInvokeHandoff: (context, args) =>
| Agent<TContext, TOutput>
| Promise<Agent<TContext, TOutput>>;

The function that invokes the handoff. The parameters passed are:

  1. The handoff run context
  2. The arguments from the LLM, as a JSON string. Empty string if inputJsonSchema is empty.

Must return an agent

Parameter Type

context

RunContext<TContext>

args

string

| Agent<TContext, TOutput> | Promise<Agent<TContext, TOutput>>


strictJsonSchema: boolean;

Whether the input JSON schema is in strict mode. We strongly recommend setting this to true, as it increases the likelihood of correct JSON input.


toolDescription: string;

The description of the tool that represents the handoff.


toolName: string;

The name of the tool that represents the handoff.

getHandoffAsFunctionTool(): object;

Returns a function tool definition that can be used to invoke the handoff.

object

description: string;
name: string;
parameters: JsonObjectSchema<any>;
strict: boolean;
type: "function";