▾
import { SkillAgent } from "@arcgis/ai-components/agent-utils/SkillAgent.js";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
systemPromptto define the agent's overall role. Optionalinstructionsadd further guidance. -
Use
skillLoadersto 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-separatedallowed-tools, followed by Markdown instructions the agent uses when the skill is active. Other front-matter fields are not supported.---name: summarize-layerdescription: Summarizes the fields in a map layer.allowed-tools: listLayerFields---When asked about a layer's fields, call listLayerFields and summarize the results. -
Use
runtimeContextLoaderto 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-toolsmetadata and supply it throughtoolLoaders. - SDK-provided tools: Add the exact name from the list below to the skill's
allowed-toolsmetadata. ThetoolLoadersentry 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-layerdescription: 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
Properties
| Property | Type | Class |
|---|---|---|
| inherited | ||
| inherited | ||
| inherited | ||
| | ||
| | ||
| inherited | ||
| readonly inherited | ||
| | ||
| SkillAgentConstructProperties["skillLoaders"] | | |
| | ||
| | ||
| inherited |
createGraph
- Type
- AgentCreateGraph
- 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
- Type
- string
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
- ""
modelTier
- 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
- Type
- string
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
- Type
- AgentRegistration
Provides the metadata and execution definition used to register this agent with the orchestrator.
skillLoaders
- 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.
toolLoaders
- 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
- Type
- AgentStateAnnotation
- 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
generate
- 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
- Signature
-
run (state?: Partial<AgentGraphState<TCustomState>>, config?: AgentExecutionConfig): Promise<AgentGraphState<TCustomState>>
Executes the agent using the provided state and configuration, then returns the resulting state.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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
Function tool or structured tool accepted by the skill runtime.
- Type
- FunctionToolLike | StructuredToolInterface
SkillAgentToolLoaders
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.
- Supertypes
- Readonly<Record<string, () => Promise<SkillAgentTool>>>
SkillAgentRuntimeContextLoaderOptions
Options provided to the context loader for a SkillAgent run.
config
- Type
- AgentExecutionConfig | undefined
Agent execution configuration available to the context loader.
SkillAgentRuntimeContextLoader
Loads additional context included in the SkillAgent's system prompt on each run.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | Options for loading context for the current agent run. | |
SkillAgentConstructProperties
Properties for constructing a SkillAgent. id, name, description, systemPrompt, and skillLoaders are required.
id
- Type
- string
Unique identifier used for agent registration and invocation. If not provided, it will be derived from the provided name.
description
- Type
- string
Describes what the agent does and when the assistant should invoke it.
systemPrompt
- Type
- string
System prompt used to guide the agent in how it should select which skill to use.
toolLoaders
- 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
- 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.