Attach an action as a tool
Pass action definitions in thetools array of defineAgent(). The same action you’d use as a workflow step works here, unchanged.
src/agents/support.ts
input schema, runs run, and returns the output as the tool result.
How an action maps to a tool
The action’s metadata becomes the tool the model sees:
Because the model reads
description to decide when to call a tool, give tool actions a clear, action-oriented description. The output schema shapes what the agent gets back.
Design tool actions for the model
A tool action is read by the model, so write it for that audience:- Write a clear
description. The model uses it to decide when to call the tool. Say what it does and when to reach for it, in plain language. - Describe each input field. Add
.describe()to the fields in theinputschema. The schema becomes the tool’s parameters, so the descriptions tell the model what each argument means. - Keep the output lean. The action’s
outputis serialized to JSON and returned to the model as the tool result, so it counts against the context window. Return the fields the agent needs to act on, not entire upstream payloads.
src/actions/lookup-customer.ts
Use integration actions as tools
Integration packages export actions you can attach directly; you don’t redefine them. Import only the ones the agent should have.Credentials for tool actions
When an action declarescredentials, Keystroke resolves them before the tool runs; the agent never sees the secret. If an action can resolve credentials at more than one scope (organization, project, or user), pin the scope with .scope() when attaching it:
.scope("user"), also assign a user credential to that tool — user scope is not inferred from the run. See credentials for how scopes and connections work.
Beyond actions
Actions are the usual way to give an agent reliable capabilities, buttools also accepts other tool types: MCP tools, subagents, and workflows — import them directly into tools (no wrappers). See build agents for subagents and workflows as tools.
Agents can call these same tools from JavaScript or TypeScript when they need to compose several
calls or process results in a loop. See code mode.
Next steps
Actions as workflow steps
Run the same actions as durable steps in a workflow.
Build agents
Configure tools, models, skills, files, and more.
Credentials
Declare and scope the credentials a tool action needs.
Integrations
Browse built-in integration actions to attach as tools.