Building Tools

Define tools for agents using the fluent builder API.


Tool Types

Agents can use several types of tools:

TypeDescription
ClientExecuted by your code (with handler)
AppRuns an inference shell app
AgentDelegates to a sub-agent
WebhookPOST to an external URL (unsigned or HMAC-signed)
HTTP / CallAuthenticated REST calls with runtime credential injection
InternalBuilt-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 parameter

Tool 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:

json
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).
  • _action is 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, action is empty; show display_name or the tool name instead.
  • _action is reserved: a tool that declares it has it replaced.

→ Tool invocation fields

Each type carries its configuration under a key of its own, and type says which key is read:

typeConfig keyDocumented in
clientclientClient Tools
appappApp Tools
agentagentAgent Tools
callcallCall Tools
httphttpCall Tools — call is preferred
hookhookWebhook Tools
mcpmcpConnector Tools
internalnoneInternal Tools

Learn More

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.