Skip to main content

AgentConfig

Constructor

Instance methods

agent.generate(options)

Options extend AI SDK generateText parameters (prompt or messages) with:
  • system?: string – overrides the default instructions.
  • structuredOutput?: Output.Output<OUTPUT, PARTIAL> – schema-based generation (Zod).
  • runtime?: RuntimeStore<STATE> – shared runtime (see RuntimeStore).
  • telemetry?: AgentTelemetryOverrides – merges functionId, metadata, recordInputs, recordOutputs.
  • loopTools?: boolean / maxStepTools?: number – per-call overrides for the tool loop.
Returns a GenerateTextResult enriched with loopTool?: boolean.

agent.stream(options)

Additional properties:
  • textStream, fullStream, text, response, usage, steps.
  • experimental_partialOutputStream when structuredOutput is provided.
  • toAIStreamResponse() / toDataStreamResponse() to integrate with HTTP streaming responses.
Structured output automatically switches to the structured pipeline when supported by the model.

agent.withTelemetry(enabled?: boolean)

Enable or disable telemetry by mutating the instance. Returns this for chaining.

Utility types

  • AgentTools – union between AI SDK ToolSet and provider dictionaries.
  • AgentGenerateResult<T> – alias of GenerateTextResult + loopTool.
  • AgentStreamResult<T> – alias of StreamTextResult + loopTool.
  • AgentTelemetryOverridesfunctionId, metadata, recordInputs?, recordOutputs?.

Runtime handling

When runtime is provided:
  • a RuntimeStore snapshot is created for the call duration;
  • onCleanup handlers run at the end (success, error, or cancellation);
  • RuntimeStore.mergeExperimentalContext merges manually passed experimental_context with the runtime state.
Without a runtime, the agent simply wraps the AI SDK behaviour.