Core primitives
Start with the choice that shapes the rest of your application:
- Python
- TypeScript
- Rust
- Go
- C#
- Java
import asyncio
from ish import Agent, tool
@tool
async def double(value: int) -> int:
"""Double an integer."""
return value * 2
async def main() -> None:
agent = Agent(
name="math_assistant",
model="gpt-4o-mini",
instructions="Use the supplied tool when computing values.",
tools=[double],
)
result = await agent.run("Double 21.")
print(result.content)
asyncio.run(main())
import { Agent } from "ish-harness";
const agent = new Agent({
name: "math_assistant",
model: { provider: "openai_chat", name: "gpt-4o-mini" },
instructions: "Use the supplied tool when computing values.",
tools: [
{
name: "double",
description: "Double an integer.",
parameters: {
type: "object",
properties: { value: { type: "integer" } },
required: ["value"],
},
execute: async (args) => Number((args as { value: number }).value) * 2,
},
],
});
const result = await agent.run("Double 21.");
console.log(result.content);
use std::{env, io, 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"]
}))
}
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())
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let model = OpenAIModel::new(
"gpt-4o-mini".into(),
"https://api.openai.com/v1".into(),
env::var("OPENAI_API_KEY")?,
0.2,
);
let agent = Agent::builder(Arc::new(model))
.name("math_assistant")
.instructions("Use the supplied tool when computing values.")
.tool(Arc::new(DoubleTool))
.build()
.map_err(io::Error::other)?;
let result = agent.run("Double 21.").await.map_err(io::Error::other)?;
println!("{}", result.content);
Ok(())
}
package main
import (
"context"
"fmt"
"github.com/ish-harness/ish-harness/sdks/go"
)
func main() {
client, err := ish.NewClient()
if err != nil {
panic(err)
}
defer client.Close()
agent := ish.NewAgent(client, ish.AgentRunRequest{
AgentName: "math_assistant",
Model: &ish.AgentModel{Provider: "openai_chat", Name: "gpt-4o-mini"},
SystemPrompt: ish.StringPtr("Use the supplied tool when computing values."),
Tools: []ish.AgentTool{
{
Name: "double",
Description: "Double an integer.",
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
},
},
},
})
res, err := agent.Run(context.Background(), "Double 21.")
if err != nil {
panic(err)
}
fmt.Println(res["content"])
}
using System.Text.Json;
using Ish.Harness;
using var ish = new IshClient();
using var schema = JsonDocument.Parse(
"""{"type":"object","properties":{"value":{"type":"integer"}},"required":["value"]}""");
var result = ish.Run(new AgentRunRequest
{
AgentName = "math_assistant",
Model = new AgentModel { Provider = "openai_chat", Name = "gpt-4o-mini" },
SystemPrompt = "Use the supplied tool when computing values.",
UserPrompt = "Double 21.",
Tools =
[
new AgentTool
{
Name = "double",
Description = "Double an integer.",
Parameters = schema.RootElement.Clone(),
Execute = (args, _) => ValueTask.FromResult<object?>(args.GetProperty("value").GetInt64() * 2),
},
],
});
Console.WriteLine(result.GetProperty("content").GetString());
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.ishharness.IshClient;
import java.nio.file.Path;
public class Main {
public static void main(String[] args) throws Exception {
var schema = new ObjectMapper().readTree(
"{\"type\":\"object\",\"properties\":{\"value\":{\"type\":\"integer\"}},\"required\":[\"value\"]}");
try (var ish = new IshClient(Path.of(System.getenv("ISH_NATIVE_LIBRARY")))) {
var request = new IshClient.AgentRequest(
"gpt-4o-mini",
"Use the supplied tool when computing values.",
"Double 21.")
.provider("openai_chat")
.agentName("math_assistant")
.tool("double", "Double an integer.", schema, toolArgs -> toolArgs.path("value").asInt() * 2);
System.out.println(ish.runAgent(request).path("content").asText());
}
}
}
- Use an
Agentwhen the model should decide which tool to call next. - Use a
DurableWorkflowwhen your code should decide which step runs next.
Both use shared Rust runtime operations for portable execution and state. SDKs also adapt user callbacks, language runtimes, opaque host objects, and native or HTTP/MCP transports. Public APIs and adapter behavior can differ by language. Add tools, context, memory, permissions, and persistence as needed.
Shared execution model
Your application starts an agent or workflow. During execution, both can call tools and use the same context and persistence facilities. Large values can be kept outside the model conversation and fetched by the runtime when a tool needs them.
The diagram shows shared building blocks, not a required setup. An agent can run without a database, and a workflow can use an in-memory store for local work. Persistence is needed when you want state to survive process restarts.
Choose the right primitive
| Need | Start with | Why |
|---|---|---|
| Let a model choose tools based on results | Agent | The next action can change as the model learns |
| Run known steps and branches with replay | DurableWorkflow | Application-defined control flow is checkpointed |
| Share facts or documents with tools and subagents | ContextStore | State is stored separately from the conversation |
| Limit or approve sensitive tool calls | Permissions and guardrails | Policy is applied around tool execution |
| Keep large results out of later prompts | Tool output management | Results can be stored and referenced compactly |
The runtime cannot guarantee that a model request succeeds or that a separate service accepted an action only once. For actions such as sending a payment, use a request ID that makes retries safe, or check the service's status before retrying after an interruption.
Building block ownership
| Building block | Owns | Add it when you need |
|---|---|---|
Agent | Model and tool loop | The next action depends on model output |
DurableWorkflow | Named steps and replay | The sequence is known and must survive restarts |
ContextStore | Shared values and documents | Tools or subagents need common task data |
| Skills and memory | Reusable instructions and durable facts | Agents need repository or domain knowledge |
| Persistence | Run history and checkpoints | You need inspection, resume, or recovery |