Interface GenerateTextResult

The completed result returned by generateText.

interface GenerateTextResult {
    provider: string;
    model: string;
    text: string;
    usage: TokenUsage;
    toolCalls: ToolCallRecord[];
    finishReason: "length" | "error" | "stop" | "tool-calls";
    agentCalls?: AgentCallRecord[];
    trace?: AgencyTraceEvent[];
    parsed?: unknown;
    plan?: Plan;
}

Properties

provider: string

Provider identifier used for the final run.

model: string

Resolved model identifier used for the run.

text: string

Final assistant text after all agentic steps have completed.

usage: TokenUsage

Aggregated token usage across all steps.

toolCalls: ToolCallRecord[]

Ordered list of every tool call made during the run.

finishReason: "length" | "error" | "stop" | "tool-calls"

Reason the model stopped generating.

  • "stop" — natural end of response.
  • "length"maxTokens limit reached.
  • "tool-calls" — loop exhausted maxSteps while still calling tools.
  • "error" — provider returned an error.
agentCalls?: AgentCallRecord[]

Ordered records of every sub-agent call made during an agency() run. undefined for plain generateText / agent() calls.

Structured trace events emitted during the run. Populated by the agency orchestrator; undefined for single-agent calls.

parsed?: unknown

Parsed structured output produced when BaseAgentConfig.output is a Zod schema. undefined when no output schema is configured.

plan?: Plan

The plan produced by the planning phase when planning is enabled. undefined when planning is disabled or was not requested.