Interface SessionSendOptions<S>

Options for a single AgentSession.send call.

interface SessionSendOptions<S> {
    responseSchema?: S;
    schemaName?: string;
    maxValidationRetries?: number;
    blockLabel?: string;
    toolChoice?: string | Record<string, unknown>;
    requestTimeout?: number;
    cacheDiagnostics?: boolean | {
        previousMessageId?: null | string;
    };
    cache?: false | {
        ttl?: "5m" | "1h";
    };
    maxTokens?: number;
    abortSignal?: AbortSignal;
    budget?: SpendBudget | SpendBudgetOptions;
}

Type Parameters

  • S extends ZodType | undefined = undefined

Properties

responseSchema?: S

Zod schema describing the expected shape of the assistant reply. When present, agentos converts the schema to JSON Schema, routes through the provider's native structured-output API (OpenAI json_schema; Anthropic's JSON output format, or a forced tool call for a schema the format cannot carry; Gemini responseSchema), and returns a Zod-validated typed object on result.object alongside the JSON string in result.text. A call whose provider payload carries no schema (a provider with none, a record schema on an Anthropic model that refuses a forced tool choice, JSON-object mode) gets the schema in its system prompt, in the words generateObject uses; each fallback provider is checked for its own payload.

The agent's tools are left out of a schema request, and with them the chain-of-thought instruction; runtime: 'legacy' (the default) warns that it leaves them out.

schemaName?: string

Display name for the schema in provider payloads. Surfaces in OpenAI's json_schema.name and Anthropic's tool name. Defaults to 'response'. Sanitized to /[a-zA-Z0-9_]/ and truncated to 64 chars.

maxValidationRetries?: number

Extra schema-validation attempts on the default runtime. Defaults to 0.

blockLabel?: string

Telemetry + eviction-boundary label for this send's transcript block. Labels are markers, not pins.

toolChoice?: string | Record<string, unknown>

Per-send generation overrides, merged over the agent's baseOpts with send-level precedence — the same contract generate(prompt, extra) gives extra. Long tool-driving loops rely on these (toolChoice, requestTimeout, cacheDiagnostics); without send-level carriage a caller migrating from generate() silently loses them.

requestTimeout?: number
cacheDiagnostics?: boolean | {
    previousMessageId?: null | string;
}

Type declaration

  • Optional previousMessageId?: null | string
cache?: false | {
    ttl?: "5m" | "1h";
}

Type declaration

  • Optional ttl?: "5m" | "1h"
maxTokens?: number
abortSignal?: AbortSignal

Ends this send when it aborts: the provider request in flight is cancelled, no further step, retry or fallback hop starts, and the send rejects with the signal's reason. The session stays open. With the default runtime nothing of the send is added to the session's history; with runtime: 'gmi' the turn ends as close() ends one, and the steps it finished stay in messages(), marked partial.

A spend budget for this send in place of the agent's; on a seat session (sessionSeat(), or a member a launched team seats) held beside it, each call checked against both and charged to both. Every provider call of the send is checked against it before it is made and recorded after it (settings make a new SpendBudget for the send). With runtime: 'gmi', every completion call of the turn, metaprompts included.