Skip to main content
Look up an Agent SDK function or type by what it does, then find its name in your language. Usage shows how the pieces fit together. TypeScript is the reference design; where a language lacks something, its cell says so.

Create an agent

Creates an agent from a definition. The definition’s step limit applies to each run or continue call.

Definition fields

Rust builds the definition with methods instead of fields: AgentDefinition::new(id, model), then .instructions(text), .tool(tool) (once per tool), .max_steps(limit), .model_retries(count, backoff) and .human_review(callback). Java’s AgentDefinition is a record with 10-, 13- and 19-argument constructors. In TypeScript, model, instructions and the sampling values can be fixed or dynamic.

Define a tool

Tools lists every tool field.

Connect to Phaseo Gateway

Outputs and retries lists the client options in each language.

Capture runs locally

See DevTools.

Stop conditions

Go and Java return a StopCondition; C# returns a Func<StopState, (bool Stop, string Reason)>; PHP returns a callable; Ruby returns a lambda. Rust has no stop conditions, only the step limit. See Stop conditions.

Run and continue

Run and continue return a run result: a Promise<AgentRunResult> in TypeScript, (RunResult, error) in Go, Task<RunResult> in C#, Result<RunResult, AgentError> in Rust, and the run result directly elsewhere. Stream methods return a stream result immediately.

Run options

PHP and Ruby take these as named or keyword arguments; Java’s RunOptions is a positional record in the order input, client, context, model, preset, maxSteps, modelRetry, toolExecution, onEvent, devtools, then an optional state. Python’s run() also accepts stop_when but ignores it; set stop conditions on the definition. PHP’s stream() and Ruby’s stream take only input, client, context and state. Rust creates defaults with RunOptions::new(input).

Continue options

Continue options take the run overrides above, plus: Java’s ContinueOptions order is run, client, context, model, preset, maxSteps, humanInput, modelRetry, toolExecution, onEvent, devtools, then approvals, rejections, toolOutputs, then runId, state. Besides this 16-argument form, it has constructors that take only the first 11 or the first 14 arguments; the rest default to empty lists or null. Rust creates defaults with ContinueOptions::new(result).

Stream result

Consumers replay from the start, so several can read the same run. How they behave differs:

Run result

The type is AgentRunResult in TypeScript and Python and RunResult elsewhere. TypeScript adds stepResults (normalized step results) and items (ordered messages, reasoning, tool activity, errors and final output; see Items). In Rust, output is a serde_json::Value, and RunResult, RunRecord, RunStep, Message, ToolCall, HumanPause, PendingToolCall, ToolDecision, ToolOutput and UsageSummary serialize with Serde.

Run record

Rust’s RunRecord also stores the effective model and step limit. TypeScript adds errorDetails with gateway error details. Run statuses are queued, running, waiting_for_tools, waiting_for_human, completed, stopped and failed. TypeScript adds cancelled.

Step record

The type is RunStep everywhere except TypeScript and Python (AgentStepRecord).

Usage summary

inputTokens, outputTokens, cachedTokens, totalTokens, cost (TypeScript, Java); input_tokens, output_tokens, cached_tokens, total_tokens, cost (Python, PHP and Ruby keys, Rust); InputTokens, OutputTokens, CachedTokens, TotalTokens, Cost (Go, C#). The type is AgentUsageSummary in TypeScript and Python and UsageSummary in Go, C#, Java and Rust. PHP and Ruby use an array or Hash. See Observability for caveats about cost.

Pauses and decisions

Field names follow each language’s style: toolCallId (TypeScript, PHP, Java), tool_call_id (Python, Ruby, Rust), ToolCallID (Go) and ToolCallId (C#). Rust’s ToolDecision is approval only. See State and approval.

Runtime context passed to tools

State accessor

Model clients

Implement a model client to send model turns through another transport, or to wrap the gateway client. In Rust, ModelRequest holds the agent ID, effective model, instructions, current messages, tool specifications (ToolSpec: id, description, JSON Schema parameters) and application context. ModelResponse holds message, usage, request_id, provider, model and finish_reason. Message has role, content, tool_calls, tool_call_id, name and is_error, with Message::user(content) and Message::assistant(content) constructors; ToolCall has id, name and JSON input.

Events and errors

TypeScript also exports agentErrorIsRetryable(), agentRetryAfterMs() and agentErrorIsContextOverflow() to classify errors, repairToolHistory(messages) to answer tool calls left without a result and drop results that answer no call, and truncateToolOutput(text, limit) to keep the start and end of long text with a notice of what was cut. See Lifecycle hooks and Events and errors.
Last modified on November 5, 2026