ESM
import { SkillAgent } from "@arcgis/ai-components/agent-utils/SkillAgent.js";
Inheritance
SkillAgent→BaseAgent<AgentData>

Runs an agent loop to carry out an assigned task using Markdown skills, selecting and switching skills as needed until complete or blocked. Use SkillAgent when the model should interpret an assigned task and choose among task-specific skills, rather than follow a developer-defined workflow.

Add the agent to an arcgis-assistant-agent component to make it available to the arcgis-assistant.

Configure the agent's guidance, skills, and run-specific context with these properties:

  • Set systemPrompt to define the agent's overall role. Optional instructions add further guidance.

  • Use skillLoaders to provide Markdown skills. With one skill, its instructions are active from the start. With multiple skills, the model initially sees their names and descriptions and can progressively disclose the relevant skill and its tools to the model. Only that skill's declared tools are made available to the model.

    Each skill file has front matter with a name, description, and optional space-separated allowed-tools, followed by Markdown instructions the agent uses when the skill is active. Other front-matter fields are not supported.

    ---
    name: summarize-layer
    description: Summarizes the fields in a map layer.
    allowed-tools: listLayerFields
    ---
    When asked about a layer's fields, call listLayerFields and summarize the results.
  • Use runtimeContextLoader to supply application context for each run.

Tools

Skills can use tools supplied by the SDK or custom tools you define for your application; both are referenced by name in the skill's Markdown allowed-tools metadata.

  • Custom tools: Create a custom tool with FunctionTool or provide an existing tool accepted by SkillAgentTool. Declare its name in the skill's allowed-tools metadata and supply it through toolLoaders.
  • SDK-provided tools: Add the exact name from the list below to the skill's allowed-tools metadata. The toolLoaders entry is only needed for specifying the location of custom tools. SDK-provided tools are already available and don't need to be specified in the toolLoaders property. They can be directly referenced by name in the skill's Markdown file.

Available SDK-provided tools include:

  • Map filtering:
    • clearFilters - Removes feature filters or effects from the map without resetting other map state.
    • resetMap - Resets broader map state.
    • setFeatureEffect - Applies a visual effect to features matching the supplied layer and filter criteria.
  • Navigation:
    • goToAddress - Finds an address or place name and navigates the map to its location.
    • goToBookmark - Navigates to the extent of a named map bookmark.
    • goToFeatures - Navigates to the extent of features matching the supplied layer and query.
    • goToFullExtent - Navigates to the full-world extent.
    • goToHomeExtent - Returns the map to its initial web map extent.
    • goToLayer - Navigates to the extent of a matching map layer.
    • goToScale - Sets the map to the requested scale.
    • goToViewpoint - Navigates to a viewpoint specified by location and optional zoom or scale.
    • goToZoom - Sets the map to the requested zoom level.
  • Map discovery and context:
    • findRelevantFields - Finds fields relevant to a task within the specified layers. Embeddings must be present on the web map for this tool to be successful.
    • findRelevantLayers - Finds map layers relevant to a task from a concise natural-language query. Embeddings must be present on the web map for this tool to be successful.
    • listLayerFields - Lists the fields and available metadata for a map layer.
    • listSharedResources - Lists resources produced by earlier agent steps, optionally filtered by resource kind. This is important for cross-agent workflows where data from one agent, should be shared with another agent for a separate workflow.
  • Feature data:
    • getAttribute - Retrieves an attribute value from a feature matching the supplied criteria.
    • getStatistics - Calculates statistics for matching features, such as aggregates for numeric fields or frequencies for categories.
    • getTopFeatures - Returns the top features ranked by values in existing fields.
    • queryFeatures - Queries matching features and returns their count and, when available, feature attributes.
Example
import { SkillAgent } from "@arcgis/ai-components/agent-utils/SkillAgent";
const summarizeLayerSkill = `---
name: summarize-layer
description: Summarizes the fields in a map layer.
allowed-tools: listLayerFields
---
When asked about a layer's fields, call listLayerFields and summarize the results.`;
const agent = new SkillAgent({
id: "layer-summary",
name: "Layer Summary",
description: "Summarizes fields in a map layer.",
systemPrompt: "Answer questions about fields in a map layer.",
skillLoaders: [async () => summarizeLayerSkill],
});

Constructors

Constructor

Constructor

Parameters

ParameterTypeDescriptionRequired
properties

Properties

createGraph

inherited Property
Type
AgentCreateGraph
Inherited from: BaseAgent
Since
ArcGIS Maps SDK for JavaScript 5.2

Creates the execution graph used to run this agent. FunctionAgent, LLMAgent, WorkflowAgent, and SkillAgent generate this function from their configuration. Configure the agent through its concrete utility rather than defining this graph directly.

