Creating Tools
ConceptualRegistering custom capabilities, including dynamically synthesized tools.
Custom tools extend Pimsy into your systems. A good tool definition is narrow, idempotent where possible, and honest about its failure modes.
Definition#
import { defineTool } from class="tok-str">"@pimsy/sdk";
export const lookupInventory = defineTool({
name: class="tok-str">"inventory.lookup",
description:
class="tok-str">"Return current stock levels for a SKU across warehouses. Read-only. " +
class="tok-str">"Returns an empty array when the SKU does not exist.",
scope: class="tok-str">"connector.inventory",
effectClass: class="tok-str">"read_external",
parameters: {
type: class="tok-str">"object",
required: [class="tok-str">"sku"],
properties: {
sku: { type: class="tok-str">"string", pattern: class="tok-str">"^[A-Z0-class="tok-num">9-]{class="tok-num">4,class="tok-num">24}$" },
warehouseIds: { type: class="tok-str">"array", items: { type: class="tok-str">"string" }, maxItems: class="tok-num">20 }
},
additionalProperties: false
},
returns: {
type: class="tok-str">"object",
properties: {
sku: { type: class="tok-str">"string" },
levels: {
type: class="tok-str">"array",
items: {
type: class="tok-str">"object",
properties: {
warehouseId: { type: class="tok-str">"string" },
available: { type: class="tok-str">"integer" },
reserved: { type: class="tok-str">"integer" }
}
}
}
}
},
timeoutMs: class="tok-num">8000,
retry: { attempts: class="tok-num">3, on: [class="tok-str">"timeout", class="tok-str">"rate_limited", class="tok-str">"upstream_5xx"] },
async execute({ sku, warehouseIds }, ctx) {
const res = await ctx.http.get(class="tok-str">"/v2/inventory", { query: { sku, warehouseIds } });
return { sku, levels: res.data.levels };
}
});Writing the description#
The description is the primary signal used during tool selection. Describe the contract, not the marketing: what it returns, what it costs, what it will not do, and what an empty result means.
Dynamic tools#
When no registered tool can accomplish a step, Pimsy may synthesize a small purpose-built tool — typically a script against an already-authorized connector or dataset. Dynamic tools are not unrestricted code execution.
- They execute inside the run sandbox with the run network egress profile.
- They inherit the effective capability set and cannot widen it.
- They are recorded in the trace with their full source for review.
- They are ephemeral by default; promotion to a registered tool requires human review.
Last updated 2026-09-13

