AgentConfig
| Property | Type | Default | Description |
|---|---|---|---|
name | string | required | Agent identifier (logging, telemetry). |
instructions | string | undefined | Default system prompt (override with system). |
model | LanguageModel | required | Model from the AI SDK. |
tools | AgentTools | undefined | Tools exposed by default (ToolSet or provider-specific). |
telemetry | boolean | false | Enables OTEL / Langfuse export by default. |
loopTools | boolean | false | Enables the automatic tool loop. |
maxStepTools | number | 20 (DEFAULT_MAX_STEP_TOOLS) | Max tool executions before the loop stops. |
Constructor
Instance methods
agent.generate(options)
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 (seeRuntimeStore).telemetry?: AgentTelemetryOverrides– mergesfunctionId,metadata,recordInputs,recordOutputs.loopTools?: boolean/maxStepTools?: number– per-call overrides for the tool loop.
GenerateTextResult enriched with loopTool?: boolean.
agent.stream(options)
textStream,fullStream,text,response,usage,steps.experimental_partialOutputStreamwhenstructuredOutputis provided.toAIStreamResponse()/toDataStreamResponse()to integrate with HTTP streaming responses.
agent.withTelemetry(enabled?: boolean)
Enable or disable telemetry by mutating the instance. Returns this for chaining.
Utility types
AgentTools– union between AI SDKToolSetand provider dictionaries.AgentGenerateResult<T>– alias ofGenerateTextResult+loopTool.AgentStreamResult<T>– alias ofStreamTextResult+loopTool.AgentTelemetryOverrides–functionId,metadata,recordInputs?,recordOutputs?.
Runtime handling
Whenruntime is provided:
- a
RuntimeStoresnapshot is created for the call duration; onCleanuphandlers run at the end (success, error, or cancellation);RuntimeStore.mergeExperimentalContextmerges manually passedexperimental_contextwith the runtime state.