Tools
Built-in tools cover connection calls, stores, knowledge, skills, and chat controls. Custom tools in amodal/tools/<name>/ run your own code. A custom tool takes one of two layouts:
amodal/tools/
├── summarize_ticket/
│ └── tool.ts ← metadata and handler in one module
└── review_request/
├── tool.json ← metadata
├── handler.ts ← default export (params, ctx) => result
├── package.json ← (optional) npm dependencies
└── requirements.txt ← (optional) Python dependenciesWhen tool.ts exists, the directory uses that layout and ignores any tool.json. Composition (ctx.callTool, ctx.callSubagent), durable execution, triggers, and the env allowlist require the tool.json layout.
To offer a durable invoke tool to external callers, set output and expose.protocols in its tool.json. See Publish a tool.
Tool code ships with the agent repository. Commit, deploy, and read the build logs for TypeScript, dependency, and validation errors. See Deployment API.
Built-in Tools
| Tool | Registered when | What it does |
|---|---|---|
request | ≥1 REST connection without openapi or skipRequestTool: true | HTTP calls with connection authentication and policy checks. See Confirmation Model. |
<connection>__<operationId> | connection with openapi.source | Typed operation calls. See Native OpenAPI connections. |
tool_search | ≥1 deferred tool: MCP, custom, or an operation of a discovery connection | Search deferred tools and load their definitions for the next reply. |
read_spilled_result, search_spilled_result | every session | Read or search a large saved tool or command result. |
store__<store>__get | store defined | Read one document by key. See Stores. |
store__<store>__set | store defined | Create or update one document. |
store__<store>__query | store defined | Filter documents. |
store__<store>__list | store defined | List documents. |
store__<store>__remove | store sets deletable: true | Delete one document. |
call_subagent | ≥1 invokable subagent | Run authored subagents. See Delegation. |
present | unscoped chat, or declared in a named agent's tools | Render a widget such as an info card, data table, or metric. |
ask_choice | always | Ask a single- or multi-select question. Calling it ends the turn; the choice arrives as the next user message. |
schedule_automation | capabilities.automations, hosted, in unscoped chat or declared in a named agent's tools | Schedule a run, once or recurring, after confirmation. It belongs to the signed-in user, if any, and the session's scope. Results reach the owner in-app, and by email when on; the result's delivery says which. A public visitor cannot schedule. Each label is unique per owner within a scope. A cron schedule runs in the user's time zone, which the chat client reports as the timezone request metadata, unless the agent names another; the agent asks for one when the client sent none. The result reports the next run in that zone. |
list_automations | capabilities.automations, hosted, in unscoped chat or declared in a named agent's tools | List the scope's automations with their next run times. A signed-in user sees the automations they own and the ones with no owner, such as those an operator created. A session with no signed-in user sees every automation in the scope. Times are in the user's time zone when the client reported one, and in UTC otherwise. |
remove_automation | capabilities.automations, hosted, in unscoped chat or declared in a named agent's tools | Delete a scheduled automation. Requires confirmation, which names the automation's label. A signed-in user can delete the automations they own and the ones with no owner. A session with no signed-in user can delete any automation in the scope. |
skip_report | capabilities.automations, in a run an owned automation started | Mark the run as having nothing to report, so its owner gets no result notification. |
load_skill | ≥1 on-demand skill in scope | Return a skill's instructions. |
load_knowledge | ≥1 Markdown knowledge document | Return a knowledge document's body. |
knowledge_search | ≥1 corpus or library, and tool in scope | Search a corpus or library. |
knowledge_read | ≥1 corpus or library, and tool in scope | Read a section or line range. |
web, web_search, fetch_url | capabilities.web or webTools configured and tool in scope | See Web Tools. |
memory | memory enabled and editable, and tool in scope | Persistent memory with add, remove, list, and search. See Memory. |
*_repo_file, *_repo_files | declared in the agent's tools | read_repo_file, write_repo_file, edit_repo_file, delete_repo_file, list_repo_files, glob_repo_files, grep_repo_files, read_many_repo_files. Writes, edits, and deletes require confirmation. Disable all with "fileTools": false in amodal.json. |
bash, read_file, write_file, publish_file | sandbox.provider configured in amodal.json and tool in scope | Run shell commands and read, write, or publish files in the session's isolated sandbox. See amodal.json. |
propose_source_change | hosted, declared in the agent's tools (or agents/main/agent.json for default chat) | Propose edits to the agent's own source for review in Studio. Also registers read_amodal_docs. See Proposals. |
<server>__<tool> | ≥1 MCP server connected | Tools discovered from each MCP server. |
A tool is "in scope" in unscoped chat, or when a named agent lists it in tools. In default chat, file tools come from the tools declared by agents/main/agent.json.
An automation with an owner belongs to that person in chat, on pages, and through the SDK. An automation with no owner is shared within its scope. Two users can use the same label, and the automations with no owner share one set of labels per scope. useAutomation follows the same rules.
Tool execution order
The model can submit independent reads together. The runtime runs up to eight eligible reads concurrently and records results in call order. Writes run one at a time, and later reads wait for preceding writes to finish. Calls that depend on another call's result must be issued after that result arrives.
Skill setup, user questions, widget display, approvals, durable operations, and connection operations sharing an upstream session run separately. Runtime ToolDefinition implementations can set concurrency: 'serial' for a read-only tool that has shared state or other ordering requirements. This scheduling applies to model-selected calls; composite handlers control their own nested call order.
Web Tools
Web tools come from one of two declarations:
capabilities.webuses Amodal's managed search and page reader through the model gateway. See Managed web tool.webToolsuses your own Google API key forweb_searchandfetch_url. The runtime calls Google directly, so these tools need no Amodal sign-in underamodal dev.
{
"webTools": {
"provider": "google",
"apiKey": "env:GOOGLE_API_KEY"
}
}"webTools": true is shorthand for the Google provider with env:GOOGLE_GENERATIVE_AI_API_KEY. In the hosted runtime, an agent without a secret of that name uses Amodal's managed search instead, the same as capabilities.web: { search: true }. Managed search provides web_search but no fetch_url; declare capabilities.web: { search: true, read: true } instead of webTools to read pages.
With provider: "google", both tools use Gemini grounding regardless of the agent's model. Set model to a Gemini model that supports Search and urlContext grounding, or omit it for the runtime default.
web_search({query, max_results})returns{ status, content, sources }: the search evidence incontent, and up tomax_resultssources (default 5, maximum 10), each{ id, url, title? }. For Google grounding,urlis a grounding redirect andtitleis usually the site's domain. An id isweb:followed by eight hex characters derived from the URL, so ids from different searches do not collide. The tool description tells the model to cite a source as[[<id>]], whichChatWidgetrenders as a numbered link. Plain-text replies, such as Slack messages,/chat/sync, and agent runs, turn each citation into a numbered markdown link and drop an id that no search or sub-agent returned. A sub-agent's answer reaches its parent with its citations as[[<id>]]markers, followed by one definition line per cited source,[[<id>]]: <url> "<title>". The parent cites those ids like its own search results, and bothChatWidgetand plain-text replies resolve them from the definitions. A definition never replaces the source of an id that a search returned.fetch_url({url, prompt})fetches and summarizes a public page through urlContext, and falls back to a local fetch with Readability extraction. The local fetch has a 10-second timeout and a 1 MB body cap. Each hostname is limited to 10 requests per 60 seconds.- Under
amodal dev, private-network URLs (localhost, RFC 1918,.local) use the local fetch. A hosted runtime refuses private-network and other non-public addresses.
Managed web tool
capabilities.web exposes one web tool. Search uses the gateway's search
provider; page reading uses a separately authorized reader integration on the
same gateway:
{
"capabilities": {
"web": { "search": true, "read": true }
}
}A named agent must declare web in its tools. Omit read for search only;
open and find are then absent from the action schema. An agent that declares
web_search also gets search through the gateway. Google webTools
configurations provide web_search and fetch_url; a Google web declaration
provides search only, not managed reading.
web({action: "search", query: "...", max_results: 5})returns evidence and source references using the existing[[web:...]]citation format. The default is five sources, maximum ten. Brave Context retains its existing 4K provider budget; this change does not increase search spending.web({action: "open", ref: "web:..."})reads a search result. Alternatively, passurlto read a specific page or fetch a fresh copy. Results include a snapshot reference, title, final URL, retrieval time, numbered text, links and a truncation flag. HTML, plain text and PDFs with a text layer are supported, up to 10 MB per source; PDF text is marked by page. Scanned PDFs and pages requiring JavaScript or authentication need a different reader. A failed read returns a short reason, such as the source's HTTP status, a blocked destination, a timeout or an unsupported format.web({action: "open", ref: "web:...", line: 61, num_lines: 60})reads another window of the saved snapshot without another gateway request. The default is 60 lines, maximum 100, wrapped at 200 characters.web({action: "find", ref: "web:...", pattern: "revenue"})finds literal text in an opened snapshot, case-insensitively, returning up to 20 matching lines. Open the reported lines to inspect surrounding evidence. This is a local lookup, not another paid search. Search, then open, then find when one depends on the previous result; independent searches and opens can run together.
Source references are session-scoped. Page snapshots have a one-hour lifetime and a bounded in-memory cache (50 pages, about 5 million cached characters). They can expire or disappear on restart; reopen the original URL if unavailable. Citations in saved chat history continue to resolve after a restart. Retrieved pages are untrusted evidence, never instructions.
The runtime reuses the authenticated CLI gateway connection or hosted deployment's
scoped key. The manifest cannot set the gateway URL, provider credentials, reader
credentials or destination policy. Search calls go to /v1/search/web-search;
reads go to /v1/search/web-read. Both carry session attribution. Configure
credentials and separate team/key grants in LiteLLM. A failed or denied read never
falls back to Google or direct runtime networking.
The managed reader is deployed separately from the runtime. See
infra/litellm/README.md for its SearXNG-compatible gateway configuration,
default-deny destination policy, private-network grants and test commands.
For on-prem deployments, use approved local services and outbound network rules.
A self-hosted metasearch service may still query external providers. This web
configuration does not restrict unrelated models or tools.
Tool Types
The @amodalai/tools package holds the types of the tool layouts and of ctx. Install it as a dependency of the agent repository:
npm install @amodalai/toolsA built tool.ts imports defineTool when the tool loads, and the hosted build removes dev dependencies, so install the package as a dependency, not a dev dependency. The build does not check types: run tsc --noEmit in the agent repository for that.
| Type | Describes |
|---|---|
ToolModule<I> | A tool.ts default export. defineTool<I>() returns one. |
ToolInputContext | The ctx a tool.ts handle receives: ToolContext & { input: I }. |
ToolContext | The ctx a handler.ts receives. See Handler Context. |
ToolHandler | A handler.ts default export. |
The package also exports ToolExposure, VerifiedClaims, NotifyInput, NotifyResult, NotificationEmail, ToolConfirmation, ToolConfirmationPage, ToolConfirmationOutcome, and defineToolHandler.
Single-file Tools
amodal/tools/<name>/tool.ts holds the metadata and the handler:
import { defineTool } from '@amodalai/tools';
interface Ticket {
id: string;
status: string;
category: string;
identity_verified?: boolean;
}
export default defineTool<{ ticket_id: string }>({
id: 'summarize_ticket',
exposure: { kind: 'open' },
base: {
name: 'summarize_ticket',
description: 'Load a support ticket and return a concise operator summary.',
parametersJsonSchema: {
type: 'object',
properties: { ticket_id: { type: 'string' } },
required: ['ticket_id'],
},
},
async handle(ctx) {
const { ticket_id } = ctx.input;
const ticket = (await ctx.request('support-api', `/tickets/${encodeURIComponent(ticket_id)}`)) as Ticket;
const needsVerification = ticket.category === 'account_access' && ticket.identity_verified !== true;
return {
ticket_id: ticket.id,
status: ticket.status,
needs_verification: needsVerification,
};
},
});The default export must have a handle(ctx) function. Parameters arrive in ctx.input. defineTool checks every field of the export, and its type argument types ctx.input.
| Field | Default | Description |
|---|---|---|
id (or base.name) | directory name with - → _ | Tool name. Must be snake_case. |
base.description | tool name | Shown to the model. Say when to use the tool. |
base.parametersJsonSchema | {"type":"object","properties":{}} | JSON Schema for the input. |
exposure.kind | open | open runs without approval and is read-only for ctx.request. requires-confirmation pauses every model-selected call for approval, and its optional prompt is the approval card's text, with {{param}} substituting a call parameter. operator-gated behaves like open. |
enabled | true | false skips registration. |
llm_callable | true | false hides the tool from the model. Composites and triggers can still call it. |
discovery | "deferred" | "direct" keeps the tool in the model's initial tool list. A deferred tool reaches the model through tool_search. |
runningLabel, completedLabel | Chat card text while running and after success. {{param}} substitutes a call parameter. | |
displayName | Noun phrase naming the tool in aggregating UIs. |
A tool.ts tool has a fixed 30-second timeout and an empty env allowlist, so ctx.env() returns undefined.
Tools that import the same module, such as a helper in amodal/_lib/, share one instance of it and its module-level state.
Tool Metadata
tool.json holds the metadata, and handler.ts default-exports (params, ctx) => result:
{
"description": "Classify support ticket priority from category, impact, and age.",
"parameters": {
"type": "object",
"properties": {
"category": { "type": "string" },
"affected_users": { "type": "number" }
},
"required": ["category", "affected_users"]
},
"timeout": 10000,
"env": ["PRIORITY_RULES_URL"],
"runningLabel": "Classifying {{category}} ticket",
"completedLabel": "Classified ticket"
}import type { ToolContext } from '@amodalai/tools';
export default async function (params: { category: string; affected_users: number }, ctx: ToolContext) {
ctx.log(`Classifying ${params.category}`);
const broad = params.affected_users >= 10;
return { priority: params.category === 'account_access' && broad ? 'high' : broad ? 'medium' : 'normal' };
}The tool name is the directory name, which must be snake_case.
| Field | Default | Description |
|---|---|---|
description | required | Shown to the model. |
name | directory name | Must match the directory name when set. |
parameters | {} | JSON Schema for the input. |
confirm | false | true or "review" lets ctx.request send write-intent calls. Neither prompts the user. "never" skips registration with a warning. |
timeout | 30000 | Handler timeout in milliseconds (0 disables the overall deadline for a durable tool). |
enabled | true | false skips registration. The model, composites, and triggers cannot call the tool. |
llm_callable | true | false hides the tool from the model. Composites and triggers can still call it. |
discovery | "deferred" | "direct" keeps the tool in the model's initial tool list. A deferred tool reaches the model through tool_search. |
internal | false | true marks the tool's calls as internal plumbing, which the chat widget hides unless verboseTools is set. |
env | [] | Environment variables ctx.env() may read. |
runningLabel, completedLabel | Chat card text while running and after success. {{param}} substitutes a call parameter. | |
displayName | Noun phrase naming the tool in aggregating UIs. | |
reminder, reminderAfterTurns | 3 | Text restated to the model after the tool goes unused for that many turns. |
uses, execution, triggers | Composition, durable execution, and non-model triggers. See Agent Workflows. | |
single_flight | true runs a durable tool one run at a time. See Single-Flight Tools. |
The loader accepts responseShaping and sandbox in tool.json but does not apply them. A tool.json tool cannot require approval: use tool.ts with exposure.kind: "requires-confirmation" for that, or gate the action inside a durable tool.
Handler Context
ctx is a ToolContext in handler.ts and a ToolInputContext in tool.ts. See Tool Types.
| Member | Description |
|---|---|
ctx.request(connection, endpoint, options?) | Authenticated call through a connection. options takes method, params, data, and intent. |
ctx.exec(command, options?) | Run a shell command. options takes cwd and timeout. Resolves to {stdout, stderr, exitCode}. |
ctx.store(storeName, payload) | Write a document to a store. Resolves to { key }. |
ctx.storeGet(storeName, key) | Read one document's payload from a store. Resolves to null when the key does not exist. |
ctx.storeQuery(storeName, options?) | Read payloads matching where, with sort, limit (default 100, maximum 500), and offset. Resolves to { rows, total, hasMore }. |
ctx.listConfirmations(options?) | The agent's confirmation records, newest first. options takes cursor and limit (default 100, maximum 200). Resolves to { entries, nextCursor }. Absent under amodal dev. |
ctx.notify(input) | Send the run's user, or another person with access to the agent, a notification they read in the app. Resolves to { id, result }, where result is created, updated, or unchanged. |
ctx.memory.list(options?) | The agent's memory as ctx.userId sees it, under the sourceAccess rule. options takes archived, query, and topic, an exact match on the memory's topic. Read-only. Absent when memory is off; rejects in a durable tool. |
ctx.env(name) | Read an allowlisted environment variable. undefined when not allowlisted. |
ctx.log(message) | Write a log line. |
ctx.signal | AbortSignal that fires on cancellation or timeout. |
ctx.scopeId | Per-user scope key for the turn. Empty string at agent level. |
ctx.scopeContext | The turn's scope context, as sent by the embedding app. It can carry client-supplied values, so do not use it for authorization. undefined when absent. |
ctx.attachments | Files attached to the turn's message, with Office files converted to text. Top-level tools only. In an agent with a sandbox, every file of the conversation is also in the sandbox under in/. |
ctx.stageAttachments(files), ctx.stagedAttachments(handle) | Keep uploaded files for a later turn and return a handle, then read them back by handle. null means the files are gone. Absent without an attachment store. |
ctx.setLabel({running?, completed?}) | Update the tool call's running and completed labels in chat (tool_label_update). |
ctx.emitReasoning(text) | Stream reasoning text during tool execution. |
ctx.emit(event) | Emit an inline chat event: ask_choice, show_preview, connection_panel, or tool_label_update. |
ctx.setDeadline(unixMs) | Tighten the call's deadline to an absolute Unix time in milliseconds. It cannot extend the deadline, and a past time aborts the call. |
ctx.claims | The verified runtime token's context claim. A value is a string or a list of strings. The request body cannot override it, so use it for identity decisions. Local runs take it from dev-users.json. |
ctx.userId | The verified id of the person the run acts for, or who is signed in to the app page that called the tool. The request cannot set it. undefined for API keys, SDK client tokens, and service tokens. See The run's user. |
ctx.sessionId, ctx.agentId | Identifiers for the current session and agent. On an app call, a fresh id per call. |
ctx.artifacts | providers list and register({ providerId, sourceRef, idempotencyKey }) for registering verified app-stored artifacts when artifactProviders are configured. Absent on an app call. |
ctx.callTool, ctx.callSubagent | Composition. See Agent Workflows. |
Durable tools also get ctx.requestInput, ctx.waitForApproval, ctx.sleepUntil, ctx.step, ctx.now, ctx.random, and ctx.artifactJobs. See Durable Tools.
The run's user
ctx.userId names the person who signed in to the chat, who saved a scheduled run, whom an operator named for a tool or agent run, or who is signed in to the app page that called the tool. It is kept across durable resumes. Its form follows the sign-in: an Amodal user id, a WorkOS user id when the agent verifies WorkOS tokens itself, or idp:<sub> for another identity provider. amodal dev --user and an eval's user set it. Treat an id your directory does not know as no one.
ctx.request rules
ctx.request resolves the connection's base URL, attaches its credentials and applies the connection's field restrictions to the response. It refuses an endpoint with a dot segment, a backslash or a control character. It does not evaluate policy.json permissions or confirmation, and it does not retry. Enforce authorization in the tool or the downstream API.
The call's intent defaults to write for POST, PUT, PATCH, and DELETE, and to read otherwise. A read-only tool (exposure.kind: "open" in tool.ts, or confirm: false in tool.json) throws on write-intent calls. Pass intent: 'read' for a read-only POST, such as a search endpoint:
const report = await ctx.request('analytics', 'properties/123:runReport', {
method: 'POST',
intent: 'read',
data: { metrics: [{ name: 'eventCount' }] },
});Naming
Tool names must be snake_case: lowercase letters, digits, and underscores, starting with a letter.
Task progress plans
The runtime provides update_plan as a built-in control tool, including on scoped agent surfaces.
It accepts a full ordered plan of { step, status } items and an optional explanation.
Statuses are pending, in_progress, and completed; at most one step may be in progress.
Each successful call replaces the previous checklist. An empty list clears it. Invalid updates
leave the last accepted plan intact.
Use progress plans for substantial multi-step work, and revise them as the user's request changes.
A completed checklist does not end the turn, validate an artifact, or authorize an action.
This checklist is separate from planning-only mode, where update_plan is rejected.
Updates are published as plan_updated SSE events (data-plan-updated through the AI SDK route)
and saved in ordinary tool results. The React widget reads accepted results for consistent live
and restored views. The latest plan's tool exchange remains verbatim through result clearing
and context compaction. Plans are scoped to the conversation, not shared across sessions.
The tool follows Codex's update_plan input contract and replacement behavior. Amodal additionally
rejects blank step labels and enforces the one-active-step rule at execution time. Its SSE transport
and structured persisted result are Amodal-specific; they are not Codex's JSON-RPC protocol.