Types, Error Signals
The core runtime uses a consistent JSON schema for AgentResult, StreamEvent,
ChatMessage, ToolCall, ModelResponse, approval interruptions, and budget
errors across all six SDKs. Host SDKs wrap these contracts in native structs,
records, interfaces, and exceptions.
- Python
- TypeScript
- Rust
- Go
- C#
- Java
import asyncio
from ish import Agent, ApprovalRequired, BudgetExceededError
async def run_checked(agent: Agent, prompt: str) -> None:
try:
result = await agent.run(prompt)
print(result.content, result.total_tokens)
except ApprovalRequired as signal:
print(f"Approval required: {signal.tool_name} ({signal.snapshot_id})")
except BudgetExceededError as err:
print(f"Budget exceeded ({err.metric}): {err.current_value} > {err.limit}")
import {
Agent,
ApprovalRequiredError,
DataPlanePolicyViolationError,
type AgentResult,
} from "ish-harness";
async function runChecked(agent: Agent, prompt: string): Promise<void> {
try {
const result: AgentResult = await agent.run(prompt);
console.log(result.content, result.total_tokens);
} catch (err) {
if (err instanceof ApprovalRequiredError) {
console.log(`Approval required: ${err.action.name} (${err.snapshotId})`);
} else if (err instanceof DataPlanePolicyViolationError) {
console.error(`Policy denied: ${err.message}`);
} else {
throw err;
}
}
}
use ish_harness::data_plane::types::{AgentResult, StreamEvent};
use ish_harness::Agent;
async fn inspect_run(agent: &Agent, prompt: &str) -> Result<(), String> {
let result: AgentResult = agent.run(prompt).await?;
println!("content={} tokens={}", result.content, result.total_tokens);
let _sample = StreamEvent {
event_type: "done".to_string(),
data: serde_json::json!({}),
..StreamEvent::default()
};
Ok(())
}
result, err := agent.Run(ctx, prompt)
if err != nil {
var ishErr *ish.IshError
if errors.As(err, &ishErr) {
fmt.Printf("ISH error [%s]: %s\n", ishErr.Code, ishErr.Message)
return
}
panic(err)
}
fmt.Println(result["content"], result["total_tokens"])
using Ish.Harness;
try
{
var result = client.Run(request);
Console.WriteLine(result.GetProperty("content").GetString());
}
catch (ApprovalRequiredException ex)
{
Console.WriteLine($"Approval required: {ex.Action} ({ex.SnapshotId})");
}
catch (DataPlanePolicyViolationException ex)
{
Console.Error.WriteLine($"Policy denied: {ex.Message}");
}
catch (IshException ex)
{
Console.Error.WriteLine($"ISH error: {ex.Message}");
}
import io.github.ishharness.ApprovalRequiredException;
import io.github.ishharness.DataPlanePolicyViolationException;
import io.github.ishharness.IshClient;
try {
var result = client.runAgent(request);
System.out.println(result.path("content").asText());
} catch (ApprovalRequiredException ex) {
System.out.println("Approval required: " + ex.snapshotId());
} catch (DataPlanePolicyViolationException ex) {
System.err.println("Policy denied: " + ex.getMessage());
} catch (IshClient.IshException ex) {
System.err.println("ISH error: " + ex.getMessage());
}
Results, approvals, runtime errors
Catch approval interrupts (ApprovalRequired / ApprovalRequiredError /
ApprovalRequiredException) and runtime or policy errors cleanly across SDKs:
Core shared fields
| Type | Key fields shared across SDKs |
|---|---|
AgentResult | trace_id, content, history, tool_calls_count, duration_ms, total_tokens, prompt_tokens, completion_tokens, total_cost_usd, model_usages |
StreamEvent | event_type (token, tool_call, observation, done), data, optional trace_id, sequence |
ChatMessage | role (user, assistant, system, tool), content, tool_calls, tool_call_id, name |
ToolCall | id, name, arguments |
ModelResponse | content, tool_calls, prompt_tokens, completion_tokens, total_tokens, provider, model |
Error signal catalog
| Condition | Python / TypeScript | Rust / Go | C# / Java |
|---|---|---|---|
| Human approval interrupt | ApprovalRequired / ApprovalRequiredError | Err(...) / *ish.IshError | ApprovalRequiredException |
| Workflow step approval | ApprovalRequired / WorkflowStepApprovalRequiredError | WorkflowStepOutcome::PendingApproval / *ish.IshError | WorkflowStepApprovalRequiredException |
| Environment drift on resume | ValueError / ApprovalEnvironmentDriftError | Err(...) / *ish.IshError | ApprovalEnvironmentDriftException |
| Policy denied | DataPlanePolicyViolationError | Err(...) / *ish.DataPlanePolicyError | DataPlanePolicyViolationException |
| Budget or ABI failure | BudgetExceededError / Error | Err(...) / *ish.IshError | IshException |