Define tools for agents using the fluent builder API.
Tool Types
Agents can use several types of tools:
| Type | Description |
|---|---|
| Client | Executed by your code (with handler) |
| App | Runs an inference shell app |
| Agent | Delegates to a sub-agent |
| Webhook | POST to an external URL (unsigned or HMAC-signed) |
| HTTP / Call | Authenticated REST calls with runtime credential injection |
| Internal | Built-in: plan, memory, widgets, finish |
Quick Example
1from inferencesh import tool, string23greet = (4 tool("greet")5 .describe("Greet a user")6 .param("name", string("User's name"))7 .handler(lambda args: f"Hello, {args['name']}!")8 .build()9)Parameter Types
All tool builders share these parameter types:
1from inferencesh import string, number, integer, boolean, enum_of, array, obj, optional23# Basic types4string("Description") # Text input5number("Description") # Decimal number6integer("Description") # Whole number7boolean("Description") # True/false89# Complex types10enum_of(["a", "b"], "desc") # Choice from list11array(string(), "desc") # List of items12obj({"key": string()}, "desc") # Nested object13optional(string()) # Optional parameterTool Definition Format
Every builder's .build() returns the same shape, which is also what the REST API accepts and returns. Write it by hand when you are not using an SDK:
1{2 "name": "search",3 "display_name": "Search Files",4 "description": "Search for files matching a pattern",5 "type": "client",6 "require_approval": false,7 "client": {8 "input_schema": {9 "type": "object",10 "properties": {11 "pattern": { "type": "string", "description": "Glob pattern to match" },12 "recursive": { "type": "boolean", "description": "Search subdirectories" }13 },14 "required": ["pattern"]15 }16 }17}name, description and type are required; display_name is what the UI shows, and require_approval pauses the call for a human. Optional approval_timeout (seconds) refuses a call nobody approves in time; omit it or set 0 to wait until answered (see Approval timeout). The tool builders have no method for it; set it on the built object. The parameters are JSON Schema.
Action labels
When an agent runs, the platform adds a required string parameter _action to every tool the model can call except finish. The model writes in it what the call does, for the user, in a few words that usually open with a verb (Fetch unread emails from alice@x.com).
- The runtime collapses whitespace, drops a trailing period, cuts the label to 120 characters, and stores it on the invocation as
action(ToolInvocationDTO.action: @inferencesh/sdk ≥ v0.34.0, inferencesh ≥ v0.36.0). _actionis removed from the arguments before the tool runs. Handlers, apps, MCP servers and webhooks get only the tool's own inputs.- When the model omits it,
actionis empty; showdisplay_nameor the tool name instead. _actionis reserved: a tool that declares it has it replaced.
Each type carries its configuration under a key of its own, and type says which key is read:
type | Config key | Documented in |
|---|---|---|
client | client | Client Tools |
app | app | App Tools |
agent | agent | Agent Tools |
call | call | Call Tools |
http | http | Call Tools — call is preferred |
hook | hook | Webhook Tools |
mcp | mcp | Connector Tools |
internal | none | Internal Tools |
Learn More
- Client Tools — Handler-based tools
- App Tools — Run inference shell apps
- Agent Tools — Delegate to sub-agents
- Call Tools — Authenticated HTTP API calls (YAML and SDK)
- Webhook Tools — Unsigned or signed POST webhooks
- Internal Tools — Plan, memory, widgets, remotes
- Approval Settings — Human-in-the-loop