description

inherited Property
Type
string
Inherited from: BaseAgent

A description of what the agent does and when the assistant should invoke it. 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

autocast inherited Property
Type
string
Inherited from: BaseAgent

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

instructions

Property
Type
string | undefined

Additional instructions appended to the system prompt.

modelTier

Property
Type
ChatModelTier

The model tier to use for the agent. Defaults to "default". See ChatModelTier for tier capabilities, current model mappings, and model-change considerations.

Default value
"default"

name

inherited Property
Type
string
Inherited from: BaseAgent

A human-readable name that describes the agent's purpose. This name 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.

registration

readonlyinherited Property
Type
AgentRegistration
Inherited from: BaseAgent

Provides the metadata and execution definition used to register this agent with the orchestrator.

runtimeContextLoader

Property
Type
SkillAgentRuntimeContextLoader | undefined

Supplies run-specific context to the agent's system prompt.

skillLoaders

Property
Type
SkillAgentConstructProperties["skillLoaders"]

One or more loaders that return Markdown definitions for this agent's skills. Each definition must include a name, description, and instructions; it may declare tool names in its optional allowed-tools metadata.

systemPrompt

Property
Type
string

The system prompt used to guide the agent.

toolLoaders

Property
Type
SkillAgentToolLoaders | undefined

Optional loaders for custom tools declared in a skill's allowed-tools metadata. SDK-provided tools are resolved by name and do not require a loader. See SkillAgentToolLoaders.

workspace

inherited Property
Type
AgentStateAnnotation
Inherited from: BaseAgent
Since
ArcGIS Maps SDK for JavaScript 5.2

Defines the state channels used by the agent's execution graph. FunctionAgent, LLMAgent, WorkflowAgent, and SkillAgent configure them internally. Configure the agent through its concrete utility rather than setting these channels directly.

Methods

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

generate

Method
Signature
generate (): void
Since
ArcGIS Maps SDK for JavaScript 5.2

Rebuilds the agent's internal execution setup from its current configuration. Concrete agent constructors call this after assigning their configuration. Call it again after changing configuration properties used to build the execution setup.

Returns
void

run

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

Executes the agent using the provided state and configuration, then returns the resulting state.

Parameters

ParameterTypeDescriptionRequired
state

Optional initial state for the agent. This can include any custom fields defined by the agent.

config

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

Returns
Promise<AgentGraphState>

A promise that resolves to the agent state after execution.

Type definitions

SkillAgentTool

Type definition

Function tool or structured tool accepted by the skill runtime.

Type
FunctionToolLike | StructuredToolInterface

SkillAgentToolLoaders

Type definition

Maps custom tool names declared in a skill's allowed-tools metadata to asynchronous loaders. Each loader returns a SkillAgentTool whose name must match its key.

SkillAgentRuntimeContextLoaderOptions

Type definition

Options provided to the context loader for a SkillAgent run.

config

Property
Type
AgentExecutionConfig | undefined

Agent execution configuration available to the context loader.

SkillAgentRuntimeContextLoader

Type definition

Loads additional context included in the SkillAgent's system prompt on each run.

Parameters

ParameterTypeDescriptionRequired
options

Options for loading context for the current agent run.

Returns
Promise<string> | string

SkillAgentConstructProperties

Type definition

Properties for constructing a SkillAgent. id, name, description, systemPrompt, and skillLoaders are required.

id

Property
Type
string

Unique identifier used for agent registration and invocation. If not provided, it will be derived from the provided name.

name

Property
Type
string

Human-readable name that describes the agent's purpose.

description

Property
Type
string

Describes what the agent does and when the assistant should invoke it.

systemPrompt

Property
Type
string

System prompt used to guide the agent in how it should select which skill to use.

skillLoaders

Property
Type
readonly [ () => Promise<string>, ...(() => Promise<string>)[] ]

One or more loaders that return Markdown definitions for this agent's skills. Each definition must include a name, description, and instructions; it may declare tool names in its optional allowed-tools metadata.

toolLoaders

Property
Type
SkillAgentToolLoaders | undefined

Optional loaders for custom tools declared in a skill's allowed-tools metadata. SDK-provided tools are resolved by name and do not require a loader. See SkillAgentToolLoaders.

modelTier

Property
Type
ChatModelTier | undefined

The model tier to use for the agent. Defaults to "default". See ChatModelTier for tier capabilities, current model mappings, and model-change considerations.

runtimeContextLoader

Property
Type
SkillAgentRuntimeContextLoader | undefined

Supplies run-specific context to the agent's system prompt.

instructions

Property
Type
string | undefined

Additional instructions appended to the system prompt.