Skip to main content

Add the crate

The SDK is currently a workspace crate. From a checkout of this repository, add it by path together with a Tokio runtime:
Versioning: The facade is at 0.7.0 and is not yet on crates.io. Depend on it by git tag, for example orcacode-v0.7.0, and expect the API to change before 1.0.

Build your first agent

A Harness owns workspace-scoped paths. An Agent is reusable configuration. A Session owns conversation context, and each run adds one turn.
The workspace must already exist and is canonicalized during build(). State defaults to <workspace>/.orca; use .state_dir(...) when generated state should live elsewhere.

One shot or multiple turns

agent.run(...) creates a fresh ephemeral session for each call. Retain a session when later requests need earlier context:

Add tools behind a policy

FnTool turns an async Rust closure into a model-callable JSON boundary. Validate arguments in the closure even when the schema marks them as required.
Policy is not isolation: ToolPolicy decides whether a registered call may execute. It does not constrain the process, filesystem, or network. An empty allowlist does not mean “deny all”; name the exact allowed tools or use a rule that denies by default.

Observe a run

Enable event and usage extensions on the agent, then attach request-specific handling. Provider support determines whether token counts are populated.

Continue, cancel, and inspect outcomes

continue_run asks for another assistant turn on the current transcript without appending a user message; it requires an existing turn to continue. Pass a caller-owned token to cancel a run from elsewhere:
run() returns an error on execution or persistence failure, discarding partial accounting. run_outcome() retains the transcript and usage even on failure or cancellation; check execution and persistence separately. It still returns an error if the run cannot start.

Persist and branch conversations

Ephemeral sessions retain history only while the value is alive. Persistent sessions record transcripts beneath the harness state directory and can be listed, resumed, and forked.

Import existing context

Seed a new session from messages you already have; a persistent session writes the imported history on open:
The agent’s system prompt replaces a leading imported system message, or is prepended if none exists. Without an agent system prompt, a leading imported system message remains. open() rejects malformed history, including unmatched tool-call exchanges. Persistence restores conversation and truncation-recovery data, not live processes, REPLs, detached workers, workflows, notifications, or pending completions.