ResumeOptions configure how to resume generation after an interrupt.

interface ResumeOptions {
    metadata?: Record<string, any>;
    respond?:
        | {
            custom?: Record<string, unknown>;
            data?: unknown;
            media?: undefined;
            metadata?: Record<string, unknown>;
            text?: undefined;
            toolRequest?: undefined;
            toolResponse: { name: string; output?: unknown; ref?: string };
        }
        | {
            custom?: Record<string, unknown>;
            data?: unknown;
            media?: undefined;
            metadata?: Record<string, unknown>;
            text?: undefined;
            toolRequest?: undefined;
            toolResponse: { name: string; output?: unknown; ref?: string };
        }[];
    restart?: | {
        custom?: Record<string, unknown>;
        data?: unknown;
        media?: undefined;
        metadata?: Record<string, unknown>;
        text?: undefined;
        toolRequest: { input?: unknown; name: string; ref?: string };
        toolResponse?: undefined;
    }
    | {
        custom?: Record<string, unknown>;
        data?: unknown;
        media?: undefined;
        metadata?: Record<string, unknown>;
        text?: undefined;
        toolRequest: { input?: unknown; name: string; ref?: string };
        toolResponse?: undefined;
    }[];
}

Properties

metadata?: Record<string, any>

Additional metadata to annotate the created tool message with in the "resume" key.

respond?:
    | {
        custom?: Record<string, unknown>;
        data?: unknown;
        media?: undefined;
        metadata?: Record<string, unknown>;
        text?: undefined;
        toolRequest?: undefined;
        toolResponse: { name: string; output?: unknown; ref?: string };
    }
    | {
        custom?: Record<string, unknown>;
        data?: unknown;
        media?: undefined;
        metadata?: Record<string, unknown>;
        text?: undefined;
        toolRequest?: undefined;
        toolResponse: { name: string; output?: unknown; ref?: string };
    }[]

respond should contain a single or list of toolResponse parts corresponding to interrupt toolRequest parts from the most recent model message. Each entry must have a matching name and ref (if supplied) for its toolRequest counterpart.

Tools have a .respond helper method to construct a reply ToolResponse and validate the data against its schema. Call myTool.respond(interruptToolRequest, yourReplyData).

restart?:
    | {
        custom?: Record<string, unknown>;
        data?: unknown;
        media?: undefined;
        metadata?: Record<string, unknown>;
        text?: undefined;
        toolRequest: { input?: unknown; name: string; ref?: string };
        toolResponse?: undefined;
    }
    | {
        custom?: Record<string, unknown>;
        data?: unknown;
        media?: undefined;
        metadata?: Record<string, unknown>;
        text?: undefined;
        toolRequest: { input?: unknown; name: string; ref?: string };
        toolResponse?: undefined;
    }[]

restart will run a tool again with additionally supplied metadata passed through as a resumed option in the second argument. This allows for scenarios like conditionally requesting confirmation of an LLM's tool request.

Tools have a .restart helper method to construct a restart ToolRequest. Call myTool.restart(interruptToolRequest, resumeMetadata).