Workflow Primitives
Tools and durable workflow steps are shared runtime concepts exposed with
language-idiomatic bindings. Python provides @tool, @step, and @workflow
decorators; TypeScript, Go, C#, and Java configure AgentTool descriptors and
DurableWorkflow; Rust uses ToolBackend and run_durable_step.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
from ish import tool
@tool(requires_approval=True, read_only=False)
async def update_account(account_id: str, status: str) -> dict[str, str]:
"""Update an account status after approval."""
return {"account_id": account_id, "status": status}
import type { ToolDefinition } from "ish-harness";
const updateAccount: ToolDefinition = {
name: "update_account",
description: "Update an account status after approval.",
parameters: {
type: "object",
properties: {
account_id: { type: "string" },
status: { type: "string" },
},
required: ["account_id", "status"],
},
requires_approval: true,
read_only: false,
execute: async (args) => {
const { account_id, status } = args as { account_id: string; status: string };
return { account_id, status };
},
};
use async_trait::async_trait;
use ish_harness::data_plane::tool_backend::ToolBackend;
use serde_json::{json, Value};
struct UpdateAccountTool;
#[async_trait]
impl ToolBackend for UpdateAccountTool {
fn name(&self) -> &str {
"update_account"
}
fn description(&self) -> &str {
"Update an account status after approval."
}
fn schema_json(&self) -> Option<Value> {
Some(json!({
"type": "object",
"properties": {
"account_id": { "type": "string" },
"status": { "type": "string" }
},
"required": ["account_id", "status"]
}))
}
fn requires_approval(&self) -> bool {
true
}
fn read_only(&self) -> bool {
false
}
async fn call(&self, arguments: Value) -> Result<String, String> {
Ok(json!({
"account_id": arguments["account_id"],
"status": arguments["status"]
})
.to_string())
}
}
updateAccountTool := ish.AgentTool{
Name: "update_account",
Description: "Update an account status after approval.",
RequiresApproval: ish.BoolPtr(true),
ReadOnly: ish.BoolPtr(false),
Parameters: map[string]any{
"type": "object",
"properties": map[string]any{
"account_id": map[string]any{"type": "string"},
"status": map[string]any{"type": "string"},
},
"required": []string{"account_id", "status"},
},
Execute: func(ctx context.Context, args map[string]any) (any, error) {
return map[string]any{
"account_id": args["account_id"],
"status": args["status"],
}, nil
},
}
using System.Text.Json;
using Ish.Harness;
using var schema = JsonDocument.Parse(
"""{"type":"object","properties":{"account_id":{"type":"string"},"status":{"type":"string"}},"required":["account_id","status"]}""");
var updateAccountTool = new AgentTool
{
Name = "update_account",
Description = "Update an account status after approval.",
Parameters = schema.RootElement.Clone(),
RequiresApproval = true,
ReadOnly = false,
Execute = (args, _) => ValueTask.FromResult<object?>(new
{
account_id = args.GetProperty("account_id").GetString(),
status = args.GetProperty("status").GetString(),
}),
};
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.ishharness.IshClient;
import java.util.Map;
var mapper = new ObjectMapper();
var schema = mapper.readTree(
"{\"type\":\"object\",\"properties\":{\"account_id\":{\"type\":\"string\"},\"status\":{\"type\":\"string\"}},\"required\":[\"account_id\",\"status\"]}");
request.tool(
"update_account",
"Update an account status after approval.",
schema,
args -> Map.of(
"account_id", args.path("account_id").asText(),
"status", args.path("status").asText()),
new IshClient.AgentToolOptions().requiresApproval(true).readOnly(false));
Tool definitions
In Python, @tool infers the tool name, description, and JSON Schema from type
annotations and docstrings. Other languages pass explicit JSON Schema
definitions or Rust ToolBackend implementations with the same safety and
scheduling metadata (requires_approval, read_only, return_direct,
secret_inputs, unfoldable, mutates, parallel_safe):
Durable workflow steps
Steps accept retries, backoff_seconds, and backoff_factor evaluated by the
shared Rust RetryPolicy. Retry callbacks may run more than once, so keep
external side effects idempotent:
- Python
- TypeScript
- Rust
- Go
- C#
- Java
from ish import SQLiteLogger, step, workflow
logger = SQLiteLogger(db_path="./data/workflow.db")
@step(retries=2, backoff_seconds=0.5)
async def validate_record(record_id: str) -> dict[str, str]:
return {"record_id": record_id, "status": "valid"}
@workflow(name="record_check", persistence=logger)
async def record_check(record_id: str) -> dict[str, str]:
return await validate_record(record_id)
import { DurableWorkflow, IshClient } from "ish-harness";
const client = new IshClient();
const wf = new DurableWorkflow(client, "record_check", "./data/workflow.db");
const result = await wf.runHostStep(
"validate_record",
{ record_id: "rec-1" },
async (input) => {
const { record_id } = input as { record_id: string };
return { record_id, status: "valid" };
},
{ retries: 2, backoffSeconds: 0.5 },
);
console.log(result);
wf.close();
client.close();
use async_trait::async_trait;
use ish_harness::persistence::SqliteWalLogger;
use ish_harness::workflows::{run_durable_step, StepFn};
use serde_json::{json, Value};
struct ValidateRecord;
#[async_trait]
impl StepFn for ValidateRecord {
async fn execute(&self, input: Value) -> Result<Value, String> {
Ok(json!({ "record_id": input["record_id"], "status": "valid" }))
}
}
let logger = SqliteWalLogger::new("./data/workflow.db")?;
let result = run_durable_step(
&logger,
"record_check",
"validate_record",
"validate-rec-1",
json!({ "record_id": "rec-1" }),
false,
2,
0.5,
2.0,
&ValidateRecord,
)
.await?;
wf, err := ish.NewDurableWorkflow(client, "record_check", "./data/workflow.db")
if err != nil {
panic(err)
}
defer wf.Close()
result, err := wf.RunHostStep(
ctx,
"validate_record",
map[string]any{"record_id": "rec-1"},
func(_ context.Context, input any) (any, error) {
m := input.(map[string]any)
return map[string]any{"record_id": m["record_id"], "status": "valid"}, nil
},
ish.HostDurableStepOptions{Retries: 2, BackoffSeconds: 0.5},
)
using System.Text.Json;
using Ish.Harness;
using var client = new IshClient();
using var wf = new DurableWorkflow(client, "record_check", "./data/workflow.db");
using var inputDoc = JsonDocument.Parse("""{"record_id":"rec-1"}""");
var result = await wf.RunHostStepAsync(
"validate_record",
inputDoc.RootElement,
(input, _) => ValueTask.FromResult<object?>(new
{
record_id = input.GetProperty("record_id").GetString(),
status = "valid",
}),
new HostDurableStepOptions(Retries: 2, BackoffSeconds: 0.5));
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.ishharness.DurableWorkflow;
import java.util.Map;
try (var wf = new DurableWorkflow(client, "record_check", "./data/workflow.db")) {
var input = new ObjectMapper().createObjectNode().put("record_id", "rec-1");
var opts = new DurableWorkflow.HostStepOptions(null, null, false, 2, 0.5, 2.0);
var result = wf.runHostStepSync(
"validate_record",
input,
in -> Map.of("record_id", in.path("record_id").asText(), "status", "valid"),
opts);
System.out.println(result);
}
See Tools, Durable workflows, and the individual SDK READMEs for current API details.