Skip to main content

Core primitives

Start with the choice that shapes the rest of your application:

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())
  • Use an Agent when the model should decide which tool to call next.
  • Use a DurableWorkflow when 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​

NeedStart withWhy
Let a model choose tools based on resultsAgentThe next action can change as the model learns
Run known steps and branches with replayDurableWorkflowApplication-defined control flow is checkpointed
Share facts or documents with tools and subagentsContextStoreState is stored separately from the conversation
Limit or approve sensitive tool callsPermissions and guardrailsPolicy is applied around tool execution
Keep large results out of later promptsTool output managementResults 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 blockOwnsAdd it when you need
AgentModel and tool loopThe next action depends on model output
DurableWorkflowNamed steps and replayThe sequence is known and must survive restarts
ContextStoreShared values and documentsTools or subagents need common task data
Skills and memoryReusable instructions and durable factsAgents need repository or domain knowledge
PersistenceRun history and checkpointsYou need inspection, resume, or recovery

Continue reading​