> ## Documentation Index
> Fetch the complete documentation index at: https://psychiatrist.sudo.la/llms.txt
> Use this file to discover all available pages before exploring further.

# Agents and providers

> An agent is a provider value: the harness, its model and options, and where its sessions are kept.

An agent is passed to `start()` and `run()` as a provider value, as in sandcastle ([ADR 0009](https://github.com/psychiatrist/psychiatrist/blob/main/docs/adr/0009-agents-and-sandboxes-as-provider-values.md)): the harness it runs on, the model passed to that harness as written, and the provider's own options.

```ts theme={null}
import { claudeCode, start } from "@psychiatrist/core";

const session = await start({ agent: claudeCode("claude-opus-5-5", { effort: "high", env: { CLAUDE_CONFIG_DIR: "/accounts/bot" } }) });
```

## Options every provider takes

| Option | Meaning |
| - | - |
| `effort` | `low`, `medium`, `high` or `max`, the four levels psychiatrist uses whatever a harness calls them; a turn can change it |
| `env` | set on the agent's own process alone, over the inherited environment, never on a command line; how you give an agent a login of its own |
| `captureSessions` Planned · #14 | `false` turns off copying a sandboxed session's record back to your own harness folder after every turn ([Sandboxes](https://psychiatrist.sudo.la/sdk/sandboxes.md)) |

## The providers

| Provider | Harness | Status |
| - | - | - |
| `claudeCode(model, options?)` | Claude Code, on your own install | available |
| `codex(model, options?)` | Codex, in app-server mode; its declines carry no reason, so the guard's rules go in the agent's prompt | Planned · #8 |
| `opencode(model, options?)` | opencode 2.x, one server per session; no `effort` (its models' levels cannot be listed) | Planned · #9 |
| `pi(model, options?)` | pi, driven over its RPC mode; the guard runs as a pi extension | Planned · #10 |

## A provider of your own

Any harness becomes an agent as `{ harness, model, effort?, env? }`. A `Harness` starts sessions, sends them turns, steers, interrupts, forks and closes them, and says whether it is ready (installed and signed in, with the provider's `env`).

## Where sessions are kept

A provider's harness keeps its session records where its own resume finds them: Claude Code's under `~/.claude/projects/` (`CLAUDE_CONFIG_DIR` in the provider's `env` moves it). `start({ resume })` checks the record is there before anything starts, and rejects with `SessionNotFoundError` when it is gone. When a resumed session works somewhere new, its newest record is carried to that place's folder, its `cwd` fields rewritten, unless the copy there holds messages the newest lacks; a title the person gave that copy stays its title.

A harness of your own resumes only when it has `sessions` (`exists` and `carry` its records), as sandcastle's providers need session storage. Without them it still runs and its open sessions fork, but `start({ resume })` rejects with `ResumeNotSupportedError` before anything starts.

## Errors

| Error | When |
| - | - |
| `TypeError` | `agent` is not a provider value (the old `"harness/model"` string, say), or `effort` or `harness` is given to `start()` itself |
| `SessionNotFoundError` | `start({ resume })` names a session the harness no longer has, or its newest record cannot be read |
| `ResumeNotSupportedError` | `start({ resume })` on a harness that keeps no session records |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.