Tools
Tools are the actions an agent can request, such as looking up an order or reading a file. Each tool has a name, a description, an input schema, and an implementation. Before running it, ISH checks the arguments and configured permissions; after it runs, ISH checks the result and returns it to the model.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
from ish import Agent, tool
@tool
def double(value: int) -> int:
"""Double an integer."""
return value * 2
agent = Agent(
name="math_agent",
model="gpt-4o-mini",
instructions="Use the supplied tool when it helps answer.",
tools=[double],
)
import { Agent } from "ish-harness";
const agent = new Agent({
name: "math_agent",
model: { provider: "openai_chat", name: "gpt-4o-mini" },
instructions: "Use the supplied tool when it helps answer.",
tools: [
{
name: "double",
description: "Double an integer.",
parameters: {
type: "object",
properties: { value: { type: "integer" } },
required: ["value"],
},
read_only: true,
execute: async (args) => Number((args as { value: number }).value) * 2,
},
],
});
use std::sync::Arc;
use async_trait::async_trait;
use ish_harness::{data_plane::tool_backend::ToolBackend, Agent, OpenAIModel};
use serde_json::{json, Value};
struct DoubleTool;
#[async_trait]
impl ToolBackend for DoubleTool {
fn name(&self) -> &str {
"double"
}
fn description(&self) -> &str {
"Double an integer."
}
fn schema_json(&self) -> Option<Value> {
Some(json!({
"type": "object",
"properties": { "value": { "type": "integer" } },
"required": ["value"]
}))
}
fn read_only(&self) -> bool {
true
}
async fn call(&self, arguments: Value) -> Result<String, String> {
let value = arguments["value"]
.as_i64()
.ok_or_else(|| "value must be an integer".to_string())?;
Ok((value * 2).to_string())
}
}
fn build_agent(model: Arc<OpenAIModel>) -> Result<Agent, String> {
Agent::builder(model)
.name("math_agent")
.instructions("Use the supplied tool when it helps answer.")
.tool(Arc::new(DoubleTool))
.build()
}
agent := ish.NewAgent(client, ish.AgentRunRequest{
AgentName: "math_agent",
Model: &ish.AgentModel{Provider: "openai_chat", Name: "gpt-4o-mini"},
SystemPrompt: ish.StringPtr("Use the supplied tool when it helps answer."),
Tools: []ish.AgentTool{
{
Name: "double",
Description: "Double an integer.",
ReadOnly: ish.BoolPtr(true),
Parameters: map[string]any{
"type": "object",
"properties": map[string]any{
"value": map[string]any{"type": "integer"},
},
"required": []string{"value"},
},
Execute: func(ctx context.Context, args map[string]any) (any, error) {
v, _ := args["value"].(float64)
return int64(v) * 2, nil
},
},
},
})
using System.Text.Json;
using Ish.Harness;
using var schema = JsonDocument.Parse(
"""{"type":"object","properties":{"value":{"type":"integer"}},"required":["value"]}""");
var request = new AgentRunRequest
{
AgentName = "math_agent",
Model = new AgentModel { Provider = "openai_chat", Name = "gpt-4o-mini" },
SystemPrompt = "Use the supplied tool when it helps answer.",
UserPrompt = "Double 21.",
Tools =
[
new AgentTool
{
Name = "double",
Description = "Double an integer.",
Parameters = schema.RootElement.Clone(),
ReadOnly = true,
Execute = (args, _) => ValueTask.FromResult<object?>(args.GetProperty("value").GetInt64() * 2),
},
],
};
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.ishharness.IshClient;
var schema = new ObjectMapper().readTree(
"{\"type\":\"object\",\"properties\":{\"value\":{\"type\":\"integer\"}},\"required\":[\"value\"]}");
var request = new IshClient.AgentRequest(
"gpt-4o-mini",
"Use the supplied tool when it helps answer.",
"Double 21.")
.provider("openai_chat")
.agentName("math_agent")
.tool(
"double",
"Double an integer.",
schema,
args -> args.path("value").asInt() * 2,
new IshClient.AgentToolOptions().readOnly(true));
Python's @tool can infer a tool's name, description, and JSON Schema from type
annotations and a docstring. TypeScript, Go, C#, and Java normally declare the
JSON Schema explicitly. The SDKs use the same Rust execution and policy rules.
How tool calls are checked
Before a tool runs, the runtime checks its arguments against the declared schema and applies configured permissions and guardrails. If an argument contains an authorized data reference, the runtime resolves it before calling the tool. It checks the result before returning it to the model and can save large output outside the prompt.
Tools that read without changing state may run concurrently when a model requests them together. Tools that write, need approval, or rely on ordered checks run in sequence. For sensitive tools, declare the schema precisely and apply least-privilege permissions.
Choose tool behavior
| Behavior | Use it for |
|---|---|
| Read-only | Looking up data without changing it |
| Parallel-safe | Independent reads that can run together |
| Approval required | Actions that need a person to confirm |
| Skill-gated | Tools that should appear only for an active skill |
| Direct return | A tool whose result should end the agent turn |
Declare the input schema and side effects honestly. The runtime uses those declarations to decide which tools to expose and whether they may run concurrently. See the API reference for advanced tool options and staged execution.
Tool errors, staged results
A recoverable error is returned to the model as a tool result so it can adjust its next action. A fatal error stops the run when continuing would be unsafe. Staged changes are published only when the result passes configured checks.
Tool callbacks execute in your application. Pair them with Guardrails, Tool Output Management, and skill gating when they access sensitive resources.