Interface GenerateTextResult

The completed result returned by generateText.

interface GenerateTextResult {
    transcriptDelta?: SessionTranscriptMessage[];
    provider: string;
    model: string;
    responseModel?: string;
    serviceTier?: string;
    servingProvider?: string;
    cacheDiagnostics?: null | CacheDiagnostics;
    providerMessageId?: null | string;
    text: string;
    usage: TokenUsage;
    toolCalls: ToolCallRecord[];
    finishReason: "length" | "error" | "stop" | "tool-calls";
    agentCalls?: AgentCallRecord[];
    trace?: AgencyTraceEvent[];
    parsed?: unknown;
    plan?: Plan;
    grounding?: VerifiedResponse;
    fallback?: FallbackSignal;
}

Hierarchy (view full)

Properties

transcriptDelta?: SessionTranscriptMessage[]

Lossless message delta this call appended to the conversation: the request's user turn plus every assistant / tool turn the tool loop recorded, in order, in provider-replayable shape (tool_call ids, parallel results, thinking blocks). Sessions append THIS — never a reconstruction — to their history. Absent only on legacy paths that never seeded a conversation array. The prompt-shim path carries a partial delta (seeded turns only); native providers carry the full trail.

provider: string

Provider identifier used for the final run.

model: string

Resolved model identifier used for the run.

responseModel?: string

Provider-reported model id of the final step (spec batch-1 C1) — can differ from model across aliases and fallback routing. Undefined on paths where no provider-reported id was captured. model keeps its existing meaning (zero-change).

serviceTier?: string

Provider-reported service tier the final step actually ran at (OpenAI service_tier on the response; spec batch-1 C2). Undefined on providers/paths without a tier concept.

servingProvider?: string

Upstream host that actually served the request when provider is an aggregator/router (OpenRouter reports e.g. 'Groq' or 'DeepInfra' per completion). Undefined for direct providers, for aggregators that omit it, and on the prompt-shim tool path. Latency attribution: identical model + token counts vary 3-5x in wall-clock by serving host, so telemetry needs this to interpret durations.

cacheDiagnostics?: null | CacheDiagnostics

Cache-diagnostics verdict from the LAST agentic step (Anthropic beta; present only when the run opted in via GenerateTextOptions.cacheDiagnostics). null = the last step's request matched its predecessor (prefix stable). A populated cacheMissReason names the earliest divergence. Per-step verdicts are available on the onAfterGeneration hook.

providerMessageId?: null | string

Provider message id (msg_...) of the LAST agentic step; present only when the run opted in via GenerateTextOptions.cacheDiagnostics. Persist it and pass it back as the next request's cacheDiagnostics.previousMessageId to thread the comparison across turns. null when the provider reported no id.

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 from BaseAgentConfig.output, or from agent().generate() with responseSchema. Undefined without a schema.

plan?: Plan

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

grounding?: VerifiedResponse

Per-claim citation verdicts attached when agent({ verifyCitations: … }) is configured. undefined when verification was not requested or could not run for this turn.

See

VerifyCitationsConfig (exported from @framers/agentos/api) for the verifyCitations options.

fallback?: FallbackSignal

Per-hop provider fallback trail. fired is true when any non-primary provider produced — or was tried for — the result, so callers can flag a degraded run even when the final attempt recovered on the primary. undefined only on legacy code paths that predate the field.