ESM
import { LLMAgent } from "@arcgis/ai-components/agent-utils/LLMAgent.js";
Inheritance
LLMAgentBaseAgent<AgentCustomState<TInput, TOutput>>Accessor.js
Since
ArcGIS Maps SDK for JavaScript 5.1

LLMAgent uses a language model to generate its output based on a provided prompt template and optional tools. It supports structured input and output through Zod schemas, allowing for validation and type safety. The agent's logic is defined by the prompt and the tools it has access to, making it a flexible option for a wide range of use cases.

Constructors

Constructor

Constructor

Parameters

ParameterTypeDescriptionRequired
properties
LLMAgentConstructProperties<TInput, TOutput>

Properties

description

inherited Property
Type
string
Inherited from: BaseAgent

Description of the agent's purpose and functionality. This can be used in registration metadata to provide context about the agent's functionality. A good description is clear and concise. Use bullet points to describe tasks the agent can accomplish. Provide examples of user questions or prompts that could be answered by the agent.

Default value
""

id

readonlyinherited Property
Type
string
Inherited from: BaseAgent

The unique identifier for the agent, derived from the name property. This ID is used for registration and invocation purposes.

inputSchema

Property
Type
ZodObjectSchema | undefined

The inputSchema property is an optional Zod schema describing the expected structured input for the agent. This can be used for validation of the input state before execution and also to extract variables from the input state for prompt formatting.

middlewares

inherited Property
Type
AgentMiddleware[]
Inherited from: BaseAgent

An optional array of middleware functions that can be used to extend or modify the agent's behavior during execution. This allows for flexible customization of the agent's execution logic. For example, middlewares can be used to implement trace messages (i.e. logging), human-in-the-loop interrupts, or other custom actions.

modelTier

Property
Type
"advanced" | "default" | "fast"

The tier of the model to use for the agent. This can affect the capabilities and performance of the agent.

Default value
"default"

name

inherited Property
Type
string
Inherited from: BaseAgent

A name for the agent, which is used in the registration metadata and can be displayed in tooling. It should be unique across agents to avoid registration conflicts. A good agent name clearly indicates the scope and purpose of the agent. For example, "WeatherAgent" or "CustomerSupportAgent" are descriptive names that convey the agent's functionality as opposed to generic names like "Agent1" or "MyAgent".

The name is also used to generate the agent's id.

outputSchema

Property
Type
ZodObjectSchema | undefined

The outputSchema property is an optional Zod schema describing the expected structured output from the agent. If provided, the agent will attempt to parse the language model's response according to this schema and return structured data. If not provided, the agent will treat the language model's response as an unstructured string message.

prompt

Property
Type
string

Defines the prompt template the agent will use to generate its output. This prompt can include variables that are populated from the agent's state at runtime through the input schema, allowing for dynamic and context-aware responses from the language model.

In this example below, {location} and {weather} would be variables extracted from the agent's state according to the input schema.

Example
"Generate a weather report for {location} based on the current {weather} conditions."

registration

readonlyinherited Property
Type
AgentRegistration
Inherited from: BaseAgent

The registration property assembles the necessary metadata and graph definition for this agent, which is consumed by the orchestrator during registration.

tools

Property
Type
FunctionToolLike[] | undefined

The tools property is an optional array of FunctionTools that the agent can use during execution.

Methods

MethodSignatureClass
initialize(): void
run
inherited
run(state?: Partial<AgentGraphState<TCustomState>>, config?: AgentExecutionConfig): Promise<AgentGraphState<TCustomState>>

initialize

Method
Signature
initialize (): void
Returns
void

run

inherited Method
Signature
run (state?: Partial<AgentGraphState<TCustomState>>, config?: AgentExecutionConfig): Promise<AgentGraphState<TCustomState>>
Inherited from: BaseAgent

Executes the agent's graph with the provided state and configuration. This method is responsible for invoking the compiled graph and returning the resulting state after execution.

Parameters

ParameterTypeDescriptionRequired
state

An optional partial state object to initialize the graph execution. This can include any custom fields defined by the agent.

config

An optional execution configuration that can influence the agent's behavior during invocation.

Returns
Promise<AgentGraphState>

A promise that resolves to the updated agent graph state after execution.

Type definitions

LLMAgentConstructProperties

Type definition
Type parameters
<TInput extends AgentData, TOutput extends AgentData>
Supertypes
Partial<Pick<LLMAgent<TInput, TOutput>, "description" | "inputSchema" | "middlewares" | "modelTier" | "outputSchema" | "tools">> ‚  Pick<LLMAgent<TInput, TOutput>‚ "name" | "prompt">