# harness

> Thin durable turn loop that wires session-manager, context-manager, and llm-router into an agent loop; spawns sub-agents as child sessions.

| field | value |
|-------|-------|
| version | 1.11.5 |
| type | binary |
| license | Apache-2.0 |
| repo | https://github.com/iii-hq/workers |
| supported_targets | x86_64-apple-darwin, aarch64-apple-darwin, x86_64-pc-windows-msvc, aarch64-pc-windows-msvc, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-unknown-linux-musl, armv7-unknown-linux-gnueabihf |
| author | iii |

## installation

```sh
iii call compose::add worker=harness@1.11.5
```

## dependencies

- `ade` @ `latest`
- `configuration` @ `latest`
- `context-manager` @ `latest`
- `cron` @ `latest`
- `document` @ `latest`
- `fp` @ `latest`
- `ide` @ `latest`
- `iii-directory` @ `latest`
- `iii-observability` @ `latest`
- `judge` @ `latest`
- `llm-router` @ `latest`
- `provider-anthropic` @ `latest`
- `provider-openai` @ `latest`
- `provider-openai-codex` @ `latest`
- `queue` @ `latest`
- `session-manager` @ `latest`
- `state` @ `latest`

## readme

<div align="center">

# harness

**A thin, durable turn loop that turns a model plus a few iii workers into an agent.**

<p>
  <a href="#quickstart"><img alt="Install: iii call compose::add worker=harness" src="https://img.shields.io/badge/install-iii%20call%20compose%3A%3Aadd%20worker%3Dharness-0a84ff?style=flat-square"></a>
  <a href="../LICENSE"><img alt="License: Apache 2.0" src="https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square"></a>
  <a href="https://www.rust-lang.org"><img alt="Built with Rust" src="https://img.shields.io/badge/built%20with-rust-orange?style=flat-square&logo=rust&logoColor=white"></a>
  <a href="https://workers.iii.dev/workers/harness"><img alt="harness on the workers registry" src="https://workers.iii.dev/workers/harness/badge.svg"></a>
  <a href="https://workers.iii.dev/workers/ade"><img alt="ade on the workers registry" src="https://workers.iii.dev/workers/ade/badge.svg"></a>
</p>

</div>

`harness` is the thin, durable turn loop that turns a model plus a few iii
workers into an agent. It takes an incoming message, persists it, assembles a
context, streams a completion, runs any function calls the model requests, and
repeats until the turn stops — all as durable, resumable steps so a crash or
restart picks up mid-turn. It wires [`session-manager`](https://github.com/iii-hq/workers/tree/main/session-manager)
(transcript), [`context-manager`](https://github.com/iii-hq/workers/tree/main/context-manager) (token budgeting, soft
dependency), and [`llm-router`](https://github.com/iii-hq/workers/tree/main/llm-router) (generation); install those
alongside it for the full loop.

## Quickstart

Install the engine, export the Anthropic credential in the terminal that will
run the engine, initialize a project, and start it:

```bash
curl -fsSL https://install.iii.dev/iii/main/install.sh | sh
export ANTHROPIC_API_KEY='<your-anthropic-api-key>'
export OPENAI_API_KEY='<your-openai-api-key>'
iii project init iii-app && cd iii-app
iii compose --up
```

```bash
# New terminal, same folder. `compose::add` updates this Compose project.
cd iii-app
iii call compose::add worker=harness worker=ade
```

```bash
open http://localhost:3113
```

Create a session, select **Anthropic → Claude Sonnet 5**, and send your first
message. Then select **OpenAI → GPT-5.6 Luna** in the same chat and send another
message. Create a new chat and send one more message with GPT-5.6 Luna. The
providers read `ANTHROPIC_API_KEY` and `OPENAI_API_KEY` from the engine
environment, so credentials do not need to be pasted into or stored by the
Console.

`iii call compose::add worker=harness` installs every worker the loop needs (see the badges
above); you do not add them one by one. During bootstrap, the harness asks the
`queue` worker to define a dedicated `harness-turn` queue before it reports
ready. That queue is FIFO within each `session_id` and processes separate
sessions concurrently; startup fails if the queue cannot be ensured.

Every turn, sub-agent spawn, and provider call is one correlated trace: the
harness turn waterfall in the console. Failed descendants stamp the whole trace
as failed and carry standard error attributes. The session transcript keeps the
same recovery, partial-output, and blocked-reaction explanation after refresh.
Automatic generation recovery requires partial output from the failed response.
A startup failure with no output ends the turn with a durable failure notice;
it does not consume the partial-response recovery budget.

<p align="center">
  <img src="https://raw.githubusercontent.com/iii-hq/workers/main/harness/docs/images/console-traces.webp" alt="Harness turn waterfall in the iii console" width="100%">
</p>

The agent-facing function surface is deny-by-default: with no `functions.allow`
globs, every model-requested call is refused and the harness is a plain chat
loop. Allow functions in per-send (`options.functions.allow`) and gate them
with the optional [`approval-gate`](https://github.com/iii-hq/workers/tree/main/approval-gate) sibling.
A pattern is `<namespace>/<pattern>` to match the id only in that namespace, or a bare
`<pattern>` to match the id in every namespace; for example `laptop/shell::*`. A namespace
qualifier must be a plain namespace (no glob characters, and not empty as in `/shell::exec`) and
must be followed by an id pattern that does not start with `/` (`laptop//shell::exec` is
rejected); otherwise the policy is rejected and every call is denied.
A pattern that starts with `hub::` or `peer::` uses a mesh id prefix that no longer exists, and
also rejects the policy: a mesh function keeps its id and lives in the namespace of its machine, so
`peer::laptop::shell::exec` becomes `laptop/shell::exec`, `hub::shell::exec` becomes
`hub/shell::exec`, and `peer::*` becomes one pattern per machine, such as `laptop/*`.
For now a `functions.deny` glob written for a mesh id's old spelling (`laptop::shell::exec`,
`*::shell::pty::*`) still denies the call, and observing it, in another namespace, ahead of every allow; write
`<namespace>/<pattern>`, since a later release drops the old spellings.
A sandbox operation answers as the router's `sandbox::<op>` and as the adapter's own
`<adapter>::<op>` (`sandbox-libkrun`, or the adapter `sandbox::adapter::info` reports). A
`functions.deny` glob or a hook's `functions` glob matching either id covers both;
`functions.allow` stays literal. `sandbox-libkrun` is always covered, a custom adapter's prefix
once a read of `sandbox::adapter::info` succeeds, at startup and on each registry change. If it
fails, for example because RBAC refuses it, the harness logs a warning and the adapter's ids stay
callable until a later read succeeds.

A session whose metadata contains `side_chat_question` is additionally capped by the configured
`side_chat_functions`, regardless of the policy supplied by a later send. Its default ceiling is
`session::get`, `session::messages-tail`, `harness::status`, `kanban::ticket::get`,
`kanban::ticket::list`, `kanban::question::list`, `coder::read-file`, and `memory::recall`.
An explicit `options.functions` may narrow that list but cannot widen it.

Before dispatch, arguments that fail the target's schema are reconciled: stringified JSON the
schema rejects is parsed. When the optional
[`judge`](https://github.com/iii-hq/workers/tree/main/judge) worker is deployed, it also settles
misnamed keys, off-enum values and unknown arguments; it sees the arguments with secret-keyed
values (`password`, `token`, `api_key`, `authorization`, …) masked and long strings cut. Every
repair is noted in the call's result.

The full function reference (every `harness::*` id and its request/response
schema) lives in the code and `iii call engine::workers::info name=harness`.

Building a consumer — a chat UI, a Telegram/WhatsApp bridge, a cron worker, or
any event-driven loop on top of the harness? Start with the integration
contract in
`architecture/integration.md`: the functions to
call, the functions to observe, and the canonical consumer patterns.

## Local development

See [`DEVELOPMENT.md`](DEVELOPMENT.md) to run the Harness and its required
workers from the local source tree with `iii compose`.

## Working with iii

iii is a language agnostic runtime where services, agents, and tools are
composed of the same things: workers, functions, and observers. One engine
holds a live registry of every connected worker, their functions, and the
observers of those functions. Calls route worker to engine to worker, so the
language, runtime, and location of a worker are invisible; the function id is
the only contract.

**1. Discover what is already there (the engine is the source of truth)**
- `engine::functions::list` — every function across all workers (filter with `prefix` / `search` / `worker`)
- `engine::functions::info { function_id }` — the request/response schema for ONE function (this is your API reference)
- `engine::workers::list` / `engine::workers::info { name }` — connected workers and their surface
- `engine::functions::info { function_id }` also gives a function's `args_format` — the args its observers pass
- `engine::observers::list` — every observer that exists

**2. Call a function.** Use `agent_call` with `{ function: "<worker>::<fn>", description: "<short user-facing action>", payload: { ... } }`. The description is shown as the agent's activity in chat; keep it concise and in the session's response language (named in the runtime context, detected from the user's first message). The payload is a JSON object (never a stringified one), and you fetch the contract via `engine::functions::info` before the first call.

**3. Need a capability that is not registered?**
- `directory::registry::workers::list { search: "<capability>" }`
- `directory::registry::workers::info { name }` to judge fit
- choose an operation id and observe `compose::on-operation-progress` with a one-shot wake
  filtered on `{ "input.operation_id": { "$eq": "<operation-id>" }, "input.terminal": { "$eq": true } }`
- call `compose::add { worker: "<name>", operation_id: "<operation-id>" }` with the same id
- read `compose::operation` once for race recovery, then confirm the functions after the terminal event

**4. Worker lifecycle.** `compose::status`, `compose::add`, `compose::up`, `compose::down`, `compose::restart`, `compose::update`, and `compose::remove`. `add`, `update`, and `remove` use the same Compose operation wake flow above; the other operations return their final result directly. `add`, `update`, and `remove` accept a `workers` list for one batch, while their singular `worker` field remains compatible. Fetch their contracts with `compose::schema { function_id: "compose::<operation>" }`. The harness routes `compose::*` to its supervising daemon and scopes each call to its own compose file.

**5. Observers, not polling.** To react to events (HTTP, schedule, webhook, file change), observe the function that emits them: `harness::observe` from a turn, `iii.observe` from a worker. Find the function with `engine::functions::list`, copy its args and filter fields from `engine::functions::info`, and confirm the observer delivers with a real call (e.g. `web::fetch` to its local URL).

**6. Handy workers.**
- `web::fetch` — all HTTP(S); pass `format: "markdown"` to read docs without flooding context
- `coder::*` — file ops for any code task (read/search/create/update/move/delete)
- `slack::*` — post to Slack

**7. Authoring a worker.** Read the SDK reference for your language first (Node / Python / Rust / Browser / Engine WS) at https://iii.dev/docs/reference/. Use the SDK's `registerWorker(...)` and call `iii.registerFunction` / `iii.observe` / `iii.call` on the returned value; they are methods, not top-level exports. Always declare `description`, `request_format`, and `response_format` so the next caller gets a real contract.

TL;DR: list, info, call. The engine tells you the truth; trust it over memory.

## Adding workers with container settings

Fetch `compose::schema { function_id: "compose::add" }` before choosing the payload.
Use container objects only if the running daemon's schema supports them. The singular
`worker` field remains a string shorthand. For settings, use `workers`, which can mix
strings and objects. Put settings inside each object, not at the request's top level.
Only `add` accepts objects; `update` and `remove` take worker names.

After registering the one-shot wake described above, call `compose::add` with a payload
like this (the local worker directory and env file must already exist):

```json
{
  "operation_id": "<operation-id>",
  "workers": [
    "state",
    {
      "worker": "./workers/api",
      "start_after": ["state"],
      "scripts": {
        "pre_run": "pnpm build",
        "pre_run_timeout": "60s",
        "run": "pnpm start",
        "post_run": "echo stopped"
      },
      "config_name": "api",
      "config_override": { "port": 3000 },
      "working_dir": "./workers/api",
      "environment": { "NODE_ENV": "development" },
      "env_file": ["./api.env"],
      "startup_timeout": "30s"
    }
  ]
}
```

`worker` accepts a package name, `name@version`, registry reference, or local directory,
including `package://` and `path://` sources. Objects also accept `version` for packages;
it must agree with any version in `worker`. Omission resolves the latest matching package
version, so keep an explicit version when it must stay pinned.

Use `scripts` (plural); `scripts.run` is valid only for local workers. `start_after`
contains container keys, derived from the last part of each worker name or directory;
required package dependencies are also included. `config_name` selects the base configuration,
and `config_override` supplies values over it. `environment` values must be strings.
`startup_timeout` limits the wait for registration.

Relative `worker`, `working_dir`, and `env_file` paths start at the compose file's directory.
`working_dir` sets the process and hook directory; when omitted, local workers use their own
directory and packages use the compose directory.

For an existing container, omitted settings stay in place. A supplied field replaces that
whole field, including `scripts`, `environment`, and `config_override`; these are not
partial map edits. Use `{}` or `[]` to clear maps or lists. A supplied `start_after` replaces
the list while retaining required package dependencies. Changes can restart running workers.
The acceptance response does not mean ready: finish the same Compose operation wake flow
before using the worker.

## Configuration

The `harness` configuration entry is owned by the `configuration` worker; every
field hot-reloads (no restart). The fields a deployment is most likely to tune:

```yaml
default_max_turns: 16            # per-turn generate-step cap when a send omits it
default_pending_timeout_ms: 1800000  # legacy parked-call (hold / pre-deploy child) wait guard
max_depth: 3                     # sub-agent depth budget
max_children: 8                  # sub-agent spawns-per-turn budget
max_transient_resumes: 3         # recovery generations per turn after retryable provider failures; a turn that still fails reports failure.retryable: true on harness::status
max_result_bytes: 262144         # function-result byte cap at capture; oversized results become an elision marker (0 = off)
prompt_cache_sections: true      # send the frozen profile prefix as its own cacheable section (+ digest) on router::chat
co_author: true                  # tell agents to end git commit messages with "Co-authored-by: iii harness (<model>) <noreply@iii.dev>"
call_reconciliation: judge       # repair malformed call arguments before dispatch: off | coerce (lossless parses) | judge (+ judge::evaluate when deployed)
projects_file_path: ~/.iii/data/harness/projects.json  # chat projects store, harness::projects (default: data/harness-projects.json under III_COMPOSE_DIR / cwd)
folders_file_path: ~/.iii/data/harness/folders.json    # saved-folder catalogue, harness::folders (default: data/harness-folders.json)
descriptions:
  agent_writes: true             # offer harness::set-description to agents (harness::chat-settings::set changes it)
autocompact:                     # the global autocompact setting (harness::chat-settings::set changes it); absent: off
  mode: tokens                   # off | tokens
  tokens: 400000                 # 20,000-2,000,000
  instructions: keep the ticket ids  # up to 1,000 characters, sent with every automatic compaction
sweep_expression: "0 * * * * *"  # cron for the pending-call expiry sweep
```

Other keys (RPC timeouts, stream coalescing, idempotency TTL, validation
retries) and their defaults live in [`src/config.rs`](src/config.rs).

## Anonymous usage reporting

The harness announces its own usage on the durable `harness:usage` topic. The
engine subscribes to that topic and sends one anonymous product event for each
message. Three moments report:

- `harness_user_turns`, when the user turns (root turns: one user message
  through its final reply) counted across every session in the state store
  reach 1, 2, 5, 10, 25 and 50, then every 50 after that (100, 150, ...). It
  carries `user_turns_total`, `sessions_total`, and `by_model`: user turns per
  provider and model of the root turn, and sessions per provider and model of
  the session's first root turn.
- `harness_model_calls`, on the same milestones of the model calls (assistant
  messages, sub-agents included) counted across every session in the state
  store. Model calls move several at a time, so a report goes out at the
  highest milestone passed. It carries `model_calls_total`, tool call and tool
  call error totals, token totals, `cost_usd`, `user_turns_total`,
  `sessions_total` and `subagents_total`, all across the state store, and
  `by_model`: model calls, tool calls, tokens and cost per provider and model
  that generated them. `subagents_total` counts each sub-agent session one
  time, when it is first seen in its root's session tree.
  `subagent_max_depth` is the deepest sub-agent level that any session tree
  reached. It has no `*_delta`.

Every counter on both events, in total and in each `by_model` entry, has a
matching `*_delta` (for example `tool_calls_delta`, `cost_usd_delta`): the
count since the previous report of the same event. The deltas of one state
store sum to its totals, so they can be added up across stores and time
windows.

- `harness_turn_failed`, once per session for each of the `failed`, `cancelled`
  and `max_turns` outcomes. This keeps the reason a run stopped exact.

`harness_turn_failed` carries the failed turn's model and provider; the two
counting events carry them only inside `by_model`, because their totals span
every model. Beyond those and the counters above, a message carries only a
fixed failure class: no message text, no prompt, no file path and no function
id. Sub-agent turns report nothing of their own; their model calls are
counted through their root session when its turn ends.

- A spawn with only a display parent (`parent_session_id`) is not a root turn.
  Its model calls are counted at the display parent's next root turn. If the
  parent has no further turn, they are not counted.
- A spawn with no parent is a root session, so its turn counts as a user turn.
- A failed turn counts as a user turn. Its `harness_turn_failed` event carries
  `error_kind`; `llm.unknown_model` means the model is not in the router
  catalog, and `llm.unknown` means the failure has no classification.
- A session that an earlier harness release ran takes its usage so far as a
  baseline on its first turn after the upgrade. That usage is not counted again.
- A fork (`session::fork`) takes the history it copied as its baseline, so
  only the model calls the fork makes are counted.
- The usage already counted is kept per session of the tree. When a session is
  deleted from the tree, the model calls of the other sessions are still
  counted.

The reporting keeps its own bookkeeping and only reads the harness's
accounting (`harness::metrics`). The counters live in the `state` worker's
store, so each project counts on its own with the default file-backed `state`
(and an `in_memory` store starts again from zero). The `harness_usage/_machine`
row holds the store-wide counters, updated by compare-and-set. Each
`harness_usage/<session_id>` row records the outcomes a session announced and
the model usage already folded in, per session of its tree, so a turn after a
restart does not count that usage again. A crash after the `_machine` update
and before the session row is saved folds that turn's model usage twice. Each
step is best effort: a failed read or publish is logged at debug level and the
turn continues.

To stop the reports, set `III_TELEMETRY_ENABLED=false` on the engine. The engine
then takes the messages from the topic and discards them, so an opted-out
deployment stores nothing.

## System prompt

The identity prompt is assembled once at send/spawn time. EVERY agent —
top-level turns (`harness::send`) and spawned children alike — is seeded with
the same single identity
([`prompts/default.txt`](prompts/default.txt)): a deliberately minimal prompt
carrying only the basic engine functions and the discovery loop (list, info,
call). A `default` entry in the directory's system-prompt store
(`<skills_folder>/system-prompts/default.md`, served by
`directory::system-prompts::get`) overrides the embedded prompt for every new
composition — write it with `directory::system-prompts::create { name:
"default" }` the first time and `::update` after (or edit the file directly; no
console surface authors it) and the next send picks that up, no restart;
any store failure (directory absent, entry missing, blank body) falls back to
the embedded prompt. What makes a child a leaf is its POLICY, not its prompt: children are
capability-walled out of the orchestration surface (`harness::spawn`,
`harness::send`, `harness::unobserve`) unless spawned with
`options: { orchestrator: true }`; spawn `options.system_prompt` remains the
identity escape hatch.

A spawn may also give its child a display-only identity with
`display: { name, icon?, color? }`. `name` is trimmed, cut to its first 48
characters when longer (never refused for its length), and becomes the title of a newly created child session; `icon` and `color` are
closed semantic tokens recorded with the child linkage in
`metadata.subagent_display`. These fields never affect routing or execution,
and reusing an existing `session_id` retains that session's original title and
metadata. Icons are `agent`, `code`, `search`, `terminal`, `database`, `test`,
`review`, `docs`, or `design`; colors are `neutral`, `blue`, `purple`, `teal`,
`green`, `amber`, or `rose`.

No prompt prescribes an orchestration process — identity prompts carry tool
guidance only, enforced repo-wide by [`tests/prompts.rs`](tests/prompts.rs).
The opt-in fan-out playbook (parent-owned control plane: pick a medium, arm
notifications, spawn leaves directly, define completion per medium) lives in
[`skills/orchestration.md`](skills/orchestration.md) — paste it into a task
prompt or pass it via `options.system_prompt`.

A non-empty `options.system_prompt` is combined with the built-in
prompt per `options.system_prompt_strategy`: `enrich` (default) appends it to
the built-in prompt, while `override` uses it verbatim. Assembly is tested in
[`src/prompt/tests.rs`](src/prompt/tests.rs).

The resolved prompt is STICKY per session, like `model`/`provider` and the
dispatch policy: a send to an existing session that names neither
`system_prompt` nor `system_prompt_strategy` inherits the prior turn's
resolved prompt verbatim (a prior `disabled` turn's absent prompt inherits
too). Naming either field resolves fresh — an explicit bare
`system_prompt_strategy` (e.g. `"enrich"`) is the reset-to-default escape
hatch. The inherited string is frozen at its original resolution — resend
the prompt fields to re-resolve.

Reasoning is sticky the same way: a send that names neither
`thinking_level` nor `provider_options` keeps the prior turn's pair, so an
omitted field never silently resets the effort (which would also bust the
provider's messages cache). Naming either field replaces the pair —
`provider_options: {}` resets to the provider default.

`options.reasoning: "lowest"` asks the harness to choose the effort instead:
the first entry other than `none` in the model's `reasoning_efforts`, else
`minimal` for a model that only reports `supports_thinking`, else no effort
(the provider decides). It cannot be combined with `thinking_level` or
`provider_options`, fails the send when the router has no catalog row for
the model, and the send response reports the choice as `reasoning`
(`thinking_level` and the native `reasoning_effort`). Later sends inherit it
like any explicit effort, and it beats an agent profile's `reasoning_effort`.

The prompt reaches `router::chat` in two forms: the flat `system_prompt`,
and `system_sections` — the STABLE prefix (the frozen profile or identity
prompt plus the frozen skills index, `cache_boundary: true`) followed by the
per-session tail (session id, working directory, policy aid, and whatever
context assembly and hooks append). Two sessions on the same profile send
the same stable bytes, and `cache_intent.surface_digest` (`sha256:` of that
section) names them, so cache-aware providers can keep one prefix entry for
all of them — when the provider supports it and the prefix meets its minimum
cacheable size: Anthropic puts its cache marker on the boundary block, OpenAI
and Codex derive `prompt_cache_key` from the digest. The digest is a local
identity, never evidence of a hit — `usage.cache_read` is. `harness::status`
reports it as `context.prompt_surface_digest`, or
`context.prompt_sections_fallback` when no sections went out: `disabled`
(`prompt_cache_sections: false`), `no_stable_prefix`, or `prefix_rewritten`
(a `pre_generate` hook replaced the prompt head — the hook's prompt still
wins, it just shares nothing).

### Agent profiles

`options.agent` on a session-creating `harness::send` names a directory agent
profile (`directory::agents::*`, one markdown file per profile). The harness
resolves it ONCE via `directory::agents::get` and freezes the result onto the
turn: the profile's RESOLVED system prompt — the directory composes `extends`
chains root-first, so `tech-lead` extending the bundled `iii` base arrives as
the full iii doctrine followed by the tech-lead body — IS the session
identity. Nothing built-in sits underneath it and no prefix is added; the
usual per-step runtime context (session id, working directory, response language, composer args, policy aid,
skills index, hook injections) follows it. A profile whose `extends` chain does not resolve is refused as an
invalid request with the directory's D415 text. The profile's `skills` are
PRELOADED: each id's body is fetched once from `directory::skills::get` and
frozen into a `<preloaded_skills>` block of `<skill id="…">` sections
appended to the prompt (ids the directory cannot serve are named as
unavailable), so the skill is in context on the first step; the session's
skills index is never narrowed by a profile — only an explicit
`options.skills` does that. A profile with `skills_index: false` (inherited
through `extends`) starts its sessions, and children running as it, with no
skills index at all; such a session ignores `options.skills` on its opening
send and refuses it later. Its preloaded skills still render, and
`directory::skills::get` stays callable when the policy allows it. Its
`model` is authoritative for the session. Its optional provider-native
`reasoning_effort` is the default for an opening send that names no level of
its own: a send that sets `thinking_level`, a native `reasoning_effort` or
`thinking` under the session's provider in `provider_options` (under any
provider when routing is automatic), or `reasoning` runs at that level
instead, and later bare sends inherit whatever the opening send resolved. A
`provider_options` that carries only an account or unrelated keys names no
level. For any effort pick other than Default, the ADE composer sends
`thinking_level`, a native `reasoning_effort`, or `reasoning` (for Lowest),
so that pick takes effect on a profile that sets an effort (it used to be
overwritten by the profile) and sticks for later bare sends in the session.
A new ADE conversation starts on the last level picked (else the pinned
default model's effort), so it runs at that level, not the profile's, unless
the picker is set to Default. When the send
also omits
`options.functions`, the dispatch policy defaults to the configured
`default_functions` baseline instead of deny-all (an identity picked to DO
something must be able to dispatch). When the profile declares (or
inherits) `functions` — its PRELOADED functions, engine function ids it uses
routinely — the harness renders each one's current description and
compacted request schema into a `<preloaded_functions>` block appended to the
frozen prompt (contracts come from the cached registry snapshot, with one
`engine::functions::info` batch for ids the snapshot cannot vouch for; ids
the engine does not know are named as unavailable), so the model calls them
on the first step instead of spending a search and a contract lookup per
session. The `<preloaded_functions>` block comes first, `<preloaded_skills>`
after it. The frozen block is never rewritten (it is the shared cache
prefix); when a preloaded contract later changes, disappears, or an
unavailable one appears, every step carries a tail notice naming exactly
those ids until a new session resolves the profile afresh. The frozen name/icon/color/model/effort/skills/functions snapshot is also
written to session metadata for clients that render established sessions. The frozen identity
travels with the prompt-stickiness rule: bare later sends
inherit it, an explicit prompt field sheds it. Refused on an existing
session or combined with either prompt field. Directory edits after
resolution never reach a live session — start a new one to pick them up.

`harness::spawn` takes the same id as a top-level `agent` field: the profile's
resolved prompt (preloaded functions and skills included) is the child's whole identity, its model slots in the same way
(model precedence profile → explicit `model` → parent, without dragging the parent's
provider onto a foreign model); its effort precedence is the spawn's
`options.thinking_level` → profile `reasoning_effort` → parent's effort; and its name and icon become the display
defaults. A spawn that names NO profile continues the parent turn's: an agent
running under a profile fans work out to itself, not to a stranger wearing the
built-in identity, and the child re-resolves that same id so its own preloaded
functions and skills arrive with it. `options.system_prompt` — the escape hatch
for a child that genuinely needs a different identity — sheds the inherited
profile instead of colliding with it, and a parentless spawn (console,
workflow, CLI) has no parent turn to inherit from. Which agent profile a spawn
names is the prompt's decision — the profile body steers it, nothing gates it.
Spawning
with `agent` into an already RUNNING session of the caller's own tree merges
the task like any reuse and does not re-apply the profile.

#### Enforced function policy (`functions_policy`)

`functions:` only preloads contracts; it never limits what a session may call.
A profile that must be limited declares `functions_policy`, which the harness
enforces on every session running as the profile, whoever starts it (a
`harness::send` with `options.agent`, a `harness::spawn` with `agent`, or a
child that inherits the parent's profile):

```yaml
functions_policy:
  allow: [kanban::ticket::get, coder::read-file, coder::search, "engine::functions::*"]
  deny: [shell::*]
```

- The send's dispatch policy (`options.functions`, or the default it falls back
  to) is CLAMPED to it. The allow-list keeps each glob that one side covers on
  the other: a send with `allow: ["*"]` gets exactly the profile's list, and
  `shell::exec` against a profile's `shell::*` stays `shell::exec`. The deny
  lists are unioned, and deny wins at dispatch. The policy only narrows: a
  send with no policy (deny all) or `allow: []` stays that way, and `expose`
  is the send's.
- Without `allow`, the policy is deny-only: the send's allow-list stays and the
  profile's `deny` is added.
- Same glob syntax as `options.functions`, including `<namespace>/` qualifiers.
  Write exact ids or `worker::*`: a pair where neither glob covers the other
  (`*::list` against `kanban::*`) keeps nothing. Quote a pattern that starts
  with `*` (`"*"`), or the YAML is invalid. A glob the harness cannot compile
  refuses the profile as an invalid request.
- The allow-list is exhaustive, for spawned children too. The discovery grants
  a child normally gets (`engine::functions::list`, `engine::functions::info`,
  `directory::skills::get`) survive only when the profile allows them, and a
  profile used by workflow JSON nodes must list `workflow-result::submit`.
  Preloaded `functions` the policy denies are named as not available.
- The policy is frozen with the identity (`TurnOptions.agent.functions_policy`,
  also in the session-metadata snapshot). Every later send that keeps the
  identity is clamped again, so an explicit `options.functions` cannot widen
  it; a send that names a prompt field sheds the identity and the policy with
  it. So a profile that needs the ceiling must not allow `harness::send`: a
  session that can call it can shed its own identity, or start a session with
  no profile at all.
- It limits which functions the session dispatches, not what they do. An
  allow-list that includes a carrier, such as `shell::*`, `fp::pipe`,
  `fp::batch`, `harness::send`, `harness::spawn` or `workflow::start`, is not
  read-only: those run their own steps under their own authority. There is no
  read-only shell; leave `shell::*` out for a read-only profile.
- A directory that predates the key does not serve it, and a harness that
  predates it ignores it, so the profile then runs unrestricted. Require both
  releases before relying on it.

A spawned child also starts with the contracts it would otherwise look up
first, in a `<preloaded_functions>` block of its own (MOT-4851). The block
holds, capped at 30 contracts:
- its whole allow-list, when that is a short (≤ 30), glob-free list of
  explicit ids;
- then every function id its task names verbatim (for example
  `` `coder::read-file` ``).

Only ids the child may dispatch are seeded, and only when the registry lists
them. Discovery grants and ids its profile already preloads are skipped, and
`expose: native` seeds nothing, because the tools already carry the schemas.
The block is frozen at spawn and rides after the cache seam (the runtime aid),
so default-identity sessions keep sharing their stable prefix. Its digests join
the preloaded-contract stale notice.

The harness ships one profile of its own, `worker-builder`
(`agents/worker-builder.md`): an identity that
extends the bundled `iii` base and takes a new worker for this repository from
scope to scaffold, CI gates, live verification on the bus, pull request, and an
experimental registry release, asking before every irreversible step. It is
published in the harness skills payload as `agents/worker-builder.md`, which
`directory::skills::download { worker: "harness" }` routes into the
directory's `agents_folder`; copying the file there by hand works the same.
Its `skills` preload the six knowledge skills from
[`iii-hq/iii/skills`](https://github.com/iii-hq/iii/tree/main/skills)
(`npx skills add iii-hq/iii/skills`) into every session's prompt; missing
ones are named as unavailable, not failures. Then `harness::send { options: { agent: "worker-builder" } }` (or
the console's agent picker) runs it.

New sessions also freeze a names-and-descriptions-only skill index into the
system-prompt prefix. `options.skills` on `harness::send` or `harness::spawn`
accepts exact skill ids. For a fresh session, omitted or empty means all
model-invocable skills. On an existing new-format session, omission inherits
the previous filter while an explicit empty list resets to all; explicit
changes are rejected while its turn is active.
This is curation, not authorization: the turn's function policy must still
allow `directory::skills::get`, and the function must exist in the live
registry. Skill bodies enter context when the model calls that function — or
up front, as `<skill id="…">` sections, when an agent profile preloads them.
Catalog changes are appended as durable user-role corrections, leaving the
frozen prefix unchanged. Legacy sessions keep their already-frozen prompt;
start a new session to apply an id filter to one.

Trusted console surfaces can preview the built-in, selected, frozen skill,
runtime-context, registry-notice, and declarative worker-injection layers with
`harness::system-prompt::get`, without making a model request. When the caller
passes no `selected_prompt` and the session has a turn record, the preview
reports the record's RESOLVED prompt (labeled `session (frozen at send)`) —
the truth for what ran and what the next send inherits — instead of
rebuilding the built-in. Set `default_only: true` to read the exact embedded
Harness default without consulting session or runtime state. Static
`pre_generate` hooks publish their exact contribution as the observer arg
`inject_prompt`; the preview lists the ones whose `sessions` globs and filters
select the session's next step. Request-dependent hook functions and compaction are not run
by the read-only preview and may change content when the prompt is sent.

The read-only `harness::context-policy` surface returns whether the destination model permits aged function-result pruning. Console context previews must use this response rather than maintaining a model list locally; failures or malformed responses are not a permission to infer a policy.

## Delete a session subtree

Console/operator callers use `harness::delete-session-tree { session_id }`, not
raw session deletion. The selected session is the root; parents and siblings
remain. The command returns `{ operation_id, attempt, session_id, status,
deleted_session_ids, error? }` quickly. Observe
`harness::on-session-tree-deletion` (filters on `input.session_id` or
`input.operation_id`) first, read
`harness::delete-session-tree-status { operation_id }` once for race recovery,
then wait for `completed` or `failed`. Pending/completed requests are idempotent;
failed requests retry under the same operation id with an incremented required
`attempt` (starting at 1). Correlate terminal events by `operation_id` **and**
`attempt`, ignoring terminal events from older attempts. Pending/completed
repeats and recovery retain the attempt.

The durable queue operation closes admission, cancels every durable descendant,
waits for terminal turns/in-flight tools, delivers one consolidated message to
the surviving direct parent, and deletes child-first. The side chats of every
session it deletes (`side_chat_of`, see [Side chats](#side-chats)) go with it,
with their own subtrees, before the session they belong to. With
approval-gate on the stack, each deleted session's approval records are
purged through `approval::on-session-deleted`, called with a payload both
the Observe v2 gate (the `Observed` envelope of `session::on-deleted`) and an
older one (the bare `{ session_id }`) read. Unconfirmed work fails
closed with data retained. See [recovery, safety boundaries and tests](architecture/session-tree-deletion.md).

## Compacting a conversation (`/compact`)

`/compact` is a command, not a prompt. Sent through `harness::send` by any
client — the console, the mobile apps, a bot — as the whole message (text only,
optionally followed by guidance: `/compact keep the ticket ids`), it never
reaches the model and no turn runs: the send returns at once with
`compaction: { compaction_id, entry_id }` and the harness compacts in the
background. `harness::compact { session_id, model?, provider?, instructions? }`
runs the same compaction and returns its outcome (`ok` / `busy` / `empty` /
`failed`, the user-facing `message`, the token counts and the `entry_ids` it
wrote) for a caller that has to wait, such as the console's model switch.
Both run the summary on the conversation's Claude Code account, resolved at
the call as a turn's would be (a side chat uses its lock's); see
[Claude Code accounts](#claude-code-accounts).

Every device watching the session learns about it, not only the one that asked:

- a `notice` row "compacting the conversation…" lands when it starts — under
  the send's `e_idem_<idempotency_key>` id, so the sender's optimistic
  `/compact` row turns into it;
- a `/compact` send shows the session `working` / "compacting context" while it
  runs (a live turn keeps its own status line);
- it ends with one row: the `compaction` record (the marker), or a `notice`
  saying why there is none (a failure names its cause, from context-manager's
  `failure`: "a larger context window" only when the input did not fit);
- `harness::on-compaction` is called with `phase: started` and `phase: completed`;
- the `harness_context` snapshot is rewritten for the compacted window, so the
  `context` chip and `harness::status` (which returns the newer snapshot) stop
  showing the old one.

The window is the one the next turn would assemble (latest compaction anchor,
`message_order`, replayed notices); the router resolves the summariser model's
limits; and a live turn's unanswered calls stay in the verbatim tail with
their results. It runs under the session's context-manager lease, so it is
safe beside a running turn, and it does not depend on the requester staying
connected.

## Autocompact

A conversation compacts by itself when its context passes a number of tokens
(chat-projects phase 3). The setting comes from three levels, and the first
that is not `inherit` decides:

| Level | Where | Shape | Default |
|---|---|---|---|
| Conversation | `metadata.autocompact` (a side chat reads its conversation's) | `{ mode: "inherit" \| "tokens" \| "off", tokens? }` | absent or malformed: inherit |
| Project | the project's `autocompact` | the same | `{ mode: "inherit" }` |
| Global | the configuration's `autocompact`, through `harness::chat-settings` | `{ mode: "off" \| "tokens", tokens?, instructions? }` | off |

`tokens` is 20,000 to 2,000,000 and `instructions` up to 1,000 characters;
`harness::chat-settings::set` and `harness::projects::create|update` refuse
anything else with `bad_setting`, `bad_tokens` or `bad_instructions` (a
rejection, `{code, message, field, ...}`, with ready copy such as "Between 20k
and 2M tokens"). At every level, `tokens` stays stored with `mode: "off"`,
inert, so turning it back on restores the size (a bad one is still refused);
`instructions: ""` clears them; a project's `{mode: "inherit"}` clears its
value. A sub-agent has no setting of its own: it follows its project and the
global.
Each turn resolves the setting at its first step and keeps it on its record
(`autocompact`), and the end of the turn resolves it again.

**The numbers.** `effective_tokens` is the setting when it is below the
model's `usable` (the input budget `context::assemble` measures), else null:
the model's own limit applies, as before. `cap_tokens` is
`setting + max(10 %, 20k)`. The context snapshot (`harness::status` verbose,
`harness_context`, `harness::on-turn-completed.context`) carries
`autocompact { setting_tokens, effective_tokens, cap_tokens, rule }`, where
`rule` is `{ scope: "global" | "project" | "session", project_id?,
project_name? }`.

**At the end of a turn**, at the top of its finalize, the conversation
compacts once the last step's billed input (`input + cache_read +
cache_write`, else the snapshot's `total` when the step reported none) plus
its output reaches `effective_tokens` (the same number is the record's
`context_before`), unless a compaction already runs, the back-off holds, or
the session is a sub-agent. It is `/compact`'s path with `trigger: "auto"`,
the threshold, the rule, the global `instructions` and the turn's own
provider options (its Claude Code account). The start notice
(`reason: "compacting"`, as `/compact`'s) reads "Auto-compacting at 160k…"
and the record "Auto-compacted at 160k · 161k →
34k tokens · acme-web rule". The turn record stays `running` with
`compacting: <compaction_id>` meanwhile: a send queues and runs after it,
`harness::side-chat::open` takes the turn's reply as final, and
`harness::side-chat::summarize` on a compacting side chat answers
`side_chat_busy`. `harness::on-turn-completed` carries the refreshed
snapshot. A Stop abandons the summary (`status: "cancelled"`, no record:
"Auto-compact stopped. The conversation goes on and compacts again after a
later turn.", with no back-off) and answers `stopping: true`; the reply is
already final, so the Stop stops the compaction only: a message queued during
it keeps its turn (the record marks `compaction_stopped: true` and keeps
`continues`). The Stop ends only the harness's wait: context-manager finishes
the summary it was asked for and holds the conversation's lease until then,
so a turn that ends meanwhile is skipped as busy ("Auto-compact skipped:
another compaction of this conversation is in progress.").

**Inside a turn** every `context::assemble` carries `compaction_budget:
cap_tokens` with `compaction_instructions` and the turn's
`provider_options`; context-manager 1.3.0 compacts inline at
`min(usable, cap)` and echoes the budget it applied. Such a compaction is
recorded with `trigger: "inline"` ("Auto-compacted during the turn at
160k · …"), or `trigger: "limit"` when the model's `usable` fired it
("Compacted at the model's limit · …"); both get a `compaction_id` and emit
only their `completed` phase. A failed or busy inline attempt writes no
notice and drops the budget for the rest of the turn (so does one that
gained less than 10 %). A context-manager without the echo is older: the
turn runs without the budget, and the end of the turn still compacts.

**Failures and the back-off.** A failed automatic compaction says why:
"Auto-compact failed: <cause>. The conversation goes on and compacts at the
model's limit." A usage limit names the account and no clock time
("Auto-compact failed: Personal reached its usage limit. The conversation goes
on and compacts again after its next turn."); the completed event and the
notice carry context-manager's `failure { kind, message, error_details? }`
for a client to format the reset. After a failure, or a compaction that
gained less than 10 %, the next attempt waits until the context grew by
another 10 % of `effective_tokens` (`harness_autocompact/<session_id>`); a
usage limit starts no back-off.

| Function | Request | Response |
|---|---|---|
| `harness::autocompact::models` | `{}` | `[{ provider, model, name, context_window, usable, last_used_ms }]` |
| `harness::autocompact::log` | `{ limit?: 20 }` | `[{ session_id, title, at_ms, trigger, threshold_tokens, context_before, context_after, rule }]` |

`harness::autocompact::models` lists the models that ran a turn on this
engine in the last 7 days (an index written with each snapshot,
`harness_autocompact_models`), named from the router catalog
(`context_window` is null for a model the router does not list). It is also
how a surface detects phase 3. `harness::autocompact::log` lists the last
automatic compactions (`auto` and `inline`), newest first, from one ring of
50 in `harness_autocompact_log` updated with compare-and-swap. Both are
internal and denied to agents. Deleting a session drops its back-off and its
log entries.

## Asking the user (`harness::ask`)

`harness::ask` lets the model put a decision with discrete options to the user
as a clickable card instead of a question written in markdown. It is
registered in the catalog like `harness::spawn`, but it is a harness control
like `submit_result`: the turn loop answers it in-process, never dispatches it
to a target, and never parks the turn. A direct call outside a turn fails with
`harness/invalid_request: harness::ask only works inside an agent turn: call it
from a model turn, not directly`.

```json
{ "questions": [ {
    "header": "Approach",
    "question": "When the agent asks, does the turn pause or end?",
    "multi_select": false,
    "options": [
      { "label": "Pause the turn", "description": "Like AskUserQuestion", "recommended": true },
      { "label": "End the turn", "description": "The answer becomes the next message" }
    ] } ],
  "about": {
    "ticket": "KAN-597",
    "blocks": ["KAN-598"],
    "class": "run_health",
    "why": "The release cannot finish until its build policy is settled."
  },
  "expires_in_min": 30,
  "on_expiry": { "answer": "Pause the turn" }
}
```

- 1–4 questions per call and 2–4 options per question.
- `header` and `question` must not be empty. A long `header` is fine: the
  card shows it with an ellipsis and the whole text on hover.
- `label` is 1–80 characters and unique within its question.
- `header` and `label` must not contain line breaks (the answer is one line
  per question).
- Limits count characters, not bytes. A value that is only whitespace counts
  as empty, and labels are compared after trimming.
- `multi_select` and `recommended` default to `false`; `description` is
  optional. At most one option in each question may be recommended.
- The UI adds a free-text "Other" choice, so the model must not include one.
- `about` is optional. Its `class` is `security`, `publish`, `external_cost`,
  `data`, `scope`, `run_health`, or `routine`, and defaults to `scope`.
  `ticket` names the card the question concerns, `blocks` names other cards
  waiting on it, and `why` is the paragraph shown above the choices.
- `expires_in_min` is optional and must be a positive integer number of minutes. With
  no expiry the question waits until it is answered or withdrawn.
- `on_expiry` defaults to `"block"`. `{ "answer": "<option label>" }` is
  accepted only for one single-select `run_health` or `routine` question, and
  must name one of that question's labels exactly. Invalid defaults are
  refused when the ask is made.

An accepted ask is answered at once with a function result whose `details` is
the card:

```json
{ "status": "awaiting_answer", "question_id": "<function call id>",
  "session_id": "…", "turn_id": "…", "questions": [ … ],
  "about": { … }, "expires_in_min": 30,
  "on_expiry": { "answer": "Pause the turn" } }
```

In `questions`, `multi_select` is always present and `description` is omitted
when absent. Default optional metadata is omitted. The model reads one text
block telling it the questions are shown, the answer will arrive as a message,
and it must not repeat them in text. It may keep working and withdraw the ask
if it stops needing the answer.

**The turn ends on the question.** A step that accepted an ask finalizes the
turn without another model call, through the same path as a text-only step:
`completed`, with the step's assistant text as the result. Three things change
that:

- A `submit_result` in the same step is handled first.
- A user message that arrived during the step (steering or a queued message)
  advances the turn as usual.
- A step whose other calls parked waits for them; the resumed step calls the
  model again.

The accepted step is recorded on the turn record (`ask_step`), so a
redelivered step still ends on the question and still refuses a second ask.

A turn that ended on the question projects the session status `done` with the
reason `awaiting answer`, so a client can mark the session as waiting on its
user (the ADE puts an amber dot on the sidebar row and the chat tab). The next
turn sets `working` again.

Refusals come back as an `is_error` result, and the turn continues so the model
can react:

| Case | Result text |
|---|---|
| A sub-agent (depth > 0) or a turn with a JSON output contract | `harness::ask needs a human to answer and none is attached to this turn (sub-agent or structured-output turn); report blocked with your question instead` |
| A second ask in the same step | `only one harness::ask per step; put all your questions (up to 4) in one call` |
| Arguments that do not parse | `invalid harness::ask arguments: <serde error>` |
| A broken limit | the field path and the limit, e.g. `questions[1].options[0].label must be at most 80 characters (got 81)` |

**Policy and hooks.** The session's allow/deny policy still applies: a denied
ask gets the usual `policy_denied` result. The repeated-failure breaker and
argument reconciliation still apply too. `pre_call` and `post_call` hooks
are **not** consulted. An approval gate could only hold the ask, and a held
call's release goes to the registered handler, which cannot show the card.

**Lifecycle and answering.** An accepted ask creates a durable `harness_ask`
entry keyed by `session_id/question_id`. This private scope is claimed at boot;
transitions use the harness's own compare-and-set accessor. Its state is `open`, then
`answering` while delivery is reserved, and finally `answered`, `dismissed`,
`withdrawn`, or `expired`. An `expired` question used the blocking expiry and
still accepts a late answer. Closed entries retain the question, `about`,
answer text, `by`, and outcome until the session is deleted.

People answer through `harness::ask::answer { session_id, question_id,
answers | dismissed, by }`. `answers` has one row per question, in question order:

```json
{ "answers": [
    { "header": "Approach", "choice": "Pause the turn" },
    { "header": "Channels", "choices": ["Console", "Slack"] },
    { "header": "Region", "other": "eu-west-2" },
    { "header": "Budget", "skipped": true }
  ],
  "by": { "channel": "control-plane", "user": "Ada" }
}
```

`by.channel` is `chat`, `control-plane`, `kanban`, or `expiry`. The first answer
reserves the entry, delivers the same text as the chat card with idempotency
key `ask:<session_id>/<question_id>`, and closes it. Concurrent or later
answers fail with `already answered by <channel>`. The delivery reservation
survives a restart and is retried with the same key, so the message is
delivered at most once. Ask deliveries set `options.require_existing_session: true`
on `harness::send`: that send refuses a missing session and skips session
creation, including when deletion races the delivery. A missing session closes
the ask with outcome `not_delivered`. Failed delivery/expiry attempts get five
bounded retries with backoff;
there is no periodic sweep. `dismissed: true` is available only for `scope`,
`routine`, and `run_health` questions.

The console renders the call as a card: checkboxes (a single-select ticks one),
each option's description, an "Other" field, a Skip toggle per question, and
Let the agent decide (where allowed) and Send for the card. Send calls
`harness::ask::answer`; cards created before durable ask entries existed fall back to submitting the answer through
the composer. Answer text is one line per question:

- a single choice sends `Approach: End the turn`;
- a multi-select sends `Channels: Console, Slack`;
- "Other" sends the typed text;
- a skipped question sends `Approach: (skipped)`: the model decides that
  one itself.

Dismiss delivers a notice instead of answers (`I dismissed your questions
without answering them. Go on with your best judgement; …`). The ask result
tells the model both may happen.

`harness::ask::withdraw { question_id }` closes an open question for the
calling agent's own session. Agents cannot supply another session id. Use it
as soon as later work makes the decision unnecessary.

`harness::ask::list { session_id?, state?, limit?, cursor? }` lists durable
entries, including closed ones. Pages sort by `session_id/question_id`; `limit`
defaults to 100 (1–200), and `cursor` is the previous page's last key, exclusive.
Entries carry `session_id`, `question_id`, `turn_id`, `questions`, `about`,
`asked_at` (epoch ms), `state`, `on_expiry`, optional `expires_in_min` and
`expires_at` (epoch ms), plus `answers`, `answer_text`, `by`, `outcome`, and
`settled_at` (epoch ms) when present. Optional `asked_by` identifies the asking
agent profile, captured from the session's `metadata.agent_profile.id`.
Outcomes are `answered`, `dismissed`,
`withdrawn`, `expired_default`, and `not_delivered`.

`harness::on-ask` fires when an entry is
accepted and `harness::on-ask-settled` fires with the whole entry after an
answer, dismissal, withdrawal, or default expiry answer. `harness::status`
and `harness::on-turn-completed` expose `open_asks`, counting entries in
`open` or `expired`.

At a blocking expiry, the entry moves to `expired` and the harness sends the
agent a message that it must not decide for the person, using idempotency key
`ask-expiry:<session_id>/<question_id>`. A valid default-answer expiry is
delivered as if the expiry channel answered it, with `(no answer within <n>
min; default applied)` appended.

**Agent rules.** Ask from a depth-0/root session; a sub-agent reports its
blocked question to its parent, which consolidates and asks. When work is on
a card, set `about` and explain `about.why`, and mark the option you recommend.
Link the work on a card with `harness::link-card { ticket }`; a call from a
sub-agent links its root session while preserving the root's other metadata.
Keep working when the answer does not block the next step. Withdraw a question
that no longer needs an answer. When a run-health issue prevents progress
(repeated check timeouts or an unavailable service), ask a `run_health` question
with a valid default instead of ending `blocked`. Neither `harness::ask::answer` nor
`kanban::question::answer` can be granted to an agent by policy; only a person
through a console/operator surface answers.

## Chat projects, saved folders and descriptions

**Saved folders** (`harness::folders::list | upsert | delete`) are the
folders the IDE's recent folders, the Chat's folder selector and the
console's folder pickers list: `{ path, name, last_used_at }`, most recently
used first, in the JSON file at `folders_file_path`. Until chat projects this
catalogue was `harness::projects::*`, in the file at `projects_file_path`; at
start the harness moves such a file to `folders_file_path` once (an
operator's `projects_file_path` is honoured for that move and logged as
deprecated). For apps released before projects, `harness::projects::list`
without `version: 2` still answers the folders as `{ projects: [...] }` (the
deprecation is logged once per connection), `harness::projects::upsert
{ path, name? }` forwards to `harness::folders::upsert`, and
`harness::projects::delete { path }` without an `id` to
`harness::folders::delete`.

**Projects** (`harness::projects::*`) group folders and the conversations
started in them: `{ id: "prj_<ULID>", name, color, folders, account,
autocompact, created_at_ms, updated_at_ms }`. A name has 1-40 characters and
is unique without regard to case; the colour is one of `blue`, `purple`,
`teal`, `green`, `amber`, `rose`; a project has 1-20 absolute folders (`~` is
expanded) and a folder sits in one project only (a folder nested in another
project's folder is allowed). A path belongs to the project whose folder is
the longest prefix of it, equal or followed by `/`. The store is
`{ version: 2, revision, projects }` at `projects_file_path`, replaced
atomically; `revision` goes up on every change, and a write keeps the fields
it does not know.

| Function | Request | Response |
|---|---|---|
| `harness::projects::list` | `{ version: 2 }` | `{ version: 2, revision, projects }` |
| `harness::projects::create` | `{ name, color, folders, account?, autocompact?, bring_existing? }` | `{ project, moved }` |
| `harness::projects::update` | `{ id, name?, color?, folders?, account?, autocompact?, bring_existing? }` | `{ project, moved }` |
| `harness::projects::delete` | `{ id }` | `{ released }` |
| `harness::projects::assign` | `{ session_ids, project: <id> \| "none" }` | `{ updated }` |

Like every harness control-plane function these are internal: they stay
off the default `engine::functions::list` (list them with
`include_internal: true`). Agents may call `harness::projects::list` by id;
the writes are denied to them.

A conversation belongs to a project through `metadata.project_id`; `"none"`
keeps it out on purpose. `bring_existing` stamps the root conversations whose
`metadata.fs_scope.root` falls in the project's folders (only the folders an
`update` adds) and whose `project_id` is missing or `"none"`; `delete` removes
`project_id` from its conversations; `assign` moves each conversation with its
sub-agents (`parent_session_id`) and side chats (`side_chat_of`).
`harness::send` stamps `project_id` on a conversation that has none when its
working folder belongs to a project, and a sub-agent copies its parent's.
Every write goes through `session::patch-meta`, with `touch: false`: moving
a conversation in or out of a project keeps its `updated_at`, so the lists
sorted by it keep their order. A refusal is one JSON object
in the error message, `{ code, message, ... }`: `name_taken`, `folder_taken`
(with `project_id`, `project_name`), `bad_name`, `bad_color`, `no_folders`,
`too_many_folders`, `folder_not_absolute`, `not_found`, `bad_request`,
`invalid_account`, `bad_setting`, `bad_tokens`. A project's `account` is
`{ mode: "global" }` (the default) or `{ mode: "pinned", account_id }`: the
Claude Code account its conversations run on (see
[Claude Code accounts](#claude-code-accounts)). Its `autocompact` is
`{ mode: "inherit" }` (the default), `{ mode: "off", tokens? }` (the size
kept, inert) or `{ mode: "tokens", tokens }` (see [Autocompact](#autocompact)).

**Descriptions.** `harness::set-description { description, title? }` is a
tool the model gets in every turn (with its own description, in the cached
tools block) while `descriptions.agent_writes` is on and the dispatch policy
allows it. The turn loop answers it for the turn's own session, next to
`harness::ask`; a direct call fails. The description is trimmed, its
whitespace collapsed and cut at 140 characters; one `session::patch-meta`
writes `description`, `description_by: "agent"`, `description_at_ms` and
`description_history` (the previous one pushed in, newest first, five kept).
`title` is written once, while `title_manual` is not set and the agent never
named the conversation (`title_by: "agent"`), else the result carries
`title_ignored: true`. A description the user wrote (`description_manual`)
is refused with `The user wrote this description; leave it.`, an empty one
with `empty`, and the same text is a no-op. A step whose only calls are
`harness::set-description`, in a reply that already has text, never ends the
turn: the result adds a `next` note and the model is asked again; when that
step ends with no text, the reply beside the description is the turn's
answer.

**Chat settings.** `harness::chat-settings::get {}` answers `{ descriptions:
{ agent_writes }, autocompact: { mode, tokens?, instructions? } }`;
`harness::chat-settings::set { patch }` merges the patch into the stored
`harness` configuration on the server (an `autocompact` field set to `null`
is removed; `tokens` and `instructions` stay while the mode is `off`; the
default, off with neither, is not stored). A harness older than 1.13 refuses
a configuration that holds `autocompact`.

**Context pane.** `harness::context-items { session_id }` answers what a
conversation gathered, newest first: `subagents` (direct children, with
`status` running / done / failed, the `display` label and a `descendants`
count), `pull_requests` (GitHub PR URLs in user and assistant text and in
function results, `source: created` for `github::pr::create`; `state` and
`checks` read through `github::exec` when the github worker is present,
cached 120 s, at most 3 s per call; `context_dismissed_prs` left out), `links`
(http(s) URLs in user and assistant text, with a `count` and the Markdown link
text as `title`), `attachments` and `images` (`direction: sent` in a user
message, `received` otherwise; files the agent wrote outside its working
folder count as received), and `side_chats` (see [Side chats](#side-chats)). Links,
attachments and images stop at 200 / 100 / 200 and `truncated` says so. The
transcript is read in pages through `session::messages-range` and indexed in
memory per session (the 64 most recent), so a later call scans only the new
entries.

## Side chats

A side chat is a side conversation forked from a point of a conversation. It
knows the conversation up to that point, runs on the conversation's model,
effort and account (so its first request reads the conversation's prompt
cache), and writes nothing into the conversation. A conversation can have
several. Like the rest of the control plane these functions are internal
(`engine::functions::list { include_internal: true }`); agents are denied
them.

| Function | Request | Response |
|---|---|---|
| `harness::side-chat::open` | `{ session_id, entry_id?, quote?: { message_id, text, agent? } }` | `{ session_id, meta }` |
| `harness::side-chat::close` | `{ session_id }` | `{ deleted, operation_id? }` |
| `harness::side-chat::keep` | `{ session_id }` | `{ meta }` |
| `harness::side-chat::summarize` | `{ session_id }` | `{ turn_id }` |

**`open`** names the conversation and the entry to fork at (default: its last
user or assistant message; a reply still streaming is skipped, so a side chat
can open while the conversation's turn runs). It calls
`session::fork { title: "Side chat" }`, then writes on the fork with one
`session::patch-meta`: `side_chat_of` (the conversation), `side_chat_from`
(the fork's own copy of the entry, as the ADE writes it), `side_chat_lock`
(`{ model, provider?, thinking_level?, account? }`, for display),
`side_chat_fork_point` (`{ entry_id, message_count }`: the conversation's
entry, for the mark under it, and the messages the fork copied) and
`side_chat_quotes` (`[quote]`, when given). It removes the spawn links a fork
copies (`parent_session_id`, `parent_turn_id`, `function_call_id`,
`parent_function_call_id`, `depth`, `spawned_by`, `root_session_id`) and who
named or described the conversation (`title_manual`, `title_by`,
`description_*`; the description is emptied). `meta` is the side chat's
session record after that write. The full lock goes to harness state
`harness_side_chat/<side chat id>`: `{ session_id, parent_session_id,
parent_entry_id, model, provider, thinking_level, provider_options (the
account among them), functions, skills, fs_scope, created_at_ms, source }`.
The conversation's turn record is copied onto the side chat as a finished
turn, so its first send continues from the conversation's own system prompt,
skills, dispatch policy, working folder and language; the fork also copies
the conversation's frozen `runtime_context` entry, so the system prompt is
the conversation's byte for byte and the session id change reaches the model
as a notice after it. Refusals: `nested_side_chat` (the session is a side
chat), `nothing_to_fork` (no turn yet), `not_found` (unknown session or
entry).

**The lock.** `harness::send` on a side chat runs on the lock. A send that
names a different `model`, `provider`, `thinking_level`, `provider_options`,
`reasoning`, `functions`, `skills` or `metadata.fs_scope`, or any
`system_prompt`, `system_prompt_strategy` or `agent`, fails with
`side_chat_locked` (`{ code, message, field, sent, locked }`); naming the
lock's own value is accepted, and clients send none. The Claude Code
account is not part of that comparison: a side chat runs on the account its
lock stored (the conversation's at the fork) and resolves none of its own. A side chat the ADE forked
before side chats (no lock in state) is locked at its next send to the
conversation's options then (`source: "lazy"`), and starts from the
conversation's turn record when it has none of its own. The first send names
the side chat after its message (whitespace collapsed, cut at 60 characters
with `…`), unless `title_manual` is set.

**`close`** deletes a side chat in which nothing was sent since the fork
(through `harness::delete-session-tree`, whose `operation_id` it returns) and
answers `deleted: true`; one with messages stays (`deleted: false`). Clients
call it when the person closes an empty side chat. **`keep`** removes
`side_chat_of`, `side_chat_from`, `side_chat_lock`, `side_chat_fork_point` and
the lock, and puts the conversation's `project_id` on it (`touch: false`): it
becomes an ordinary conversation in the conversation's project.
**`summarize`** sends, in the side chat, `Summarize what we concluded in this
side conversation for the main conversation, in at most five short lines.
Plain text, no preamble.` as a turn with `options.metadata.side_chat_summary:
true`; when that turn completes, the entry id of its reply is appended to the
side chat's `side_chat_summaries` (the newest 20) before
`harness::on-turn-completed`. It is refused with `side_chat_busy` while a turn
runs in the side chat. `close`, `keep` and `summarize` answer `not_found` for
an unknown session and `not_side_chat` for one that is not a side chat. Every
refusal is one JSON object in the error message, as for projects.

`harness::context-items` lists a conversation's side chats in `side_chats`,
from `session::list` filtered on `side_chat_of`, most recently active first:
`{ session_id, title, message_count, created_at_ms, updated_at_ms,
from_entry_id?, status, running }`. `message_count` counts the messages added
since the fork (all of them for a side chat forked before side chats),
`from_entry_id` is the conversation's entry it was forked at, `status` is
`running`, `done` or `failed` as for subagents, and `running` is true while a
turn runs. Deleting a conversation deletes its side chats.

## Claude Code accounts

A turn on the `claude-code` provider runs on one of the Claude Code accounts
the tmux worker signs in (chat-projects phase 4). When the turn starts, the
harness resolves the account once and freezes it on the turn:

1. the conversation's `metadata.claude_account` (an account id, or `"global"`
   for the global account), written by clients through `session::patch-meta`;
2. else its project's `account`, when it is `{ mode: "pinned", account_id }`;
3. else the global account, read from `tmux::accounts::list` (`global`).

The id goes into `provider_options["claude-code"].account` after the preset,
the inherited options and any named options, and a client's own `account`
there is dropped. The turn record keeps `account { id, source }`, `source`
being `session`, `project` or `global`. A sub-agent runs on the account of
its parent's current turn, whatever it inherited when it was spawned (only a
parent with no turn record leaves it the inherited id), and a side chat on
its lock's. A pin, a parent's or a lock's account that tmux no longer lists
fails the turn before any model call with `harness.unknown_account`. With no
tmux worker (or tmux reporting Claude unavailable) no account is set, an
inherited one is dropped, and the provider keeps its single sign-in.

When tmux is there but cannot answer (an error or a timeout), or the projects
file cannot be read for a conversation whose project may pin its account, the
account cannot be decided: the turn's first step runs again after a short
pause, spending one of its transient resumes (a `recovery` entry with `code:
"harness.accounts_unavailable"`, phase `pre_turn`). When they run out, the
turn fails with `harness.accounts_unavailable`, retryable, before any model
call, and `harness::retry` can run it again. A side chat whose lock holds an
account, and a sub-agent whose parent's turn has one, keep it while tmux
cannot answer.

The verbose `harness::status` and `harness::on-turn-started` /
`harness::on-turn-completed` carry `account { id, source }`; the lean status
does not.

**The usage limit.** The router reports an account's plan limit as a
`rate_limited` error whose `error_details` are `{ usage_limit: true, window?:
"five_hour" | "week", resets_at_ms? }`, on the response, on its terminal
message, or on the error of a call that could not be dispatched (its message
then a JSON object carrying them). The turn is not resumed (no transient
resume runs) and fails with `llm.usage_limit`, not retryable; the turn's
`failure.details` and the transcript's error entry carry `{ usage_limit,
window?, resets_at_ms?, account }`. The lean status leaves `details` out.

| Function | Request | Response |
|---|---|---|
| `harness::retry` | `{ session_id }` | `{ turn_id }` |
| `harness::metrics::account-split` | `{}` | `[{ account, week_percent, resets_at_ms?, outside_measured, segments }]` |

Both are internal, and agents are denied them.

**`harness::retry`** runs a session's failed last turn again, as a new turn
with the same user message (no second one is appended), on the session's
current options and a newly resolved account, so a client that wrote
`claude_account` first ("Continue in …") runs it there. The options are
those a send naming nothing would take: the last turn's model, provider,
reasoning, prompt, skills and policy, the configured per-turn limits, and its
working folder but none of its send's own metadata; the failed turn's output
contract stays. A sub-agent's account resolves from its parent's current turn. A turn that had streamed part of an answer continues with the
same nudge as a transient resume. Refusals: `nothing_to_retry` (no turn, or
the last one did not fail) and `busy` (a turn is running).

**The ledger.** `claude-code` turns have no price, so each model response's
tokens (`input`, `output`, `cache_read`, `cache_write`) are added to the
`state` scope `harness_account_usage`, one document per day, account and
project (`<day>:<account>:<project id | none>`), by hour and Anthropic model.
A response whose prompt (input, cache reads and cache writes) passes its
model's long-prompt threshold (Haiku 5.5: 100,000 tokens) counts under
`<model>#long`, priced on the long-prompt card. A day is kept for 35 days (the
day and the 34 after it), then deleted. A day's document that cannot be read
is moved to `harness_account_usage_unreadable` (`<key>@<unix ms>`) before the
day is counted again, and the split skips one it cannot read.

**`harness::metrics::account-split`** answers, for each account
`tmux::usage::read` lists, its weekly percentage split into `segments`:
`{ kind: "project", project_id, name, color, percent }`, `{ kind:
"no_project", percent }` and `{ kind: "outside", percent }`. The week starts
seven days before its reset. The Chat's tokens since then (the ledger) and the
tokens tmux measured outside the Chat (`tmux::usage::claude_outside`) are
priced at the Anthropic list price (`router::models::get`, else a built-in
table, else the nearest model of the same family, else Sonnet 5.5's, logged
once per model), and each segment gets `week_percent × its cost ÷ the total
cost`. A project deleted since counts as no project. A week that reset after
tmux read it is at 0% with no segments; when tmux no longer knows its reset,
it starts now. When tmux cannot measure the outside, `outside_measured` is false
and the Chat's segments share the whole week. With no tmux worker the answer
is `[]`; a failing tmux is `tmux_unavailable`.

## Observable functions

The harness hosts these functions. Every one is private: observers observe it,
and only the harness calls it. Each handler returns the event it is called
with, so observers receive the event as the call's output (with `capture:
['output']` the target reads it at `payload.output`). Observe them with `iii.observe` from a worker; an agent
observes only `harness::on-timer` and its own post-turn validator.

| Function | Args | Filter on | Event |
|---|---|---|---|
| `harness::on-ready` | none | — | `{ status: 'ready', timestamp }`. An observer added after boot receives the current ready event once it is active, as a call of the function for that observer alone (metadata `{ for_observer: <observer id> }`), in the same shape as the boot event. |
| `harness::on-ask` | none | `input.session_id`, `input.question_id` | The whole durable ask entry when a question is accepted. |
| `harness::on-ask-settled` | none | `input.session_id`, `input.question_id` | The whole durable ask entry after it closes. |
| `harness::on-turn-started` | none | `input.session_id`, `input.parent_session_id`, `input.parent.session_id` | `{ session_id, turn_id, timestamp, depth, message_preview?, parent?, parent_session_id?, account? }`: a turn began executing (first loop step); `depth` is 0 at the top level. `account` is `{ id, source }` on a `claude-code` turn (see [Claude Code accounts](#claude-code-accounts)). |
| `harness::on-turn-completed` | none | as `harness::on-turn-started` | `{ session_id, turn_id, status, terminal, open_asks, timestamp, result?, result_error?, reason?, parent?, parent_session_id?, context?, account? }`: a turn reached `completed` / `cancelled` / `failed`. `terminal` is `false` while the session still owns an armed wake (a claimed one counts until its delivery has seeded the woken turn, and never for the turn that took it, drained from that turn's queue or merged into it), or when the turn's finalize drained a queued message and reseeds the session, so consumers finalize an exchange on `terminal: true`. `harness::status` reports the same as `expects_wake: true`. A turn that ended with a wake armed and was then stopped completes twice: `terminal: false`, then `terminal: true` when its last wake is gone. A turn whose reseed fails also completes twice, the second time with the terminal decision its finalize deferred. A reseed continues the exchange in a new turn, so its terminal completion can carry another `turn_id` than the one `harness::send` returned: correlate on `session_id`. A finalize interrupted before its reseed (the process died), or whose reseed and settle both failed, is finished by a redelivery of the same step: the queue's, or the orphan redrive's, which re-delivers a finished turn that still promises a continuation, or still owes the completion a failed settle or stop left unsent, as it does a running one. |
| `harness::on-message-queued` | none | `input.session_id` | `{ session_id, entry_id, queued_at, timestamp }`: a message parked in the session's queue while its turn streams. |
| `harness::on-observers-changed` | none | `input.session_id` | `{ session_id, timestamp }`: the session's observers or their fire counts changed; read `harness::observers::list`. |
| `harness::on-compaction` | none | `input.session_id`, `input.compaction_id` | `{ session_id, compaction_id, phase, timestamp, trigger, source, threshold_tokens?, rule?, ... }`: a compaction started (`phase: started`) or finished (`phase: completed` with `status` ok/busy/empty/failed/cancelled, the user-facing `message`, `tokens_before` / `tokens_after`, `context_before` / `context_after`, `failure?` and the transcript `entry_ids`). `trigger` is `command`, `auto`, `inline` or `limit`; `inline` and `limit` emit only `completed`. |
| `harness::on-session-tree-deletion` | none | `input.session_id`, `input.operation_id` | `{ operation_id, attempt, session_id, status, deleted_session_ids, error? }`: a subtree deletion changed status; terminal statuses are `completed` and `failed`. |
| `harness::projects::on-changed` | none | `input.project_id`, `input.change` | `{ revision, project_id, change }`: a chat project was `created`, `updated` or `deleted`; refetch `harness::projects::list { version: 2 }`. |
| `harness::chat-settings::on-changed` | none | — | `{ settings }`: the Chat settings changed, from a device or the configuration entry. |
| `harness::on-timer` | `{ at }` (epoch ms) | — | `{ scheduled_at, actual_at }`: called once at `at`; an observer receives the call for its own `at`. `at` more than 7 days out is refused (`CONFIG_ERROR`). An `at` already past (an observer added again after the harness was down) is called once, as soon as the observers of that instant added together are active. |

An observer whose target is `harness::spawn` is refused (`FORBIDDEN`) on the
turn events.

### Hook points

Six synchronous hook points, each a private function. At each point the
harness calls the function with the hook input and waits for the merged
outcome. Its deliver hook runs the chain: the observers whose `sessions` and
`functions` globs match the input and whose filters match the call, in
`priority` order (ties by target), each called through its observer with the
input as the previous one left it. A `<namespace>/<pattern>` entry in
`functions` matches one engine namespace; a bare pattern matches every
namespace. A qualifier with glob characters, an empty one or a doubled slash
(`*/shell::*`, `/shell::*`, `laptop//shell::*`) reads as bare, with a one-time
warning, so the hook still runs in every namespace. For now an entry written for a mesh id's old
spelling (`laptop::shell::*`, `hub::shell::*`, `peer::*`) still matches the call in that other
namespace, with a one-time warning; write `<namespace>/<pattern>`, since a later release drops the
old spellings. A harness older than this one matches no call for a
`<namespace>/<pattern>` entry and skips the hook; register one only after a
hook input carried `own_namespace`. A target answers
`{ decision, reason?, mutations?, annotations? }`.

The handler returns the hook input, so the function's `request_format` and
`response_format` are the input, and that is what observers observe. Every
input carries `{ point, session_id, turn_id, step, depth, own_namespace,
metadata? }` (`own_namespace` is the namespace the harness runs in, where a
call without a namespace goes; `metadata` is the turn's `options.metadata`)
plus the point's own fields. The harness gets back the merged outcome,
`{ decision, reason?, held_by?, system_prompt?, append_messages?, arguments?,
result?, prompt?, annotations? }`, with `decision` `continue`, `deny` or `hold`.

Each turn step also carries the namespace as the OpenTelemetry baggage
`iii.own_namespace`, next to `iii.session.id`, so a worker the step calls (the
directory's search and info) knows where a call without a namespace goes. The
baggage is set around the turn step only, so a held call released later
reaches iii-directory as if from an older harness and gets the old output.

| Function | Runs | Input adds | The harness gets back |
|---|---|---|---|
| `harness::hook::on-pre-turn` | First step of a turn, before any model spend. May veto. | — | `decision`, `reason?` |
| `harness::hook::on-pre-generate` | After context assembly, before generation. May extend the system prompt, append messages, or veto. An observer whose contribution is static passes it as the arg `inject_prompt`; the harness appends it before context assembly to the turns its `sessions` globs and filters select (filters see the input without the assembled `system_prompt`, `messages` and `tools`), so the budget and compaction count it, and its target is not called. It joins the stable prefix ahead of the per-session runtime aid, so every session it selects shares it from the provider's prompt cache. | `generate { system_prompt, messages, model, provider, functions_generation, tools, expose }`, `parent?`, `parent_session_id?` (a sub-agent turn's parent, as on `harness::on-turn-completed`) | `decision`, `reason?`, `system_prompt?`, `append_messages?`, `annotations?` |
| `harness::hook::on-post-generate` | After the final assistant message. Observe only. | `generated { message }` | `decision: continue` |
| `harness::hook::on-pre-call` | After the allow/deny policy passes, before the called function runs. May deny, hold, or rewrite arguments. Never consulted for `harness::ask`, which the turn loop answers itself. | `call { id, function_id, namespace, implicit_namespace, arguments, description? }` (`namespace` is the engine namespace the call runs in; `implicit_namespace` is where this id runs when a call names none; `description`: the `agent_call` wrapper's display-only description of the call, when the model gave one; absent on a direct `harness::function::call`; a released hold recovers it from the transcript) | `decision`, `reason?`, `held_by?`, `arguments?`, `annotations?` |
| `harness::hook::on-post-call` | After the called function returns, before the result is persisted. May rewrite the result, or move the session's working directory (below). | `call`, `result { function_call_id, function_id, content, is_error, details }` | `decision`, `held_by?`, `result?`, `annotations?` |
| `harness::hook::on-post-turn` | At finalize, after the output contract validated the result. A deny re-prompts the turn (bounded by `max_validation_retries`). | `result` (the turn's result) | `decision`, `reason?`, `prompt?` |

Hook args: `{ functions?, sessions?, payload?, result_into?, retry_prompt?,
priority?, timeout_ms?, on_error?, inject_prompt?, input? }` — `functions` globs select
the called functions (`on-pre-call`, `on-post-call`), `sessions` globs the
sessions (omit for every session), `payload` + `result_into` call a plain
composition function as an `on-post-turn` validator, `timeout_ms` bounds each
call (default 5000), and `on_error` is `fail_closed` (default for the `pre`
points and `on-post-turn`) or `fail_open`. A call that fails, times out, or is
refused (`OVERFLOW`, `OBSERVER_NOT_ACTIVE`) follows `on_error`. `input` lists the
input fields the target reads as dotted paths, `[]` mapping over a list
(`generate.tools[].name` sends each tool as `{ name }`); the target gets those
plus the envelope (`point`, `session_id`, `turn_id`, `step`, `depth`,
`metadata`, `own_namespace`). An `on-pre-generate` input carries the whole
prompt, every message and every tool schema, so a target that reads a few of
them should list them.

```rust
iii.observe(
    Source::function("harness::hook::on-pre-generate")
        .args(json!({ "priority": 100, "timeout_ms": 3000, "on_error": "fail_open",
            "input": ["generate.messages", "generate.tools[].name"] })),
    "judge::mentions::pre-generate",
);
```

An `on-post-call` target may move the session's working directory: it answers
`{ "decision": "continue", "mutations": { "fs_scope": { "root": "/abs/path" } } }`.
The `ide` worker does this after a `shell::exec` that created a git worktree
(unless the call passes `follow_worktree: false`), or removed the one the
session is rooted in. The harness takes the mutation
only when both the target and the called function are `shell::*` / `coder::*`
ids. That is a filter that keeps the scope-enforcing workers the only
proposers, not authentication: any worker on the bus can already send a
session any root. A failed call, a call that ran in another namespace, a
relative path or an unscoped session never moves; neither does a turn with
another call awaiting approval, and the call's result tells the model so. On a
move the harness:

- sets the turn's root, so the step's later calls run there, later turns keep
  it, and the model gets a runtime-context note at its next generation;
- then mirrors `fs_scope { root, moved_from }` into the session's metadata
  with `session::set-meta`. `moved_from` is the guard a client compares with
  the folder it shows before following; the harness never reads it.

Under the `workspace` boundary an approved `git worktree add` also moves the
boundary there, for sub-agents too. A send that names a root still wins, so a
client must adopt the mirrored root or its next send moves the session back. A
re-tasked sub-agent keeps its own root unless the spawn names one.

A folder granted for the session (`harness::filesystem::grant`) is stamped only
on a call in the namespace a call without `namespace` runs in. A call in
another namespace carries the session's root and only the folders its own
release grants, so `shell` or `coder` refuses the folder there. The harness
does not ask for it again: the folder watch of `approval-gate` does, per call,
once that worker checks folder grants per namespace. An older approval-gate
reads the session's grant as covering the folder and does not ask, so the model
gets only the refusal; update approval-gate with this harness.

### Agent observers

An agent observes with `harness::observe` and removes an observer with
`harness::unobserve { id }`; the harness intercepts both in the turn loop and
creates the observer itself, for the calling session:

```ts
// harness::observe
{
  function_id: string           // the observed function
  namespace?: string            // default: the harness's namespace, then `default`, then Compose's
  args?: object                 // for harness::on-timer: { at } or { in_ms }
  filters?: object              // e.g. { "input.scope": { "$eq": "run" } }
  target?: { function_id: string; payload?: object; event_into?: string }  // omitted: wake this session
  label?: string
  action?: string               // user-facing text shown with each delivery
  once?: boolean
  conditions?: { function_id: string; config?: object }[]
  lifecycle?: { once?: boolean; max_fires?: number; expires_in_ms?: number }
}
→ { observer_id: string; once: boolean; note?: string }
```

Each observer is a durable binding in the harness's state; its engine
observer targets `harness::observer::deliver` with the binding id as observer
id. The delivery hop takes the `Observed` envelope of iii's delivery (the event
is the call's `output`) and the payload a source's deliver hook sends through
the observer (`kanban::on-change`, `stories::on-changed`: the event is the
payload as sent). The harness counts delivered fires
itself (`once`, `max_fires`) and runs the conditions before a delivery; the
lifecycle deadline is also the observer's `expires_in_ms`. A one-shot wake
without a deadline gets 10 minutes, unless it observes `harness::on-timer` or
`cron::on-tick`; when one passes unfired, the session is woken with a notice. The harness waits
briefly for the observer to become active, so `INVALID_ARGS`, `FORBIDDEN`,
`NOT_OBSERVABLE` and a worker's rejection come back to the agent. An observer
reads every call of the function it observes, other sessions' included, so the
session's dispatch policy must allow that function, as it must allow a target
or a condition; functions no agent may call (credential and private state
accessors, `harness::observer::deliver`) are refused either way. `workflow::start`
is refused as a target, and a stored binding that names it does not fire: a
delivered call skips the pre-call hook that stamps the caller's folder. Allowing a
private event source (`state::on-changed`, `shell::on-job-finished`,
`harness::on-timer`) lets the agent observe it, never call it, and it is not
offered as a tool. Bindings stored by harness versions before 0.26 are
translated at boot, or retired with a notice to their owner. `harness::observers::list { session_id? }` and
`harness::observers::dispose { observer_id, session_id }` are the console's
read and teardown over a session's observers; new transcript records use the
custom type `observer_fired`.

The harness also observes, for its own plumbing: `engine::on-workers-changed`,
`engine::on-functions-changed`, `directory::skills::on-change`, `cron::on-tick`
(`{ expression }`, the pending-call sweep), `session::on-deleted`,
`configuration::on-updated`, `compose::on-operation-progress` (terminal events)
and `ade::ui::asset` for its console UI.

See the spec at
[`tech-specs/2026-06-agentic/harness.md`](https://github.com/iii-hq/workers/blob/main/tech-specs/2026-06-agentic/harness.md)
for the hook contract and chain semantics.

## skills

This version ships 2 skill files for agents, also browsable on the worker page:

- [`SKILL.md`](https://iii.dev/registry/workers/harness?tab=skills&skill=SKILL.md&version=1.11.5)
- [`skills/orchestration.md`](https://iii.dev/registry/workers/harness?tab=skills&skill=skills%2Forchestration.md&version=1.11.5)

### SKILL.md

# harness

The harness is the durable turn loop that wires `session-manager`, `llm-router`,
and `context-manager` into an agent. A consumer stays thin: it kicks off a turn,
renders the conversation from the session transcript, and reacts to turn
boundaries and human-gated calls. The harness streams the assistant message into
the session as it generates, so you watch the session, not the harness — there
is no `agent::events` stream, and `harness::status` is a point-in-time recovery
read, not a render feed.

Every invocation is a call (`iii.call({ function_id, payload })`), and every
reaction is an observer (`iii.observe(source, target)`). Tool dispatch is
deny-by-default: a send with no
`options.functions.allow` is a plain chat loop and every model-requested call is
refused until you allow globs per send. Sessions are minted by the harness
(`s_<uuid>`) or supplied by you; a send into a running turn folds in as steering
(`merged: true`) instead of erroring, and a repeated `idempotency_key` returns
the original turn without appending.

A session-creating send names a `model`, or only a `provider`: the harness
then starts on that provider's declared default model (`default_model` in
`router::provider::list`, checked against its live catalog; a provider that
reports none fails the send as before). A new session that names neither
`thinking_level` nor `provider_options` also starts on the provider's
`default_thinking_level`; an explicit level wins, and later sends into the
session inherit the prior turn's as usual. `thinking_level` is `off`,
`minimal`, `low`, `medium`, `high` or `xhigh`; `off` is honoured only on
models whose catalog entry says `supports_thinking_off: true`; elsewhere the
fallback is the provider's own (most send their lowest effort and warn, Kimi
ignores the level).

Prerequisites: `session-manager` (required — transcript store and change feed)
and `llm-router` (required — generation and the model catalog) must be present.
`context-manager` (token budgeting and compaction) is a soft dependency — absent
it, the harness sends raw history. `approval-gate` (the human-in-the-loop gate)
is optional; without it no call is held and every allowed call runs un-gated.

## When to Use

- Start or steer an agent turn and return immediately (`harness::send`).
- Cancel an in-flight turn (`harness::stop`) or read coarse turn state for
  recovery and guards (`harness::status`).
- Chain turns or react to outcomes from a worker by observing
  `harness::on-turn-completed` with the SDK's `iii.observe`. An in-run agent
  cannot observe turn events; see [Agent observers](#agent-observers).
- Drive a turn from an arbitrary inbound event (cron tick, webhook, sensor) by
  translating it into a `harness::send`.

## Boundaries

- Not a transcript feed. Render from `session-manager`'s `session::on-message-added`
  / `on-message-updated` / `on-status-changed` (reconcile by `revision`); do not poll
  `harness::status` for content.
- Not the approvals engine. The harness ships only the gate mechanics; the
  policy, decision RPCs (`approval::resolve`), inbox (`approval::list-pending`),
  and prompt events live in `approval-gate`.
- Not a chain guard. `options.max_turns` bounds a single turn, not a
  send-completed-send loop; carry your own stop condition.
- Do not call the internal functions (below) — they forge call ids and turn
  progress, so calling them out of band corrupts the turn record.
- An in-run agent cannot start turns: `send` / `run` / `turn` / `stop` are denied
  to the model by policy. `harness::spawn` is the only turn-starter an agent calls,
  and it self-enforces depth, fan-out, and policy subsetting. An observer never
  starts an agent: an agent observes with `harness::observe` to be woken (or to
  have a plain function called), and spawns from the woken turn.

## Functions

Consumer-facing:

- `harness::send` — ensure the session, persist the incoming message, and kick
  off a turn; returns fast or merges into a running turn (steering).
- `harness::stop` — request cancellation of an in-flight turn; cascades to
  spawned children and kills the `shell::exec_bg` jobs the stopped sessions
  started through their own tool calls (the harness stamps those with the
  session; jobs started by observer deliveries or `fp::pipe` steps are unowned
  and survive). It does not end a session parked on a wake, which ends on its next
  wake, deadline included. A stop that means no more turns passes
  `quiet_deadlines: true`: that wake's deadline then starts no turn, and the session
  ends as cancelled.
- `harness::status` — read the current turn state for a session; `null` when no
  turn ever ran. For recovery and guards, not rendering.
- `harness::spawn` — spawn a sub-agent in a child session. Model-facing (invoked
  through `agent_call`), not a consumer entry point.
- `harness::observe` / `harness::unobserve` — the agent's observe tools,
  intercepted by the turn loop for the calling session (see Agent observers).
- `harness::observers::list` / `harness::observers::dispose` — read and remove a
  session's agent observers (in-turn calls default to the calling session).
- `harness::ask` — put a decision with discrete options to the user as a
  clickable card (1–4 questions, 2–4 options each). Model-facing (invoked
  through `agent_call`) and answered by the turn loop itself: the turn ends
  on the question and the answer arrives as the user's next message, one
  `Header: answer` line per question (`(skipped)` for a question the user
  passed on; a dismissed card sends a notice instead). Refused in
  sub-agents, structured-output turns, and for a second ask in one step.
- `harness::set-description` — keep the conversation's one-line description
  (and, once, its name) up to date. Offered as a tool of its own in every turn
  while the Chat setting `descriptions.agent_writes` is on; answered by the
  turn loop for the turn's own session, so a direct call fails. Call it with
  other calls or beside the reply text: a step whose only call it is, beside
  reply text, asks the model once more (end with no text when the reply was
  the answer; that reply is then the turn's result). A description the
  user wrote is never replaced (`The user wrote this description; leave it.`).
- `harness::projects::list { version: 2 }` — the chat projects: named,
  coloured groups of folders; a conversation's `metadata.project_id` names
  its project (`"none"` = kept out on purpose). Always send `version: 2`;
  without it the call answers the saved folders for apps released before
  projects. Internal like every harness control-plane function (off the
  default `engine::functions::list`), but agents may call it by id.

Console and app control-plane (internal, list them with
`engine::functions::list { include_internal: true }`): `harness::folders::list`
/ `upsert` / `delete` (the saved-folder catalogue, formerly
`harness::projects::*`), `harness::projects::create` / `update` / `delete` /
`assign` (refusals are one JSON object in the error: `{code, message}` with
`name_taken`, `folder_taken`, `bad_name`, `bad_color`, `no_folders`,
`too_many_folders`, `folder_not_absolute`, `not_found`), `harness::context-items`
(the context pane: subagents, pull requests, links, attachments, images and side
chats of a conversation, newest first), `harness::chat-settings::get` / `set`,
and the side chats: `harness::side-chat::open { session_id, entry_id?, quote? }`
(fork a conversation at an entry into a side chat that runs on its model,
effort and account, locked by `harness::send`: a send naming other options
fails `side_chat_locked`), `harness::side-chat::close { session_id }`
(`deleted: true` when nothing was sent in it), `harness::side-chat::keep
{ session_id }` (an ordinary conversation in the conversation's project) and
`harness::side-chat::summarize { session_id }` (a fixed summary prompt; the
reply's entry id joins `side_chat_summaries`). Their refusals:
`nested_side_chat`, `nothing_to_fork`, `side_chat_locked`, `side_chat_busy`,
`not_side_chat`, `not_found`. Agents are denied the writes and the side-chat
functions.

Internal — the harness drives these; never call them directly:
`harness::turn` (the durable loop step), `harness::function::call` /
`harness::function::resolve` (dispatch and parked-call settle),
`harness::observer::deliver` (the target of every agent observer),
`harness::sweep-pending` (cron expiry), and `harness::on-config-change`
(hot-reload).

## Filesystem scope

`options.metadata.fs_scope.root` on a send is the session's working
directory; a later send that omits `fs_scope` keeps it. The harness stamps a
trusted `fs_scope { root, grants, boundary }` onto every `shell::*` /
`coder::*` call and strips any the model supplies. `boundary` decides what
`root` means to the `ide` worker:

- `workspace` — `coder::*`, `shell::fs::*` and an exec `cwd` stay inside
  `root` plus the session's grants (`harness::filesystem::grant`).
- `configured_roots` — `root` only anchors relative paths; the worker's own
  roots apply. The model's prompt says so ("default directory, not an access
  boundary").

The `filesystem_boundary` config picks it: `auto` (the default) is
`workspace` only while approval-gate's access watch is bound; `workspace` or
`configured_roots` pins it. `harness::filesystem::info` reports the boundary
in effect. A sub-agent spawned in a turn into a new session starts with a
copy of its parent's grants; later grants to the parent do not reach it.
Under `workspace`, an in-turn spawn's `options.filesystem_root` must lie
inside the parent's root or grants. What an exec'd process itself writes is
the `ide` worker's `fs.exec_confinement` switch.

A `harness::hook::on-post-call` target may move the working directory by
answering `mutations.fs_scope.root` on a `shell::*` / `coder::*` call; the
`ide` worker does so after a `git worktree add`, unless the call passes
`follow_worktree: false` (and back, after removing the worktree the session is
rooted in). Only a `shell::*` / `coder::*` target is heard: a filter, not
authentication. The step's later calls and later turns
run in the new root, and session metadata gets `fs_scope { root, moved_from }`.
Under `workspace` an approved `git worktree add` moves the boundary too, for
sub-agents as well. A send that names a root still wins, so a client must
adopt the mirrored root. A re-tasked sub-agent keeps its own root unless the
spawn names one.

## Attachments

A file attached to a message is stored by `session-manager` and rides the
message as a `file` block (the text mentions it as `@attachment(id="a_…")`).
The model never gets the bytes or the raw block: each `file` block reaches it,
in place, as one text block whose attribute values are escaped as XML:

```text
<attachment id="a_…" name="report.pdf" mime="application/pdf" size="1234567">
Read it with session::read-attachment {"session_id":"<sid>","attachment_id":"a_…"}
</attachment>
```

Read a file by making that call when the task needs it; nothing is inlined.
`session::read-attachment` answers the characters of a text file, or of an
office document converted to markdown, in windows (`offset`, `next_offset`),
and for a PDF, an image or any other file `how_to_read`: the exact `fp::pipe`
calls that convert it to markdown (`pdf::to-markdown`) or save a copy in a
temporary folder outside the working folder for your own tools (unzip an
archive, run a script over data), or the worker to install when one is
missing. When the message also carries the file's picture, the block says so
before the call. The persisted transcript keeps the `file` block.

## Turn events

The harness hosts private functions that consumers and sibling workers observe
with the SDK's `iii.observe` instead of polling `harness::status`. Each returns
the event it is called with, so an observer with `capture: ['output']` receives
the `Observed` envelope with the event at `output`. They are not agent-observable: `harness::observe` refuses
them (see [Agent observers](#agent-observers)).

- `harness::on-turn-started` — a turn began executing (first loop step).
- `harness::on-turn-completed` — a turn reached a terminal status
  (`completed` / `cancelled` / `failed`), carrying the result or error for
  chaining, failure toasts, auto-titling, and result delivery; `terminal` is
  `false` while the session still owns an armed wake. A turn that ended with a
  wake armed and was then stopped completes twice: `terminal: false`, then
  `terminal: true` when its last wake is gone.
- `harness::on-message-queued`, `harness::on-observers-changed`,
  `harness::on-compaction`, `harness::on-session-tree-deletion` and
  `harness::on-ready` — see the worker README for their events.
- `harness::projects::on-changed` — a chat project was created, updated or
  deleted (`{ revision, project_id, change }`); refetch
  `harness::projects::list { version: 2 }`.
- `harness::chat-settings::on-changed` — the Chat settings changed
  (`{ settings }`).

None takes args: filter on `input.session_id`, or on
`input.parent_session_id` / `input.parent.session_id` to watch the children a
turn `spawn`s (in-turn spawns only — a direct `harness::spawn` call creates no
parent link, so filter those by `input.session_id`). Observe
`on-turn-completed` for outcomes and to chain the next hop; observe
`on-turn-started` only for observability. Delivery is at-most-once and
unordered — treat each event as an edge. Re-seed with `harness::status` and
`approval::list-pending` after a reconnect. Do not observe these for live
transcript rendering — that is `session-manager`'s job.

```typescript
// Worker code (iii-sdk), not an agent tool call.
iii.registerFunction('myapp::on-turn-done', handler)
iii.observe(
  {
    function_id: 'harness::on-turn-completed',
    filters: { 'input.session_id': { $eq: sessionId } },
    capture: ['output'],
  },
  'myapp::on-turn-done',
)
```

`engine::functions::info { function_id }` returns each event's shape as its
`response_format`.

## Agent observers

An in-run agent observes with `harness::observe`; the harness intercepts the
call, owns the binding for the calling session, and creates the observer:

```json
harness::observe {
  "function_id": "state::on-changed",
  "filters": { "input.scope": { "$eq": "run-x" }, "input.key": { "$eq": "report" } },
  "label": "report-ready",
  "lifecycle": { "expires_in_ms": 600000 }
}
```

Omit `target` to be woken in this session; name `target: { function_id,
payload?, event_into? }` to have a plain function called with the event
(never `harness::*`). `harness::on-timer { at | in_ms }` is the one-shot
deadline.

Agents cannot observe the turn events. `harness::observe` refuses
`harness::on-turn-completed`, `harness::on-turn-started` and every other
`harness::*` function with `harness/invalid_request: cannot observe harness
function ...: turn events are not agent-observable`. The two exceptions are
`harness::on-timer` and `harness::hook::on-post-turn` with a validator as the
target, scoped to the calling session or the children it names under the
`<session_id>-` prefix (see [Hooks](#hooks-policy-siblings-only)).

Watch what the work writes instead. To wait for a sub-agent, name a state key
in its brief, have it write its result there, and observe that key with a
deadline before you `harness::spawn` it, so a fast child cannot finish
unobserved and a failed one cannot park you forever:

```json
harness::observe {
  "function_id": "state::on-changed",
  "filters": { "input.scope": { "$eq": "run-x" }, "input.key": { "$eq": "child-a" } },
  "label": "child-a-done",
  "lifecycle": { "expires_in_ms": 600000 }
}
```

Set `lifecycle.expires_in_ms` on every wake except a timer, to how long the work
should take: `once` bounds deliveries, not time, so a one-shot wake without it
expires after 10 minutes (`harness::on-timer` and `cron::on-tick` fire by
themselves and get no default). When the deadline passes first, the session is
woken with an expiry notice instead of the write. The child may still be running:
to keep waiting, re-arm first, then read the key with `state::get`, because a
write made while nothing is armed never reaches the new observer. Retry, report,
or continue without the child only once you know it failed. A `state::barrier`
never sees those writes, so its deadline must outlast the whole fan-in. A wake whose
session was stopped mid-turn, or while parked with `quiet_deadlines`, retires at its
deadline with no notice. For a fan-out, arm one wake per
child key, each with a deadline, and read each result with `state::get` once
woken. A wake is once by default, a call observer is standing; bound standing
observers with `lifecycle` and remove them with `harness::unobserve { id }`.
Nothing throttles an observer, and a cycle routed through a state write
re-enters at depth 0 and every lap is a paid turn: design reactions acyclically.
See `architecture/reactive-observers.md` for the full payload.

## Hooks (policy siblings only)

The harness hosts six synchronous, in-path hook functions:
`harness::hook::on-pre-turn`, `harness::hook::on-pre-generate`,
`harness::hook::on-post-generate`, `harness::hook::on-pre-call`,
`harness::hook::on-post-call`, and `harness::hook::on-post-turn`. A sibling
observes one with args `{ functions?, sessions?, priority?, timeout_ms?,
on_error?, inject_prompt?, ... }`; at each point the harness calls the function
and its observers' targets run in `priority` order in the turn's critical path,
where the harness acts on their answers (veto / hold / mutate).
`on-pre-call` / `on-post-call` observers take a `functions` glob list to scope
which calls they gate. Each hook function's `request_format` and
`response_format` (`engine::functions::info`) are the input its observers'
targets receive; the harness gets back the chain's merged outcome. These are for operator-trusted policy siblings
(`approval-gate` observes `on-pre-call`); ordinary consumers do not observe
hooks. An agent may observe `on-post-turn` for its own session or for the
children it names under the `<session_id>-` prefix, with a validator as the
target.

## api reference

```json
{
  "functions": [
    {
      "description": "Ask the user for a decision between discrete options: 1-4 questions, 2-4 options each; the UI adds a free-text \"Other\" choice, so do not include one. The questions are shown as a clickable card in the chat and stay open while you do other work. The answer arrives as a user message (one `Header: answer` line per question; a skipped question reads `(skipped)`, and a dismissed card sends a notice instead of answers), so do not repeat the questions in text. Set `about.class` to `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. It defaults to `scope` for other questions. Not available to sub-agents or structured-output turns.",
      "metadata": {},
      "name": "harness::ask",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          }
        },
        "properties": {
          "about": {
            "allOf": [
              {
                "$ref": "#/definitions/AskAbout"
              }
            ],
            "description": "What this decision concerns and what it blocks."
          },
          "expires_in_min": {
            "description": "Minutes until the expiry action runs. Omitted asks wait forever.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "on_expiry": {
            "allOf": [
              {
                "$ref": "#/definitions/AskExpiry"
              }
            ],
            "description": "What to do at expiry. Defaults to leaving the question open and telling the agent that it must not decide for the user."
          },
          "questions": {
            "description": "1-4 questions shown together on one card; the answer arrives as the user's next message, one line per question.",
            "items": {
              "$ref": "#/definitions/AskQuestion"
            },
            "maxItems": 4,
            "minItems": 1,
            "type": "array"
          }
        },
        "required": [
          "questions"
        ],
        "title": "AskRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          },
          "AskStatus": {
            "oneOf": [
              {
                "description": "The card is shown; the answer arrives as the user's next message.",
                "enum": [
                  "awaiting_answer"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "What an accepted ask records as its result `details`: the card the UI draws and the ids it uses to tell an open question from an answered one.",
        "properties": {
          "about": {
            "$ref": "#/definitions/AskAbout"
          },
          "expires_in_min": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "on_expiry": {
            "$ref": "#/definitions/AskExpiry"
          },
          "question_id": {
            "description": "The function-call id of this ask.",
            "type": "string"
          },
          "questions": {
            "description": "The questions as shown, in request order.",
            "items": {
              "$ref": "#/definitions/AskQuestion"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/AskStatus"
          },
          "turn_id": {
            "description": "The turn that asked; the question remains open if the session moves on.",
            "type": "string"
          }
        },
        "required": [
          "question_id",
          "questions",
          "session_id",
          "status",
          "turn_id"
        ],
        "title": "AskResponse",
        "type": "object"
      }
    },
    {
      "description": "Answer a durable ask; only human console/operator calls may answer.",
      "metadata": {
        "internal": true
      },
      "name": "harness::ask::answer",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "additionalProperties": false,
            "properties": {
              "choice": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "choices": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "header": {
                "type": "string"
              },
              "other": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "skipped": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "header"
            ],
            "type": "object"
          },
          "AnswerBy": {
            "properties": {
              "channel": {
                "$ref": "#/definitions/Channel"
              },
              "user": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "channel"
            ],
            "type": "object"
          },
          "Channel": {
            "enum": [
              "chat",
              "control-plane",
              "kanban",
              "expiry"
            ],
            "type": "string"
          }
        },
        "properties": {
          "answers": {
            "items": {
              "$ref": "#/definitions/Answer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "by": {
            "$ref": "#/definitions/AnswerBy"
          },
          "dismissed": {
            "default": false,
            "type": "boolean"
          },
          "question_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "by",
          "question_id",
          "session_id"
        ],
        "title": "AnswerRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "additionalProperties": false,
            "properties": {
              "choice": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "choices": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "header": {
                "type": "string"
              },
              "other": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "skipped": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "header"
            ],
            "type": "object"
          },
          "AnswerBy": {
            "properties": {
              "channel": {
                "$ref": "#/definitions/Channel"
              },
              "user": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "channel"
            ],
            "type": "object"
          },
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          },
          "AskState": {
            "enum": [
              "open",
              "answering",
              "answered",
              "dismissed",
              "withdrawn",
              "expired"
            ],
            "type": "string"
          },
          "Channel": {
            "enum": [
              "chat",
              "control-plane",
              "kanban",
              "expiry"
            ],
            "type": "string"
          },
          "Outcome": {
            "enum": [
              "answered",
              "dismissed",
              "withdrawn",
              "expired_default",
              "not_delivered"
            ],
            "type": "string"
          }
        },
        "properties": {
          "about": {
            "$ref": "#/definitions/AskAbout"
          },
          "answer_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "answers": {
            "items": {
              "$ref": "#/definitions/Answer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "asked_at": {
            "format": "int64",
            "type": "integer"
          },
          "asked_by": {
            "description": "Asking agent profile id, when the session has a frozen profile.",
            "type": [
              "string",
              "null"
            ]
          },
          "by": {
            "anyOf": [
              {
                "$ref": "#/definitions/AnswerBy"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "expires_in_min": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "on_expiry": {
            "$ref": "#/definitions/AskExpiry"
          },
          "outcome": {
            "anyOf": [
              {
                "$ref": "#/definitions/Outcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "question_id": {
            "type": "string"
          },
          "questions": {
            "items": {
              "$ref": "#/definitions/AskQuestion"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          },
          "settled_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "state": {
            "$ref": "#/definitions/AskState"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "about",
          "asked_at",
          "on_expiry",
          "question_id",
          "questions",
          "session_id",
          "state",
          "turn_id"
        ],
        "title": "Entry",
        "type": "object"
      }
    },
    {
      "description": "List durable asks, including closed entries, with optional session and state filters.",
      "metadata": {},
      "name": "harness::ask::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AskState": {
            "enum": [
              "open",
              "answering",
              "answered",
              "dismissed",
              "withdrawn",
              "expired"
            ],
            "type": "string"
          }
        },
        "properties": {
          "cursor": {
            "description": "The last key returned by the previous page (exclusive).",
            "type": [
              "string",
              "null"
            ]
          },
          "limit": {
            "format": "uint",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "session_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "anyOf": [
              {
                "$ref": "#/definitions/AskState"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "title": "ListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "additionalProperties": false,
            "properties": {
              "choice": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "choices": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "header": {
                "type": "string"
              },
              "other": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "skipped": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "header"
            ],
            "type": "object"
          },
          "AnswerBy": {
            "properties": {
              "channel": {
                "$ref": "#/definitions/Channel"
              },
              "user": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "channel"
            ],
            "type": "object"
          },
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          },
          "AskState": {
            "enum": [
              "open",
              "answering",
              "answered",
              "dismissed",
              "withdrawn",
              "expired"
            ],
            "type": "string"
          },
          "Channel": {
            "enum": [
              "chat",
              "control-plane",
              "kanban",
              "expiry"
            ],
            "type": "string"
          },
          "Entry": {
            "properties": {
              "about": {
                "$ref": "#/definitions/AskAbout"
              },
              "answer_text": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "answers": {
                "items": {
                  "$ref": "#/definitions/Answer"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "asked_at": {
                "format": "int64",
                "type": "integer"
              },
              "asked_by": {
                "description": "Asking agent profile id, when the session has a frozen profile.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "by": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/AnswerBy"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "expires_at": {
                "format": "int64",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "expires_in_min": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "on_expiry": {
                "$ref": "#/definitions/AskExpiry"
              },
              "outcome": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Outcome"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "question_id": {
                "type": "string"
              },
              "questions": {
                "items": {
                  "$ref": "#/definitions/AskQuestion"
                },
                "type": "array"
              },
              "session_id": {
                "type": "string"
              },
              "settled_at": {
                "format": "int64",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "state": {
                "$ref": "#/definitions/AskState"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "about",
              "asked_at",
              "on_expiry",
              "question_id",
              "questions",
              "session_id",
              "state",
              "turn_id"
            ],
            "type": "object"
          },
          "Outcome": {
            "enum": [
              "answered",
              "dismissed",
              "withdrawn",
              "expired_default",
              "not_delivered"
            ],
            "type": "string"
          }
        },
        "properties": {
          "cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "entries": {
            "items": {
              "$ref": "#/definitions/Entry"
            },
            "type": "array"
          }
        },
        "required": [
          "entries"
        ],
        "title": "ListResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: record that a harness::ask card was answered through the card or dismissed, so every client shows it settled.",
      "metadata": {
        "internal": true
      },
      "name": "harness::ask::settle",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AskOutcome": {
            "oneOf": [
              {
                "description": "The card's answer (every question answered or skipped) was sent.",
                "enum": [
                  "answered"
                ],
                "type": "string"
              },
              {
                "description": "The card was dismissed: the agent was told it gets no answer.",
                "enum": [
                  "dismissed"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "outcome": {
            "$ref": "#/definitions/AskOutcome"
          },
          "question_id": {
            "description": "The ask's function-call id (`harness::ask` result `question_id`).",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "outcome",
          "question_id",
          "session_id"
        ],
        "title": "SettleRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AskOutcome": {
            "oneOf": [
              {
                "description": "The card's answer (every question answered or skipped) was sent.",
                "enum": [
                  "answered"
                ],
                "type": "string"
              },
              {
                "description": "The card was dismissed: the agent was told it gets no answer.",
                "enum": [
                  "dismissed"
                ],
                "type": "string"
              }
            ]
          },
          "AskSettlement": {
            "properties": {
              "outcome": {
                "$ref": "#/definitions/AskOutcome"
              },
              "question_id": {
                "description": "The function-call id of the ask (`AskResponse::question_id`).",
                "type": "string"
              },
              "settled_at": {
                "description": "Unix milliseconds.",
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "outcome",
              "question_id",
              "settled_at"
            ],
            "type": "object"
          }
        },
        "properties": {
          "settlements": {
            "description": "The session's settlements, oldest first (at most `ask_settlement::MAX_SETTLEMENTS`).",
            "items": {
              "$ref": "#/definitions/AskSettlement"
            },
            "type": "array"
          }
        },
        "required": [
          "settlements"
        ],
        "title": "SettlementsResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: list which harness::ask cards in a session were answered or dismissed (the console's ask card reads this).",
      "metadata": {
        "internal": true
      },
      "name": "harness::ask::settlements",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "SettlementsRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AskOutcome": {
            "oneOf": [
              {
                "description": "The card's answer (every question answered or skipped) was sent.",
                "enum": [
                  "answered"
                ],
                "type": "string"
              },
              {
                "description": "The card was dismissed: the agent was told it gets no answer.",
                "enum": [
                  "dismissed"
                ],
                "type": "string"
              }
            ]
          },
          "AskSettlement": {
            "properties": {
              "outcome": {
                "$ref": "#/definitions/AskOutcome"
              },
              "question_id": {
                "description": "The function-call id of the ask (`AskResponse::question_id`).",
                "type": "string"
              },
              "settled_at": {
                "description": "Unix milliseconds.",
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "outcome",
              "question_id",
              "settled_at"
            ],
            "type": "object"
          }
        },
        "properties": {
          "settlements": {
            "description": "The session's settlements, oldest first (at most `ask_settlement::MAX_SETTLEMENTS`).",
            "items": {
              "$ref": "#/definitions/AskSettlement"
            },
            "type": "array"
          }
        },
        "required": [
          "settlements"
        ],
        "title": "SettlementsResponse",
        "type": "object"
      }
    },
    {
      "description": "Withdraw a question that no longer needs an answer. Agent calls always target their own session.",
      "metadata": {},
      "name": "harness::ask::withdraw",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "question_id": {
            "type": "string"
          },
          "session_id": {
            "default": "",
            "description": "Stamped by the harness for an agent call; operators supply it explicitly.",
            "type": "string"
          }
        },
        "required": [
          "question_id"
        ],
        "title": "WithdrawRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "additionalProperties": false,
            "properties": {
              "choice": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "choices": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "header": {
                "type": "string"
              },
              "other": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "skipped": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "header"
            ],
            "type": "object"
          },
          "AnswerBy": {
            "properties": {
              "channel": {
                "$ref": "#/definitions/Channel"
              },
              "user": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "channel"
            ],
            "type": "object"
          },
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          },
          "AskState": {
            "enum": [
              "open",
              "answering",
              "answered",
              "dismissed",
              "withdrawn",
              "expired"
            ],
            "type": "string"
          },
          "Channel": {
            "enum": [
              "chat",
              "control-plane",
              "kanban",
              "expiry"
            ],
            "type": "string"
          },
          "Outcome": {
            "enum": [
              "answered",
              "dismissed",
              "withdrawn",
              "expired_default",
              "not_delivered"
            ],
            "type": "string"
          }
        },
        "properties": {
          "about": {
            "$ref": "#/definitions/AskAbout"
          },
          "answer_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "answers": {
            "items": {
              "$ref": "#/definitions/Answer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "asked_at": {
            "format": "int64",
            "type": "integer"
          },
          "asked_by": {
            "description": "Asking agent profile id, when the session has a frozen profile.",
            "type": [
              "string",
              "null"
            ]
          },
          "by": {
            "anyOf": [
              {
                "$ref": "#/definitions/AnswerBy"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "expires_in_min": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "on_expiry": {
            "$ref": "#/definitions/AskExpiry"
          },
          "outcome": {
            "anyOf": [
              {
                "$ref": "#/definitions/Outcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "question_id": {
            "type": "string"
          },
          "questions": {
            "items": {
              "$ref": "#/definitions/AskQuestion"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          },
          "settled_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "state": {
            "$ref": "#/definitions/AskState"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "about",
          "asked_at",
          "on_expiry",
          "question_id",
          "questions",
          "session_id",
          "state",
          "turn_id"
        ],
        "title": "Entry",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: the engine's last automatic compactions, newest first (chat-projects phase 3): { limit?: 20 } → [{ session_id, title, at_ms, trigger, threshold_tokens, context_before, context_after, rule }].",
      "metadata": {
        "internal": true
      },
      "name": "harness::autocompact::log",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "limit": {
            "default": null,
            "description": "How many, newest first (default 20, at most 50).",
            "format": "uint",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "title": "LogRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "LogEntry": {
            "description": "One automatic compaction, as `harness::autocompact::log` lists it.",
            "properties": {
              "at_ms": {
                "format": "int64",
                "type": "integer"
              },
              "context_after": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "context_before": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "rule": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Rule"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "session_id": {
                "type": "string"
              },
              "threshold_tokens": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "title": {
                "description": "The conversation's title when it compacted.",
                "type": "string"
              },
              "trigger": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Trigger"
                  }
                ],
                "description": "`auto` or `inline`."
              }
            },
            "required": [
              "at_ms",
              "session_id",
              "title",
              "trigger"
            ],
            "type": "object"
          },
          "Rule": {
            "description": "The rule that decided a conversation's setting.",
            "properties": {
              "project_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_name": {
                "description": "The project's name when the rule was read.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "$ref": "#/definitions/RuleScope"
              }
            },
            "required": [
              "scope"
            ],
            "type": "object"
          },
          "RuleScope": {
            "description": "Which level's setting applies.",
            "oneOf": [
              {
                "enum": [
                  "global",
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's own (a side chat's: its conversation's).",
                "enum": [
                  "session"
                ],
                "type": "string"
              }
            ]
          },
          "Trigger": {
            "description": "What started a compaction (chat-projects contract C).",
            "oneOf": [
              {
                "description": "`/compact` or `harness::compact`.",
                "enum": [
                  "command"
                ],
                "type": "string"
              },
              {
                "description": "The end of a turn past the autocompact threshold.",
                "enum": [
                  "auto"
                ],
                "type": "string"
              },
              {
                "description": "A turn's assembly, at the autocompact budget.",
                "enum": [
                  "inline"
                ],
                "type": "string"
              },
              {
                "description": "A turn's assembly, at the model's own limit (as before autocompact).",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          }
        },
        "items": {
          "$ref": "#/definitions/LogEntry"
        },
        "title": "Array_of_LogEntry",
        "type": "array"
      }
    },
    {
      "description": "Internal control-plane: the models that ran a turn on this engine in the last 7 days, for the autocompact settings (chat-projects phase 3): [{ provider, model, name, context_window, usable, last_used_ms }]. `usable` is the input budget context-manager measured for the model; names and windows come from the router catalog.",
      "metadata": {
        "internal": true
      },
      "name": "harness::autocompact::models",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "ModelsRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AutocompactModel": {
            "description": "One model `harness::autocompact::models` lists.",
            "properties": {
              "context_window": {
                "description": "The catalog's window; `null` when the router does not list it.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "last_used_ms": {
                "format": "int64",
                "type": "integer"
              },
              "model": {
                "type": "string"
              },
              "name": {
                "description": "The catalog's display name, else the model id.",
                "type": "string"
              },
              "provider": {
                "type": "string"
              },
              "usable": {
                "description": "The input budget context-manager measured on its last turn: where it compacts at its own limit.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "last_used_ms",
              "model",
              "name",
              "provider",
              "usable"
            ],
            "type": "object"
          }
        },
        "items": {
          "$ref": "#/definitions/AutocompactModel"
        },
        "title": "Array_of_AutocompactModel",
        "type": "array"
      }
    },
    {
      "description": "Internal control-plane: the Chat settings, { descriptions: { agent_writes }, autocompact: { mode: \"off\" | \"tokens\", tokens?, instructions? } }.",
      "metadata": {
        "internal": true
      },
      "name": "harness::chat-settings::get",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "ChatSettingsGetRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AutocompactConfig": {
            "additionalProperties": false,
            "description": "[`WorkerConfig::autocompact`]. `tokens` and `instructions` are kept while the mode is `off`, so turning it back on restores them.",
            "properties": {
              "instructions": {
                "description": "What the summary keeps, up to 1,000 characters: sent with every automatic compaction, as the text after `/compact` is.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AutocompactMode"
                  }
                ],
                "default": "off"
              },
              "tokens": {
                "description": "The threshold in tokens, 20,000 to 2,000,000.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AutocompactMode": {
            "description": "[`WorkerConfig::autocompact`]'s mode.",
            "oneOf": [
              {
                "description": "Compact only at the model's own limit, as before autocompact.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Compact at `tokens` (or the model's limit, when smaller).",
                "enum": [
                  "tokens"
                ],
                "type": "string"
              }
            ]
          },
          "DescriptionsSettings": {
            "properties": {
              "agent_writes": {
                "description": "Agents keep conversation descriptions up to date (`harness::set-description` is offered to the model).",
                "type": "boolean"
              }
            },
            "required": [
              "agent_writes"
            ],
            "type": "object"
          }
        },
        "properties": {
          "autocompact": {
            "allOf": [
              {
                "$ref": "#/definitions/AutocompactConfig"
              }
            ],
            "default": {
              "mode": "off"
            },
            "description": "The global autocompact setting (chat-projects phase 3): `off` (the default) or `tokens`; `tokens` and `instructions` stay while off."
          },
          "descriptions": {
            "$ref": "#/definitions/DescriptionsSettings"
          }
        },
        "required": [
          "descriptions"
        ],
        "title": "ChatSettings",
        "type": "object"
      }
    },
    {
      "description": "The Chat settings changed (from any device, or the harness configuration): { settings }.",
      "metadata": {},
      "name": "harness::chat-settings::on-changed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AutocompactConfig": {
            "additionalProperties": false,
            "description": "[`WorkerConfig::autocompact`]. `tokens` and `instructions` are kept while the mode is `off`, so turning it back on restores them.",
            "properties": {
              "instructions": {
                "description": "What the summary keeps, up to 1,000 characters: sent with every automatic compaction, as the text after `/compact` is.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AutocompactMode"
                  }
                ],
                "default": "off"
              },
              "tokens": {
                "description": "The threshold in tokens, 20,000 to 2,000,000.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AutocompactMode": {
            "description": "[`WorkerConfig::autocompact`]'s mode.",
            "oneOf": [
              {
                "description": "Compact only at the model's own limit, as before autocompact.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Compact at `tokens` (or the model's limit, when smaller).",
                "enum": [
                  "tokens"
                ],
                "type": "string"
              }
            ]
          },
          "ChatSettings": {
            "properties": {
              "autocompact": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AutocompactConfig"
                  }
                ],
                "default": {
                  "mode": "off"
                },
                "description": "The global autocompact setting (chat-projects phase 3): `off` (the default) or `tokens`; `tokens` and `instructions` stay while off."
              },
              "descriptions": {
                "$ref": "#/definitions/DescriptionsSettings"
              }
            },
            "required": [
              "descriptions"
            ],
            "type": "object"
          },
          "DescriptionsSettings": {
            "properties": {
              "agent_writes": {
                "description": "Agents keep conversation descriptions up to date (`harness::set-description` is offered to the model).",
                "type": "boolean"
              }
            },
            "required": [
              "agent_writes"
            ],
            "type": "object"
          }
        },
        "properties": {
          "settings": {
            "$ref": "#/definitions/ChatSettings"
          }
        },
        "required": [
          "settings"
        ],
        "title": "ChatSettingsChangedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AutocompactConfig": {
            "additionalProperties": false,
            "description": "[`WorkerConfig::autocompact`]. `tokens` and `instructions` are kept while the mode is `off`, so turning it back on restores them.",
            "properties": {
              "instructions": {
                "description": "What the summary keeps, up to 1,000 characters: sent with every automatic compaction, as the text after `/compact` is.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AutocompactMode"
                  }
                ],
                "default": "off"
              },
              "tokens": {
                "description": "The threshold in tokens, 20,000 to 2,000,000.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AutocompactMode": {
            "description": "[`WorkerConfig::autocompact`]'s mode.",
            "oneOf": [
              {
                "description": "Compact only at the model's own limit, as before autocompact.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Compact at `tokens` (or the model's limit, when smaller).",
                "enum": [
                  "tokens"
                ],
                "type": "string"
              }
            ]
          },
          "ChatSettings": {
            "properties": {
              "autocompact": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AutocompactConfig"
                  }
                ],
                "default": {
                  "mode": "off"
                },
                "description": "The global autocompact setting (chat-projects phase 3): `off` (the default) or `tokens`; `tokens` and `instructions` stay while off."
              },
              "descriptions": {
                "$ref": "#/definitions/DescriptionsSettings"
              }
            },
            "required": [
              "descriptions"
            ],
            "type": "object"
          },
          "DescriptionsSettings": {
            "properties": {
              "agent_writes": {
                "description": "Agents keep conversation descriptions up to date (`harness::set-description` is offered to the model).",
                "type": "boolean"
              }
            },
            "required": [
              "agent_writes"
            ],
            "type": "object"
          }
        },
        "properties": {
          "settings": {
            "$ref": "#/definitions/ChatSettings"
          }
        },
        "required": [
          "settings"
        ],
        "title": "ChatSettingsChangedEvent",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: change the Chat settings with a patch, { patch: { descriptions: { agent_writes }, autocompact: { mode, tokens, instructions } } }, merged into the harness configuration on the server (an autocompact field set to null is removed). Refused with `bad_setting` (an unknown mode, or `tokens` mode without tokens), `bad_tokens` (outside 20,000-2,000,000) or `bad_instructions` (over 1,000 characters). Answers { settings }.",
      "metadata": {
        "internal": true
      },
      "name": "harness::chat-settings::set",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "patch": {
            "additionalProperties": true,
            "description": "The settings to change; keys not named keep their value.",
            "type": "object"
          }
        },
        "required": [
          "patch"
        ],
        "title": "ChatSettingsSetRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AutocompactConfig": {
            "additionalProperties": false,
            "description": "[`WorkerConfig::autocompact`]. `tokens` and `instructions` are kept while the mode is `off`, so turning it back on restores them.",
            "properties": {
              "instructions": {
                "description": "What the summary keeps, up to 1,000 characters: sent with every automatic compaction, as the text after `/compact` is.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AutocompactMode"
                  }
                ],
                "default": "off"
              },
              "tokens": {
                "description": "The threshold in tokens, 20,000 to 2,000,000.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AutocompactMode": {
            "description": "[`WorkerConfig::autocompact`]'s mode.",
            "oneOf": [
              {
                "description": "Compact only at the model's own limit, as before autocompact.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Compact at `tokens` (or the model's limit, when smaller).",
                "enum": [
                  "tokens"
                ],
                "type": "string"
              }
            ]
          },
          "ChatSettings": {
            "properties": {
              "autocompact": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AutocompactConfig"
                  }
                ],
                "default": {
                  "mode": "off"
                },
                "description": "The global autocompact setting (chat-projects phase 3): `off` (the default) or `tokens`; `tokens` and `instructions` stay while off."
              },
              "descriptions": {
                "$ref": "#/definitions/DescriptionsSettings"
              }
            },
            "required": [
              "descriptions"
            ],
            "type": "object"
          },
          "DescriptionsSettings": {
            "properties": {
              "agent_writes": {
                "description": "Agents keep conversation descriptions up to date (`harness::set-description` is offered to the model).",
                "type": "boolean"
              }
            },
            "required": [
              "agent_writes"
            ],
            "type": "object"
          }
        },
        "properties": {
          "settings": {
            "$ref": "#/definitions/ChatSettings"
          }
        },
        "required": [
          "settings"
        ],
        "title": "ChatSettingsSetResponse",
        "type": "object"
      }
    },
    {
      "description": "Compact a session's conversation now and wait for the outcome: summarise its older history with the session's (or the named) model, keep the recent tail verbatim, and tell every client watching the session. `/compact` through harness::send starts the same compaction without waiting.",
      "metadata": {
        "internal": true
      },
      "name": "harness::compact",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "instructions": {
            "default": null,
            "description": "Guidance for the summariser: what to keep, drop, or emphasise. Steers this compaction only.",
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "default": null,
            "description": "The model that writes the summary; omitted, the session's last turn's.",
            "type": [
              "string",
              "null"
            ]
          },
          "provider": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "CompactRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CompactFailure": {
            "description": "Why the summariser failed (context-manager 1.3.0, D162).",
            "properties": {
              "error_details": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ErrorDetails"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "A usage limit's details (D147)."
              },
              "kind": {
                "description": "`usage_limit`, `rate_limited`, `input_too_large`, `timeout`, `unavailable` or `other`.",
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "kind",
              "message"
            ],
            "type": "object"
          },
          "ErrorDetails": {
            "description": "The details of a provider error that its kind does not carry (chat-projects contract C). The kind stays `rate_limited`: a usage limit is that kind with `usage_limit: true`, and neither the router nor the harness's transient resume retries it.",
            "properties": {
              "resets_at_ms": {
                "description": "When the window resets, in unix milliseconds.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "usage_limit": {
                "default": false,
                "description": "The account reached its plan's usage limit: retrying before the reset cannot succeed.",
                "type": "boolean"
              },
              "window": {
                "description": "The limit's window: `five_hour` or `week`.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "Rule": {
            "description": "The rule that decided a conversation's setting.",
            "properties": {
              "project_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_name": {
                "description": "The project's name when the rule was read.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "$ref": "#/definitions/RuleScope"
              }
            },
            "required": [
              "scope"
            ],
            "type": "object"
          },
          "RuleScope": {
            "description": "Which level's setting applies.",
            "oneOf": [
              {
                "enum": [
                  "global",
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's own (a side chat's: its conversation's).",
                "enum": [
                  "session"
                ],
                "type": "string"
              }
            ]
          },
          "Status": {
            "oneOf": [
              {
                "description": "Summarised; the `compaction` record anchors every later turn.",
                "enum": [
                  "ok"
                ],
                "type": "string"
              },
              {
                "description": "Another compaction of the session was running.",
                "enum": [
                  "busy"
                ],
                "type": "string"
              },
              {
                "description": "Nothing old enough to summarise.",
                "enum": [
                  "empty"
                ],
                "type": "string"
              },
              {
                "description": "The summariser failed or the result could not be saved.",
                "enum": [
                  "failed"
                ],
                "type": "string"
              },
              {
                "description": "A Stop abandoned an automatic compaction: no record was written.",
                "enum": [
                  "cancelled"
                ],
                "type": "string"
              }
            ]
          },
          "Trigger": {
            "description": "What started a compaction (chat-projects contract C).",
            "oneOf": [
              {
                "description": "`/compact` or `harness::compact`.",
                "enum": [
                  "command"
                ],
                "type": "string"
              },
              {
                "description": "The end of a turn past the autocompact threshold.",
                "enum": [
                  "auto"
                ],
                "type": "string"
              },
              {
                "description": "A turn's assembly, at the autocompact budget.",
                "enum": [
                  "inline"
                ],
                "type": "string"
              },
              {
                "description": "A turn's assembly, at the model's own limit (as before autocompact).",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "How a compaction ended — also what `harness::on-compaction` carries on completion.",
        "properties": {
          "compaction_id": {
            "type": "string"
          },
          "context_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "context_before": {
            "description": "The whole context's tokens before and after.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "entry_ids": {
            "description": "The transcript rows it wrote, in order: the start notice (absent when it never started) and the outcome row.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "failure": {
            "anyOf": [
              {
                "$ref": "#/definitions/CompactFailure"
              },
              {
                "type": "null"
              }
            ],
            "description": "Why the summariser failed, when context-manager said (1.3.0)."
          },
          "message": {
            "description": "The outcome as every client shows it.",
            "type": "string"
          },
          "rule": {
            "anyOf": [
              {
                "$ref": "#/definitions/Rule"
              },
              {
                "type": "null"
              }
            ],
            "description": "The rule that set the threshold."
          },
          "session_id": {
            "type": "string"
          },
          "source": {
            "description": "[`Trigger::source`], for readers older than `trigger`.",
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/Status"
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "threshold_tokens": {
            "description": "The threshold an automatic compaction crossed.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "tokens_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "tokens_before": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "trigger": {
            "allOf": [
              {
                "$ref": "#/definitions/Trigger"
              }
            ],
            "description": "What started it."
          }
        },
        "required": [
          "compaction_id",
          "entry_ids",
          "message",
          "session_id",
          "source",
          "status",
          "trigger"
        ],
        "title": "Outcome",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: what a conversation gathered, newest first — its subagents, pull requests (with their state when the github worker is present), links, attachments and images sent and received, and its side chats — for the context pane.",
      "metadata": {
        "internal": true
      },
      "name": "harness::context-items",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "ContextItemsRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AttachmentItem": {
            "properties": {
              "attachment_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "direction": {
                "description": "`sent` (in a user message) or `received` (in a function result or an assistant message, or a file the agent wrote).",
                "type": "string"
              },
              "entry_id": {
                "type": "string"
              },
              "mime": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "path": {
                "description": "For a file the agent wrote: its absolute path on the engine's computer.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "size": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "direction",
              "entry_id",
              "mime",
              "name"
            ],
            "type": "object"
          },
          "ImageItem": {
            "properties": {
              "attachment_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "block_index": {
                "description": "The `image` block's index in the entry's message content.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "direction": {
                "description": "`sent` or `received`, by the attachments' rule.",
                "type": "string"
              },
              "entry_id": {
                "type": "string"
              },
              "mime": {
                "type": "string"
              }
            },
            "required": [
              "block_index",
              "direction",
              "entry_id",
              "mime"
            ],
            "type": "object"
          },
          "LinkItem": {
            "properties": {
              "count": {
                "description": "Mentions in the conversation.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entry_id": {
                "description": "The newest entry naming it.",
                "type": "string"
              },
              "host": {
                "type": "string"
              },
              "title": {
                "description": "The text of a Markdown `[text](url)`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "url": {
                "type": "string"
              }
            },
            "required": [
              "count",
              "entry_id",
              "host",
              "url"
            ],
            "type": "object"
          },
          "PullRequestItem": {
            "properties": {
              "checks": {
                "description": "`passing`, `failing` or `pending`; absent without checks.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The newest entry naming it.",
                "type": "string"
              },
              "number": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "repo": {
                "description": "`owner/name`, lower case.",
                "type": "string"
              },
              "source": {
                "description": "`created` (a `github::pr::create` result) or `mentioned`.",
                "type": "string"
              },
              "state": {
                "description": "`open`, `draft`, `merged` or `closed`; absent without the github worker.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "title": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "url": {
                "type": "string"
              }
            },
            "required": [
              "entry_id",
              "number",
              "repo",
              "source",
              "url"
            ],
            "type": "object"
          },
          "SideChatItem": {
            "description": "One side chat of the conversation (chat-projects phase 2): the pane row \"<title> · 6 messages · 10m\", with a dot while a turn runs.",
            "properties": {
              "created_at_ms": {
                "format": "int64",
                "type": "integer"
              },
              "from_entry_id": {
                "description": "The conversation's entry it was forked at (`side_chat_fork_point`), for the mark under that message; absent for a side chat forked before phase 2.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "message_count": {
                "description": "Messages added in the side chat since the fork (user, assistant and function results; 0 while nothing was sent). A side chat forked before phase 2 records no fork point: all its messages count.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "running": {
                "description": "A turn is running in it (`status == \"running\"`).",
                "type": "boolean"
              },
              "session_id": {
                "type": "string"
              },
              "status": {
                "description": "`running`, `done` or `failed`, from its session status (as subagents).",
                "type": "string"
              },
              "title": {
                "description": "\"Side chat\" until its first message names it.",
                "type": "string"
              },
              "updated_at_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "created_at_ms",
              "message_count",
              "running",
              "session_id",
              "status",
              "title",
              "updated_at_ms"
            ],
            "type": "object"
          },
          "SubagentItem": {
            "properties": {
              "descendants": {
                "description": "Sessions below this one (its own subagents and theirs).",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "display": {
                "description": "The `subagent_display` label (for example \"Explore\").",
                "type": [
                  "string",
                  "null"
                ]
              },
              "ended_at_ms": {
                "format": "int64",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              },
              "started_at_ms": {
                "format": "int64",
                "type": "integer"
              },
              "status": {
                "description": "`running`, `done` or `failed`.",
                "type": "string"
              },
              "title": {
                "type": "string"
              }
            },
            "required": [
              "descendants",
              "session_id",
              "started_at_ms",
              "status",
              "title"
            ],
            "type": "object"
          },
          "Truncated": {
            "properties": {
              "attachments": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "images": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "links": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "attachments": {
            "items": {
              "$ref": "#/definitions/AttachmentItem"
            },
            "type": "array"
          },
          "generated_at_ms": {
            "format": "int64",
            "type": "integer"
          },
          "images": {
            "items": {
              "$ref": "#/definitions/ImageItem"
            },
            "type": "array"
          },
          "links": {
            "items": {
              "$ref": "#/definitions/LinkItem"
            },
            "type": "array"
          },
          "message_count": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "pull_requests": {
            "items": {
              "$ref": "#/definitions/PullRequestItem"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          },
          "side_chats": {
            "items": {
              "$ref": "#/definitions/SideChatItem"
            },
            "type": "array"
          },
          "subagents": {
            "items": {
              "$ref": "#/definitions/SubagentItem"
            },
            "type": "array"
          },
          "truncated": {
            "$ref": "#/definitions/Truncated"
          }
        },
        "required": [
          "attachments",
          "generated_at_ms",
          "images",
          "links",
          "message_count",
          "pull_requests",
          "session_id",
          "side_chats",
          "subagents",
          "truncated"
        ],
        "title": "ContextItemsResponse",
        "type": "object"
      }
    },
    {
      "description": "Return the Harness context-pruning policy for a destination model without making a model request.",
      "metadata": {
        "internal": true
      },
      "name": "harness::context-policy",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "model": {
            "type": "string"
          }
        },
        "required": [
          "model"
        ],
        "title": "ContextPolicyRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "allow_prune": {
            "description": "Whether aged function results may be pruned for this model.",
            "type": "boolean"
          }
        },
        "required": [
          "allow_prune"
        ],
        "title": "ContextPolicyResponse",
        "type": "object"
      }
    },
    {
      "description": "Durably cancel and delete only the selected session subtree; returns an operation snapshot.",
      "metadata": {
        "internal": true
      },
      "name": "harness::delete-session-tree",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "DeleteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "DeletionStatus": {
            "enum": [
              "deleting",
              "completed",
              "failed"
            ],
            "type": "string"
          }
        },
        "properties": {
          "attempt": {
            "description": "Initial attempt is 1; only an explicit failed-operation retry increments it.",
            "format": "uint32",
            "minimum": 1,
            "type": "integer"
          },
          "deleted_session_ids": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "operation_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/DeletionStatus"
          }
        },
        "required": [
          "attempt",
          "deleted_session_ids",
          "operation_id",
          "session_id",
          "status"
        ],
        "title": "Snapshot",
        "type": "object"
      }
    },
    {
      "description": "Internal queued subtree deletion continuation.",
      "metadata": {
        "internal": true
      },
      "name": "harness::delete-session-tree-run",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "operation_id": {
            "type": "string"
          }
        },
        "required": [
          "operation_id"
        ],
        "title": "StatusRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "$ref": "#/definitions/Snapshot"
          },
          {
            "type": "null"
          }
        ],
        "definitions": {
          "DeletionStatus": {
            "enum": [
              "deleting",
              "completed",
              "failed"
            ],
            "type": "string"
          },
          "Snapshot": {
            "additionalProperties": false,
            "properties": {
              "attempt": {
                "description": "Initial attempt is 1; only an explicit failed-operation retry increments it.",
                "format": "uint32",
                "minimum": 1,
                "type": "integer"
              },
              "deleted_session_ids": {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "error": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "operation_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "status": {
                "$ref": "#/definitions/DeletionStatus"
              }
            },
            "required": [
              "attempt",
              "deleted_session_ids",
              "operation_id",
              "session_id",
              "status"
            ],
            "type": "object"
          }
        },
        "title": "Nullable_Snapshot"
      }
    },
    {
      "description": "Read a durable session subtree deletion snapshot, or null if unknown.",
      "metadata": {
        "internal": true
      },
      "name": "harness::delete-session-tree-status",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "operation_id": {
            "type": "string"
          }
        },
        "required": [
          "operation_id"
        ],
        "title": "StatusRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "$ref": "#/definitions/Snapshot"
          },
          {
            "type": "null"
          }
        ],
        "definitions": {
          "DeletionStatus": {
            "enum": [
              "deleting",
              "completed",
              "failed"
            ],
            "type": "string"
          },
          "Snapshot": {
            "additionalProperties": false,
            "properties": {
              "attempt": {
                "description": "Initial attempt is 1; only an explicit failed-operation retry increments it.",
                "format": "uint32",
                "minimum": 1,
                "type": "integer"
              },
              "deleted_session_ids": {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "error": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "operation_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "status": {
                "$ref": "#/definitions/DeletionStatus"
              }
            },
            "required": [
              "attempt",
              "deleted_session_ids",
              "operation_id",
              "session_id",
              "status"
            ],
            "type": "object"
          }
        },
        "title": "Nullable_Snapshot"
      }
    },
    {
      "description": "Internal control-plane: edit a still-parked queued message in place by entry_id, preserving its queue position.",
      "metadata": {
        "internal": true
      },
      "name": "harness::edit_queued",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "entry_id": {
            "description": "The queued row to edit (its client-visible `entry_id`).",
            "type": "string"
          },
          "message": {
            "description": "The replacement user message text.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "entry_id",
          "message",
          "session_id"
        ],
        "title": "EditQueuedRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "updated": {
            "description": "False when no still-parked row matched — already drained or unknown.",
            "type": "boolean"
          }
        },
        "required": [
          "updated"
        ],
        "title": "EditQueuedResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: grant a session access to an additional filesystem root.",
      "metadata": {
        "internal": true
      },
      "name": "harness::filesystem::grant",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "root": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "root",
          "session_id"
        ],
        "title": "FilesystemGrantRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "roots": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "roots",
          "session_id"
        ],
        "title": "FilesystemGrantsResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: list additional filesystem roots granted to a session.",
      "metadata": {
        "internal": true
      },
      "name": "harness::filesystem::grants",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "FilesystemGrantsRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "roots": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "roots",
          "session_id"
        ],
        "title": "FilesystemGrantsResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: the default working-directory root new sessions are scoped to.",
      "metadata": {
        "internal": true
      },
      "name": "harness::filesystem::info",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "FilesystemInfoRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "FilesystemBoundary": {
            "enum": [
              "workspace",
              "configured_roots"
            ],
            "type": "string"
          }
        },
        "properties": {
          "boundary": {
            "allOf": [
              {
                "$ref": "#/definitions/FilesystemBoundary"
              }
            ],
            "description": "Effective per-session boundary for shell/coder calls: the configured `filesystem_boundary`, or under `auto`, `workspace` when the filesystem approval hook can widen it, otherwise `configured_roots`."
          },
          "default_root": {
            "description": "Working-directory root stamped onto the first turn of a session whose send carries no explicit `fs_scope.root`; `null` when defaulting is disabled (`default_filesystem_root: \"off\"`) or neither `III_COMPOSE_DIR` nor the cwd is available.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "boundary"
        ],
        "title": "FilesystemInfoResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: revoke a session's access to an additional filesystem root.",
      "metadata": {
        "internal": true
      },
      "name": "harness::filesystem::revoke",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "root": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "root",
          "session_id"
        ],
        "title": "FilesystemRevokeRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "roots": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "roots",
          "session_id"
        ],
        "title": "FilesystemGrantsResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: forget a saved folder.",
      "metadata": {
        "internal": true
      },
      "name": "harness::folders::delete",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "path": {
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "FolderDeleteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "deleted": {
            "type": "boolean"
          }
        },
        "required": [
          "deleted"
        ],
        "title": "FolderDeleteResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: list the saved folders (the IDE's recent folders, the Chat's folder selector, the console's folder pickers), most recently used first.",
      "metadata": {
        "internal": true
      },
      "name": "harness::folders::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "FoldersListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SavedFolder": {
            "description": "One saved folder.",
            "properties": {
              "last_used_at": {
                "format": "int64",
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            },
            "required": [
              "last_used_at",
              "name",
              "path"
            ],
            "type": "object"
          }
        },
        "properties": {
          "folders": {
            "items": {
              "$ref": "#/definitions/SavedFolder"
            },
            "type": "array"
          }
        },
        "required": [
          "folders"
        ],
        "title": "FoldersListResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: remember, touch, or rename a saved folder.",
      "metadata": {
        "internal": true
      },
      "name": "harness::folders::upsert",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "name": {
            "default": null,
            "description": "A custom display name. Omit to keep the current name (or use the folder name for a new folder); pass blank to reset to the folder name.",
            "type": [
              "string",
              "null"
            ]
          },
          "path": {
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "FolderUpsertRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SavedFolder": {
            "description": "One saved folder.",
            "properties": {
              "last_used_at": {
                "format": "int64",
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            },
            "required": [
              "last_used_at",
              "name",
              "path"
            ],
            "type": "object"
          }
        },
        "description": "`project` is the key the catalogue answered with before the rename; the shape stays the same (D25). `folder` carries the same record under its new name.",
        "properties": {
          "folder": {
            "$ref": "#/definitions/SavedFolder"
          },
          "project": {
            "$ref": "#/definitions/SavedFolder"
          }
        },
        "required": [
          "folder",
          "project"
        ],
        "title": "FolderUpsertResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: invoke one iii function (unwrapped from agent_call), enforce the dispatch policy, and capture the normalised result — or report it pending.",
      "metadata": {
        "internal": true
      },
      "name": "harness::function::call",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CallInput": {
            "properties": {
              "arguments": true,
              "function_id": {
                "description": "The iii function to invoke (already unwrapped from `agent_call`).",
                "type": "string"
              },
              "id": {
                "description": "function_call id, echoed into the result.",
                "type": "string"
              }
            },
            "required": [
              "arguments",
              "function_id",
              "id"
            ],
            "type": "object"
          }
        },
        "properties": {
          "call": {
            "$ref": "#/definitions/CallInput"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "call",
          "session_id"
        ],
        "title": "FunctionCallRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "$ref": "#/definitions/CallResultResponse"
          },
          {
            "$ref": "#/definitions/CallPendingResponse"
          }
        ],
        "definitions": {
          "CallPendingResponse": {
            "properties": {
              "function_call_id": {
                "type": "string"
              },
              "function_id": {
                "type": "string"
              },
              "pending": {
                "type": "boolean"
              },
              "pending_timeout_ms": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "function_call_id",
              "function_id",
              "pending"
            ],
            "type": "object"
          },
          "CallResultResponse": {
            "properties": {
              "content": {
                "items": {
                  "$ref": "#/definitions/ContentBlock"
                },
                "type": "array"
              },
              "details": true,
              "duration_ms": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "function_call_id": {
                "type": "string"
              },
              "function_id": {
                "type": "string"
              },
              "is_error": {
                "type": "boolean"
              }
            },
            "required": [
              "content",
              "details",
              "duration_ms",
              "function_call_id",
              "function_id",
              "is_error"
            ],
            "type": "object"
          },
          "ContentBlock": {
            "oneOf": [
              {
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "text"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "text",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "attachment_id": {
                    "description": "Optional link to the stored original of this inline image (`session::put-attachment`, resolvable with `session::get-attachment`). Lets readers ask `session::messages { include_image_data: false }` and fetch the bytes lazily instead of receiving them inline. Persisted verbatim on the transcript; model-bound consumers never see it (see [`ContentBlock::strip_files`]). Omitted on the wire when absent so legacy transcripts stay byte-identical.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "data": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "image"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "data",
                  "mime",
                  "type"
                ],
                "type": "object"
              },
              {
                "description": "Reference to an original upload in the session-manager attachment store (resolvable with `session::get-attachment`). A REFERENCE ONLY: the bytes are never inline. Persisted verbatim on user messages; every model-bound copy replaces it with an `<attachment>` text block naming the call that reads it (see [`ContentBlock::strip_files`]).",
                "properties": {
                  "attachment_id": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "size": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "type": {
                    "enum": [
                      "file"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "attachment_id",
                  "mime",
                  "name",
                  "size",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "signature": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "text": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "thinking"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "text",
                  "type"
                ],
                "type": "object"
              },
              {
                "description": "Opaque redacted thinking payload — replayed verbatim on the wire.",
                "properties": {
                  "data": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "redacted_thinking"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "data",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "arguments": true,
                  "function_id": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "function_call"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "arguments",
                  "function_id",
                  "id",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "content": {
                    "items": {
                      "$ref": "#/definitions/ContentBlock"
                    },
                    "type": "array"
                  },
                  "function_call_id": {
                    "type": "string"
                  },
                  "is_error": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "type": {
                    "enum": [
                      "function_result"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "content",
                  "function_call_id",
                  "type"
                ],
                "type": "object"
              }
            ]
          }
        },
        "title": "FunctionCallResponse"
      }
    },
    {
      "description": "Internal: settle a pending call's result (or release a held call) and resume the parked turn.",
      "metadata": {
        "internal": true
      },
      "name": "harness::function::resolve",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ContentBlock": {
            "oneOf": [
              {
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "text"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "text",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "attachment_id": {
                    "description": "Optional link to the stored original of this inline image (`session::put-attachment`, resolvable with `session::get-attachment`). Lets readers ask `session::messages { include_image_data: false }` and fetch the bytes lazily instead of receiving them inline. Persisted verbatim on the transcript; model-bound consumers never see it (see [`ContentBlock::strip_files`]). Omitted on the wire when absent so legacy transcripts stay byte-identical.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "data": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "image"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "data",
                  "mime",
                  "type"
                ],
                "type": "object"
              },
              {
                "description": "Reference to an original upload in the session-manager attachment store (resolvable with `session::get-attachment`). A REFERENCE ONLY: the bytes are never inline. Persisted verbatim on user messages; every model-bound copy replaces it with an `<attachment>` text block naming the call that reads it (see [`ContentBlock::strip_files`]).",
                "properties": {
                  "attachment_id": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "size": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "type": {
                    "enum": [
                      "file"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "attachment_id",
                  "mime",
                  "name",
                  "size",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "signature": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "text": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "thinking"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "text",
                  "type"
                ],
                "type": "object"
              },
              {
                "description": "Opaque redacted thinking payload — replayed verbatim on the wire.",
                "properties": {
                  "data": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "redacted_thinking"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "data",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "arguments": true,
                  "function_id": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "function_call"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "arguments",
                  "function_id",
                  "id",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "content": {
                    "items": {
                      "$ref": "#/definitions/ContentBlock"
                    },
                    "type": "array"
                  },
                  "function_call_id": {
                    "type": "string"
                  },
                  "is_error": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "type": {
                    "enum": [
                      "function_result"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "content",
                  "function_call_id",
                  "type"
                ],
                "type": "object"
              }
            ]
          },
          "ResolveFsScope": {
            "properties": {
              "grants": {
                "default": [],
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "action": {
            "description": "`deliver` (default) supplies the result; `execute` releases a hook-held call through the remaining call pipeline.",
            "type": [
              "string",
              "null"
            ]
          },
          "content": {
            "items": {
              "$ref": "#/definitions/ContentBlock"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "details": true,
          "fs_scope": {
            "anyOf": [
              {
                "$ref": "#/definitions/ResolveFsScope"
              },
              {
                "type": "null"
              }
            ],
            "description": "execute only: one-shot additional roots trusted by the caller and unioned with the session's durable filesystem grants."
          },
          "function_call_id": {
            "type": "string"
          },
          "is_error": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "function_call_id",
          "session_id",
          "turn_id"
        ],
        "title": "FunctionResolveRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "resolved": {
            "description": "False when the call is unknown, already done, or (execute) not held.",
            "type": "boolean"
          },
          "turn_resumed": {
            "description": "True when this resolve re-enqueued the turn.",
            "type": "boolean"
          }
        },
        "required": [
          "resolved",
          "turn_resumed"
        ],
        "title": "FunctionResolveResponse",
        "type": "object"
      }
    },
    {
      "description": "Synchronous hook: after the called function returns, before the result is appended. May rewrite content/details/is_error. Args `functions` globs select the called functions. Each matching observer's target is called with the hook input plus `call` and `result` { function_call_id, function_id, content, is_error, details }; the harness gets back the merged outcome { decision, held_by?, result?, annotations? }. A `shell::*`/`coder::*` target may answer mutations.fs_scope.root on a `shell::*`/`coder::*` call to move the session's working directory.",
      "metadata": {},
      "name": "harness::hook::on-post-call",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CallInput": {
            "description": "The function call a call hook runs around.",
            "properties": {
              "arguments": true,
              "description": {
                "description": "on-pre-call only: the `agent_call` wrapper's display-only `description` of this call, when the model gave one.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "function_id": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "implicit_namespace": {
                "description": "The namespace this id runs in when a call names none.",
                "type": "string"
              },
              "namespace": {
                "description": "The engine namespace the call runs in.",
                "type": "string"
              }
            },
            "required": [
              "arguments",
              "function_id",
              "id",
              "implicit_namespace",
              "namespace"
            ],
            "type": "object"
          },
          "CallResultInput": {
            "description": "What the called function returned.",
            "properties": {
              "content": {
                "items": true,
                "type": "array"
              },
              "details": true,
              "function_call_id": {
                "type": "string"
              },
              "function_id": {
                "type": "string"
              },
              "is_error": {
                "type": "boolean"
              }
            },
            "required": [
              "content",
              "details",
              "function_call_id",
              "function_id",
              "is_error"
            ],
            "type": "object"
          }
        },
        "description": "`harness::hook::on-post-call` input.",
        "properties": {
          "call": {
            "$ref": "#/definitions/CallInput"
          },
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "result": {
            "$ref": "#/definitions/CallResultInput"
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "call",
          "depth",
          "point",
          "result",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PostCallInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CallInput": {
            "description": "The function call a call hook runs around.",
            "properties": {
              "arguments": true,
              "description": {
                "description": "on-pre-call only: the `agent_call` wrapper's display-only `description` of this call, when the model gave one.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "function_id": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "implicit_namespace": {
                "description": "The namespace this id runs in when a call names none.",
                "type": "string"
              },
              "namespace": {
                "description": "The engine namespace the call runs in.",
                "type": "string"
              }
            },
            "required": [
              "arguments",
              "function_id",
              "id",
              "implicit_namespace",
              "namespace"
            ],
            "type": "object"
          },
          "CallResultInput": {
            "description": "What the called function returned.",
            "properties": {
              "content": {
                "items": true,
                "type": "array"
              },
              "details": true,
              "function_call_id": {
                "type": "string"
              },
              "function_id": {
                "type": "string"
              },
              "is_error": {
                "type": "boolean"
              }
            },
            "required": [
              "content",
              "details",
              "function_call_id",
              "function_id",
              "is_error"
            ],
            "type": "object"
          }
        },
        "description": "`harness::hook::on-post-call` input.",
        "properties": {
          "call": {
            "$ref": "#/definitions/CallInput"
          },
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "result": {
            "$ref": "#/definitions/CallResultInput"
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "call",
          "depth",
          "point",
          "result",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PostCallInput",
        "type": "object"
      }
    },
    {
      "description": "Synchronous hook: after the final assistant message update. Observe only: each matching observer's target is called with the hook input plus `generated` { message }; the harness gets back { decision: continue }.",
      "metadata": {},
      "name": "harness::hook::on-post-generate",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "GeneratedInput": {
            "description": "The generated assistant message.",
            "properties": {
              "message": true
            },
            "required": [
              "message"
            ],
            "type": "object"
          }
        },
        "description": "`harness::hook::on-post-generate` input.",
        "properties": {
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "generated": {
            "$ref": "#/definitions/GeneratedInput"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "generated",
          "point",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PostGenerateInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "GeneratedInput": {
            "description": "The generated assistant message.",
            "properties": {
              "message": true
            },
            "required": [
              "message"
            ],
            "type": "object"
          }
        },
        "description": "`harness::hook::on-post-generate` input.",
        "properties": {
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "generated": {
            "$ref": "#/definitions/GeneratedInput"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "generated",
          "point",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PostGenerateInput",
        "type": "object"
      }
    },
    {
      "description": "Synchronous hook: at finalize, after the output contract validated the result, before the turn completes. Deny re-prompts the turn (bounded by max_validation_retries). Args `sessions` globs scope it; args `payload`+`result_into` call a plain composition function (fp::pipe) as the validator. Each matching observer's target is called with the hook input plus the turn's `result` (or the template with the result injected); the harness gets back the merged outcome { decision, reason?, prompt? }.",
      "metadata": {},
      "name": "harness::hook::on-post-turn",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::hook::on-post-turn` input.",
        "properties": {
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "result": {
            "description": "The turn's result, validated by its output contract."
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "point",
          "result",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PostTurnInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::hook::on-post-turn` input.",
        "properties": {
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "result": {
            "description": "The turn's result, validated by its output contract."
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "point",
          "result",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PostTurnInput",
        "type": "object"
      }
    },
    {
      "description": "Synchronous hook: after the allow/deny policy passes, before the called function runs. May deny, hold, or rewrite arguments. Args `functions` globs select the called functions. Each matching observer's target is called with the hook input plus `call` { id, function_id, namespace, implicit_namespace, arguments }, the arguments as the previous target left them; the harness gets back the merged outcome { decision, reason?, held_by?, arguments?, annotations? }.",
      "metadata": {},
      "name": "harness::hook::on-pre-call",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CallInput": {
            "description": "The function call a call hook runs around.",
            "properties": {
              "arguments": true,
              "description": {
                "description": "on-pre-call only: the `agent_call` wrapper's display-only `description` of this call, when the model gave one.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "function_id": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "implicit_namespace": {
                "description": "The namespace this id runs in when a call names none.",
                "type": "string"
              },
              "namespace": {
                "description": "The engine namespace the call runs in.",
                "type": "string"
              }
            },
            "required": [
              "arguments",
              "function_id",
              "id",
              "implicit_namespace",
              "namespace"
            ],
            "type": "object"
          }
        },
        "description": "`harness::hook::on-pre-call` input.",
        "properties": {
          "call": {
            "$ref": "#/definitions/CallInput"
          },
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "resume_after": {
            "description": "Set when a released hold resumes the chain after this holder's target; removed before any target is called.",
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "call",
          "depth",
          "point",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PreCallInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CallInput": {
            "description": "The function call a call hook runs around.",
            "properties": {
              "arguments": true,
              "description": {
                "description": "on-pre-call only: the `agent_call` wrapper's display-only `description` of this call, when the model gave one.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "function_id": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "implicit_namespace": {
                "description": "The namespace this id runs in when a call names none.",
                "type": "string"
              },
              "namespace": {
                "description": "The engine namespace the call runs in.",
                "type": "string"
              }
            },
            "required": [
              "arguments",
              "function_id",
              "id",
              "implicit_namespace",
              "namespace"
            ],
            "type": "object"
          }
        },
        "description": "`harness::hook::on-pre-call` input.",
        "properties": {
          "call": {
            "$ref": "#/definitions/CallInput"
          },
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "resume_after": {
            "description": "Set when a released hold resumes the chain after this holder's target; removed before any target is called.",
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "call",
          "depth",
          "point",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PreCallInput",
        "type": "object"
      }
    },
    {
      "description": "Synchronous hook: after context assembly, before generation. May extend the system prompt, append messages, or veto. Each matching observer's target is called with the hook input plus `generate` { system_prompt, messages, model, provider, functions_generation, tools, expose } as the previous target left it, and on a sub-agent's turn `parent` / `parent_session_id` as harness::on-turn-completed reports them; the harness gets back the merged outcome { decision, reason?, system_prompt?, append_messages?, annotations? }. An observer whose contribution is static passes it as args.inject_prompt; it joins the prompt before assembly of the turns its `sessions` globs and filters select, and its target is not called. A target that reads a few fields lists them as args.input (dotted paths, `[]` maps a list) and gets those plus the envelope.",
      "metadata": {},
      "name": "harness::hook::on-pre-generate",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "GenerateInput": {
            "description": "What generation is about to send.",
            "properties": {
              "expose": {
                "description": "The session's function exposure mode."
              },
              "functions_generation": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "messages": {
                "items": true,
                "type": "array"
              },
              "model": {
                "type": "string"
              },
              "provider": {
                "type": "string"
              },
              "system_prompt": {
                "type": "string"
              },
              "tools": {
                "description": "The decision tools the model is offered.",
                "items": true,
                "type": "array"
              }
            },
            "required": [
              "expose",
              "functions_generation",
              "messages",
              "model",
              "provider",
              "system_prompt",
              "tools"
            ],
            "type": "object"
          },
          "ParentLink": {
            "description": "Sub-agent linkage recorded on a child turn (harness.md § Sub-agents).",
            "properties": {
              "function_call_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "function_call_id",
              "session_id",
              "turn_id"
            ],
            "type": "object"
          }
        },
        "description": "`harness::hook::on-pre-generate` input.",
        "properties": {
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "generate": {
            "$ref": "#/definitions/GenerateInput"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "parent": {
            "anyOf": [
              {
                "$ref": "#/definitions/ParentLink"
              },
              {
                "type": "null"
              }
            ],
            "description": "The spawning call, on a sub-agent's turn; as `harness::on-turn-completed` reports it."
          },
          "parent_session_id": {
            "description": "The session this turn's session is displayed under; as `harness::on-turn-completed` reports it.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "generate",
          "point",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PreGenerateInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "GenerateInput": {
            "description": "What generation is about to send.",
            "properties": {
              "expose": {
                "description": "The session's function exposure mode."
              },
              "functions_generation": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "messages": {
                "items": true,
                "type": "array"
              },
              "model": {
                "type": "string"
              },
              "provider": {
                "type": "string"
              },
              "system_prompt": {
                "type": "string"
              },
              "tools": {
                "description": "The decision tools the model is offered.",
                "items": true,
                "type": "array"
              }
            },
            "required": [
              "expose",
              "functions_generation",
              "messages",
              "model",
              "provider",
              "system_prompt",
              "tools"
            ],
            "type": "object"
          },
          "ParentLink": {
            "description": "Sub-agent linkage recorded on a child turn (harness.md § Sub-agents).",
            "properties": {
              "function_call_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "function_call_id",
              "session_id",
              "turn_id"
            ],
            "type": "object"
          }
        },
        "description": "`harness::hook::on-pre-generate` input.",
        "properties": {
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "generate": {
            "$ref": "#/definitions/GenerateInput"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "parent": {
            "anyOf": [
              {
                "$ref": "#/definitions/ParentLink"
              },
              {
                "type": "null"
              }
            ],
            "description": "The spawning call, on a sub-agent's turn; as `harness::on-turn-completed` reports it."
          },
          "parent_session_id": {
            "description": "The session this turn's session is displayed under; as `harness::on-turn-completed` reports it.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "generate",
          "point",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PreGenerateInput",
        "type": "object"
      }
    },
    {
      "description": "Synchronous hook: first step of a turn, before any model spend. May veto. Observe it with args { sessions?, priority?, timeout_ms?, on_error? }. Each matching observer's target is called with the hook input { point, session_id, turn_id, step, depth, own_namespace, metadata? } and answers { decision, reason?, mutations?, annotations? }; the harness gets back the merged outcome { decision, reason? }.",
      "metadata": {},
      "name": "harness::hook::on-pre-turn",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::hook::on-pre-turn` input.",
        "properties": {
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "point",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PreTurnInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::hook::on-pre-turn` input.",
        "properties": {
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "The turn's `options.metadata`."
          },
          "own_namespace": {
            "description": "The namespace the harness runs in; a call without a namespace goes there.",
            "type": [
              "string",
              "null"
            ]
          },
          "point": {
            "description": "The hook point: `pre_turn`, `pre_generate`, `post_generate`, `pre_call`, `post_call` or `post_turn`.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "point",
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "PreTurnInput",
        "type": "object"
      }
    },
    {
      "description": "Link the calling session tree's root to a kanban card without replacing other session metadata.",
      "metadata": {},
      "name": "harness::link-card",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "default": "",
            "description": "Stamped by the harness for an agent call; operators supply it explicitly.",
            "type": "string"
          },
          "ticket": {
            "type": "string"
          }
        },
        "required": [
          "ticket"
        ],
        "title": "LinkCardRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "type": "string"
          },
          "ticket": {
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "ticket"
        ],
        "title": "LinkCardResponse",
        "type": "object"
      }
    },
    {
      "description": "Aggregate durable model usage, function outcomes, and available trace/span observability for the session tree `root_session_id` belongs to (`session_id` is accepted as an alias, and a sub-agent id is resolved to its root). `complete` is true only after every session in the durable tree has reached a terminal turn. Pass `omit_context: true` when you only need the counters and cost: each session's context snapshot is then left out.",
      "metadata": {},
      "name": "harness::metrics",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "oneOf": [
          {
            "required": [
              "root_session_id"
            ]
          },
          {
            "required": [
              "session_id"
            ]
          }
        ],
        "properties": {
          "omit_context": {
            "description": "Leave each session's context snapshot out of `by_session` (and skip reading it). For callers that only need the counters and cost. Default false.",
            "type": "boolean"
          },
          "omit_traces": {
            "description": "Skip the trace/span aggregation (`traces` stays absent). It scans the engine's trace store and is the slowest part of a complete answer. Default false.",
            "type": "boolean"
          },
          "root_session_id": {
            "description": "Any session in the tree. `session_id` is accepted as an alias, and a child id is walked up to its root, so the id that addresses `harness::status` addresses the tree here too.",
            "type": "string"
          },
          "session_id": {
            "description": "Any session in the tree. `session_id` is accepted as an alias, and a child id is walked up to its root, so the id that addresses `harness::status` addresses the tree here too.",
            "type": "string"
          },
          "subtree": {
            "description": "Report the given session and its descendants only, instead of walking up to the root first: the response's root is the given session (depth 0), which keeps its own `parent_session_id`. Default false.",
            "type": "boolean"
          }
        },
        "title": "SessionMetricsRequestV1",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "ContextSnapshotV1": {
            "description": "One generation's context accounting. `free = usable - total`, floored at zero: once provider usage lands, `total` is what was billed, which can exceed the `usable` budget the window was fit into — that budget was derived before the generation from an estimate.",
            "properties": {
              "autocompact": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/SnapshotAutocompactV1"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The autocompact threshold the meters mark (chat-projects phase 3): the setting this step followed, where the end of a turn compacts and the inline budget context-manager applied. Absent from a harness that predates it."
              },
              "categories": {
                "$ref": "#/definitions/SnapshotCategoriesV1"
              },
              "compacted": {
                "description": "The context carries a conversation summary: compacted on this step, or anchored on an earlier compaction entry (a previous step, the console's `/compact`). The summary's tokens count in `system_prompt`.",
                "type": "boolean"
              },
              "effective_max_output_tokens": {
                "description": "Output allocation `usable` was derived against.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "estimator": {
                "description": "Which estimator produced the numbers (`heuristic` until the context-manager resolves a real tokenizer). Absent when the context-manager predates the breakdown response.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "free": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "model": {
                "type": "string"
              },
              "prefix_divergences": {
                "description": "Already-sent rows this session's requests rewrote, newest last (at most [`MAX_PREFIX_DIVERGENCES`]), carried from step to step.",
                "items": {
                  "$ref": "#/definitions/PrefixDivergenceV1"
                },
                "type": "array"
              },
              "prompt_sections_fallback": {
                "description": "Why no shared prefix went out: `disabled` (config), `no_stable_prefix` (empty identity prompt) or `prefix_rewritten` (a pre_generate hook replaced the prompt head; its prompt still wins, it just shares nothing).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "prompt_surface_digest": {
                "description": "Identity of the shared prompt prefix this generation went out with (`sha256:` of the stable section) — present only when the request carried `system_sections`. A local identity, never a provider hit; `usage.cache_read` is the reuse signal.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "provider": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_cost_usd": {
                "description": "Running cost of the whole session in USD, accumulated across every generation step. `usage.cost_usd` is one step's bill — on providers with steep cache discounts the per-step number swings two orders of magnitude, so a chip showing it alone reads as a bouncing total.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "summarized_head_tokens": {
                "description": "Size of the history that summary replaced.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "timestamp": {
                "format": "int64",
                "type": "integer"
              },
              "total": {
                "description": "Final request estimate: categories plus post-assembly growth.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": "string"
              },
              "usable": {
                "description": "The input budget the window was fit into.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Usage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Actual provider usage for this generation, stamped after the terminal frame; absent when the provider returned none (or the generation never completed)."
              }
            },
            "required": [
              "categories",
              "compacted",
              "effective_max_output_tokens",
              "free",
              "model",
              "session_id",
              "step",
              "timestamp",
              "total",
              "turn_id",
              "usable"
            ],
            "type": "object"
          },
          "ModelUsageV1": {
            "additionalProperties": false,
            "description": "What the steps one model generated used. A conversation can switch models mid-way, and providers differ in what they report (one may send tokens and no cost, another nothing), so the session's counters alone cannot say which model a gap belongs to.",
            "properties": {
              "cache_read_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cache_write_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cost_usd": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "function_calls": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "input_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "model": {
                "type": "string"
              },
              "output_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "provider": {
                "type": "string"
              },
              "reasoning_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "turns": {
                "description": "Model steps (assistant messages) this model generated.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "unreported_generations": {
                "description": "Generations stored with no usage at all: a stream cut before the provider reported, a request refused before a provider saw it, or one still streaming. The transcript does not say which, so none counts as zero: while this is non-zero every counter is a lower bound. Absent when zero.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "cache_read_tokens",
              "cache_write_tokens",
              "cost_usd",
              "function_calls",
              "input_tokens",
              "model",
              "output_tokens",
              "provider",
              "reasoning_tokens",
              "turns"
            ],
            "type": "object"
          },
          "PrefixDivergenceV1": {
            "description": "One generation that rewrote a row an earlier request of the session had already sent: a prefix-matching provider cache (DeepSeek) stops reusing at that row.",
            "properties": {
              "cache_read": {
                "description": "`usage.cache_read` of the rewriting request: what the provider still reused.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "call_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "cause": {
                "description": "What rewrote the row, as far as the harness can tell: `prune` (context-manager pruned or reduced function results to fit the budget that step) or `system_prompt` (row 0: a compaction summary or a prompt change).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "index": {
                "description": "First row (0 = system prompt, then one per message) that differs from the session's previous request. Absent when only the provider's wire mapping changed.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "prev_len": {
                "description": "Rows the previous request carried.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "provider_note": {
                "description": "The provider's own wire-level finding, cause included, when it reported one (a final-message warning starting with [`PROVIDER_PREFIX_NOTE`]).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "role": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "step",
              "turn_id"
            ],
            "type": "object"
          },
          "Rule": {
            "description": "The rule that decided a conversation's setting.",
            "properties": {
              "project_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_name": {
                "description": "The project's name when the rule was read.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "$ref": "#/definitions/RuleScope"
              }
            },
            "required": [
              "scope"
            ],
            "type": "object"
          },
          "RuleScope": {
            "description": "Which level's setting applies.",
            "oneOf": [
              {
                "enum": [
                  "global",
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's own (a side chat's: its conversation's).",
                "enum": [
                  "session"
                ],
                "type": "string"
              }
            ]
          },
          "SessionTraceMetricsV1": {
            "additionalProperties": false,
            "properties": {
              "by_session": {
                "items": {
                  "$ref": "#/definitions/SessionTraceUsageV1"
                },
                "type": "array"
              },
              "duration_ms": {
                "description": "Elapsed window from the first observed span to the last observed span.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error_span_count": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "span_count": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "trace_count": {
                "description": "Distinct traces across the root session and all descendants.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "by_session",
              "duration_ms",
              "error_span_count",
              "span_count",
              "trace_count"
            ],
            "type": "object"
          },
          "SessionTraceUsageV1": {
            "additionalProperties": false,
            "properties": {
              "depth": {
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "duration_ms": {
                "description": "Elapsed window from the session's first observed span to its last.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error_span_count": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "parent_session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              },
              "span_count": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "trace_count": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "depth",
              "duration_ms",
              "error_span_count",
              "session_id",
              "span_count",
              "trace_count"
            ],
            "type": "object"
          },
          "SessionUsageTotalsV1": {
            "additionalProperties": false,
            "properties": {
              "by_model": {
                "description": "The same counters per model that generated a step, ordered by provider then model. Absent when nothing generated, and from a harness that predates it.",
                "items": {
                  "$ref": "#/definitions/ModelUsageV1"
                },
                "type": "array"
              },
              "cache_read_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cache_write_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cost_usd": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "function_call_errors": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "function_calls": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "input_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "output_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "reasoning_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "sessions": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turns": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "unreported_generations": {
                "description": "Generations stored with no usage at all: a stream cut before the provider reported, a request refused before a provider saw it, or one still streaming. The transcript does not say which, so none counts as zero: while this is non-zero every counter is a lower bound. Absent when zero.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "cache_read_tokens",
              "cache_write_tokens",
              "cost_usd",
              "function_call_errors",
              "function_calls",
              "input_tokens",
              "output_tokens",
              "reasoning_tokens",
              "sessions",
              "turns"
            ],
            "type": "object"
          },
          "SessionUsageV1": {
            "additionalProperties": false,
            "properties": {
              "by_model": {
                "description": "The same counters per model that generated a step, ordered by provider then model. Absent when nothing generated, and from a harness that predates it.",
                "items": {
                  "$ref": "#/definitions/ModelUsageV1"
                },
                "type": "array"
              },
              "cache_read_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cache_write_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "context": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ContextSnapshotV1"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The session's latest per-generation context snapshot (categories, budget, usage) — absent for sessions that have not generated since snapshots landed."
              },
              "cost_usd": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "depth": {
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "function_call_errors": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "function_calls": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "input_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "output_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "parent_session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "reasoning_tokens": {
                "description": "Summed over the generations that reported usage. One of them may lack this counter and is left out; `null` means none reported it or more than one lacked it — never a measured zero, so the key is always present and a reader can tell the two apart. A generation with no usage at all is counted in `unreported_generations` instead and makes this a lower bound.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              },
              "turns": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "unreported_generations": {
                "description": "Generations stored with no usage at all: a stream cut before the provider reported, a request refused before a provider saw it, or one still streaming. The transcript does not say which, so none counts as zero: while this is non-zero every counter is a lower bound. Absent when zero.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "cache_read_tokens",
              "cache_write_tokens",
              "cost_usd",
              "depth",
              "function_call_errors",
              "function_calls",
              "input_tokens",
              "output_tokens",
              "reasoning_tokens",
              "session_id",
              "turns"
            ],
            "type": "object"
          },
          "SnapshotAutocompactV1": {
            "description": "`ContextSnapshotV1.autocompact`: the threshold the meters mark.",
            "properties": {
              "cap_tokens": {
                "description": "The budget inside a turn, `setting + max(10 %, 20k)`; `null` without a setting. context-manager compacts inline at `min(usable, cap)`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "effective_tokens": {
                "description": "Where the conversation compacts at the end of a turn: the setting when it is below `usable`; `null` when the model's own limit applies.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "rule": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Rule"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The level that decided; `null` when none was resolved."
              },
              "setting_tokens": {
                "description": "The resolved setting; `null` for off.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "SnapshotCategoriesV1": {
            "description": "Where the request's tokens sit. Categories are assembly-time estimates; `hook_guidance` is the measured growth after assembly (pre-generate hook appends and orphan-repair patches), 0 when the request left assembly unchanged.",
            "properties": {
              "hook_guidance": {
                "default": 0,
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "messages": {
                "$ref": "#/definitions/SnapshotMessagesV1"
              },
              "overhead": {
                "description": "Provider framing plus response_format / provider_options fields.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "skills": {
                "default": 0,
                "description": "Selected skill bodies contained in the system prompt.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "system_prompt": {
                "description": "Final assembled system prompt excluding tokens attributed to `skills`: identity, per-step aids, and any compaction summary section.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "tools": {
                "description": "Function schemas exposed to the model.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "messages",
              "overhead",
              "system_prompt",
              "tools"
            ],
            "type": "object"
          },
          "SnapshotMessagesV1": {
            "description": "Estimated tokens of the assembled window's messages, by role.",
            "properties": {
              "assistant": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "custom": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "function_result": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "user": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "assistant",
              "custom",
              "function_result",
              "user"
            ],
            "type": "object"
          },
          "Usage": {
            "properties": {
              "cache_read": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cache_write": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cost_usd": {
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "input": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "output": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "reasoning": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "by_session": {
            "items": {
              "$ref": "#/definitions/SessionUsageV1"
            },
            "type": "array"
          },
          "complete": {
            "type": "boolean"
          },
          "root_session_id": {
            "type": "string"
          },
          "totals": {
            "$ref": "#/definitions/SessionUsageTotalsV1"
          },
          "traces": {
            "anyOf": [
              {
                "$ref": "#/definitions/SessionTraceMetricsV1"
              },
              {
                "type": "null"
              }
            ],
            "description": "Trace/span aggregates when the engine's in-memory observability exporter is available. Usage metrics remain available when it is not."
          }
        },
        "required": [
          "by_session",
          "complete",
          "root_session_id",
          "totals"
        ],
        "title": "SessionMetricsResponseV1",
        "type": "object"
      }
    },
    {
      "description": "Each tmux Claude Code account's weekly usage split by project (chat-projects D28, D133): the Chat's tokens from the harness's ledger and the tokens tmux measured outside the Chat, both priced at the Anthropic API list price, share the account's weekly percentage. `[]` with no tmux worker.",
      "metadata": {
        "internal": true
      },
      "name": "harness::metrics::account-split",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "AccountSplitRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountSplit": {
            "description": "One account's week.",
            "properties": {
              "account": {
                "description": "The tmux account id.",
                "type": "string"
              },
              "outside_measured": {
                "description": "tmux measured the usage outside the Chat. When it could not, there is no `outside` segment and the Chat's segments split the week alone.",
                "type": "boolean"
              },
              "resets_at_ms": {
                "description": "When the week starts again, in unix milliseconds.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "segments": {
                "description": "They add up to `week_percent`; none when nothing was spent.",
                "items": {
                  "$ref": "#/definitions/SplitSegment"
                },
                "type": "array"
              },
              "week_percent": {
                "description": "How much of the week is used, 0 to 100 (tmux's reading).",
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "account",
              "outside_measured",
              "segments",
              "week_percent"
            ],
            "type": "object"
          },
          "SplitSegment": {
            "description": "A share of the week.",
            "oneOf": [
              {
                "properties": {
                  "color": {
                    "type": "string"
                  },
                  "kind": {
                    "enum": [
                      "project"
                    ],
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "percent": {
                    "format": "double",
                    "type": "number"
                  },
                  "project_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "color",
                  "kind",
                  "name",
                  "percent",
                  "project_id"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "kind": {
                    "enum": [
                      "no_project"
                    ],
                    "type": "string"
                  },
                  "percent": {
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "kind",
                  "percent"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "kind": {
                    "enum": [
                      "outside"
                    ],
                    "type": "string"
                  },
                  "percent": {
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "kind",
                  "percent"
                ],
                "type": "object"
              }
            ]
          }
        },
        "items": {
          "$ref": "#/definitions/AccountSplit"
        },
        "title": "Array_of_AccountSplit",
        "type": "array"
      }
    },
    {
      "description": "Observe a function for the current harness session: each time it runs, omit `target` to be notified in this session with what it returned, or name a non-harness `target.function_id` to call with it. Pass the function's `args` when it takes them and `filters` on its `input.<field>` to choose calls. Set `lifecycle.expires_in_ms` on every wake except a timer, to how long the work should take; a one-shot wake without it expires after 10 minutes with a notice. Returns `{ observer_id, once }`; a `note` is advice about the observer, which was created either way. Call-target results are discarded and do not return to this session.",
      "metadata": {},
      "name": "harness::observe",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "BindingTarget": {
            "additionalProperties": false,
            "description": "What a delivery dispatches. `function_id` is any iii function — `harness::send` for a wake, anything else for a mechanical reaction. Strict: an unknown key (sub-agent fields such as `task`) is refused when the agent observes, never silently dropped.",
            "properties": {
              "event_into": {
                "description": "JSON pointer where the event lands inside the payload (default `/event`).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "function_id": {
                "type": "string"
              },
              "payload": {
                "description": "Payload template; the delivered event is injected into it at `event_into`."
              }
            },
            "required": [
              "function_id"
            ],
            "type": "object"
          },
          "ConditionSpec": {
            "description": "One declared condition. Evaluated at fire time with the typed decision contract; ordinary iii functions, so a barrier or a claim is just a function someone wrote.",
            "properties": {
              "config": {
                "description": "Passed to the condition function AS its `condition_config`: give its fields (e.g. `id`, `expect`) directly, not wrapped in `condition_config`."
              },
              "function_id": {
                "type": "string"
              }
            },
            "required": [
              "function_id"
            ],
            "type": "object"
          },
          "LifecycleRequest": {
            "additionalProperties": false,
            "description": "The caller-settable half of a binding's lifecycle. Strict on purpose: an unknown key here (the retired `expires_at` above all) is a dropped deadline, so it must error naming the accepted fields, never pass.",
            "properties": {
              "expires_in_ms": {
                "description": "Relative deadline: the observer stops this many milliseconds after it was created (the only deadline form). Set it on every wake except a timer, to how long the work should take: if nothing fires by then, the session is woken with a notice. A one-shot wake without it expires after 10 minutes.",
                "format": "int64",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_fires": {
                "description": "Lifetime delivery budget; the observer is removed on its Nth delivery.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "once": {
                "description": "Remove the observer after its first delivery (same as top-level `once`).",
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "Agent-facing observe contract.",
        "properties": {
          "action": {
            "description": "User-facing text saying what happened, shown with each delivery.",
            "type": [
              "string",
              "null"
            ]
          },
          "args": {
            "additionalProperties": true,
            "default": null,
            "description": "Args for the worker that hosts the function, a JSON object; its description says which it takes: cron `{ \"expression\" }`, database `{ \"db\", \"table\"?, \"ops\"? }`, `harness::on-timer` `{ \"in_ms\" }` or `{ \"at\" }` (epoch ms). Omit for a function that takes none.",
            "type": [
              "object",
              "null"
            ]
          },
          "conditions": {
            "description": "Delivery-time gates, in order; each is an iii function answering `{ decision: \"allow\" | \"skip\", payload?, reason? }`.",
            "items": {
              "$ref": "#/definitions/ConditionSpec"
            },
            "type": "array"
          },
          "filters": {
            "additionalProperties": true,
            "default": null,
            "description": "Which calls reach this observer, a JSON object of explicit operators on the call's fields: `{ \"input.scope\": { \"$eq\": \"run\" } }`.",
            "type": [
              "object",
              "null"
            ]
          },
          "function_id": {
            "description": "The function to observe: `state::on-changed`, `cron::on-tick`, `harness::on-timer`, `database::on-row-changed`, or any other function. What it returns is the event.",
            "type": "string"
          },
          "label": {
            "description": "A short human label echoed back in the notification text.",
            "type": [
              "string",
              "null"
            ]
          },
          "lifecycle": {
            "anyOf": [
              {
                "$ref": "#/definitions/LifecycleRequest"
              },
              {
                "type": "null"
              }
            ],
            "description": "When the observer stops delivering; top-level `once` is the shorthand."
          },
          "namespace": {
            "description": "Where the function is hosted; omitted: this harness's namespace, then `default`, then Compose's.",
            "type": [
              "string",
              "null"
            ]
          },
          "once": {
            "description": "Remove the observer after its first delivery; defaults to true for a wake (no `target`) and `harness::on-timer`, false for a call target and `cron::on-tick`.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "target": {
            "anyOf": [
              {
                "$ref": "#/definitions/BindingTarget"
              },
              {
                "type": "null"
              }
            ],
            "description": "The function called with each event: `{ function_id, payload?, event_into? }` — the fixed payload and the JSON pointer where the event is injected into it (default `/event`). Omit it to be notified in this session instead. `harness::spawn` is never a valid target."
          }
        },
        "required": [
          "function_id"
        ],
        "title": "ObserveArgs",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "note": {
            "description": "Advisory only — the observer was CREATED. Says what applied by default or what looks suspicious in its wiring (e.g. a filter naming a key someone already wrote). Read it and act on it if it applies.",
            "type": [
              "string",
              "null"
            ]
          },
          "observer_id": {
            "type": "string"
          },
          "once": {
            "description": "The effective `once` flag applied (after the per-function default).",
            "type": "boolean"
          }
        },
        "required": [
          "observer_id",
          "once"
        ],
        "title": "ObserveResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal target of every observer an agent created with harness::observe: evaluates the binding's conditions, projects the observed call's output into the target's payload, and dispatches it (a wake into the owner session, or a plain function call). Receives the Observed envelope from iii's delivery, or the payload as sent from a call through the observer (a source's deliver hook); never called directly.",
      "metadata": {
        "internal": true
      },
      "name": "harness::observer::deliver",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "allOf": [
              {
                "$ref": "#/definitions/Observed_for_AnyValue_and_AnyValue"
              }
            ],
            "description": "iii's delivery: the `Observed` envelope of one call of the observed function."
          },
          {
            "description": "A call through the observer from the observed function's deliver hook: the payload as the source sent it."
          }
        ],
        "definitions": {
          "Caller": {
            "description": "Who made an invocation. `worker_id` / `worker_name` are stamped by the engine from the calling connection; `function_id`, `invocation_id` and `parent` are asserted by the calling SDK.",
            "properties": {
              "function_id": {
                "description": "The handler the call was made from; absent for a top-level call.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "invocation_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "parent": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ParentCaller"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The caller of that handler, one level only."
              },
              "worker_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "InvocationStatus": {
            "enum": [
              "success",
              "error"
            ],
            "type": "string"
          },
          "ObservedError": {
            "description": "What a call failed with: [`Observed::error`], [`Call::error`](crate::Call::error).",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "Observed_for_AnyValue_and_AnyValue": {
            "description": "What an observer's target receives when iii delivers: the observed call, per the observer's `capture`.\n\n```rust,no_run # use iii_sdk::{Error, IIIClient, Observed, RegisterFunction}; # use serde_json::Value; # fn demo(iii: &IIIClient) { iii.register_function( \"alerts::payment-failed\", RegisterFunction::new(|event: Observed<Value>| { println!(\"{} failed: {:?}\", event.function_id, event.error); Ok::<_, Error>(()) }), ); # } ```",
            "properties": {
              "activation_id": {
                "type": "string"
              },
              "caller": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Caller"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "duration_ms": {
                "format": "double",
                "type": "number"
              },
              "error": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ObservedError"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "function_id": {
                "type": "string"
              },
              "input": true,
              "invocation_id": {
                "type": "string"
              },
              "metadata": true,
              "namespace": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "observer_id": {
                "type": "string"
              },
              "output": true,
              "started_at_ms": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "status": {
                "$ref": "#/definitions/InvocationStatus"
              }
            },
            "required": [
              "activation_id",
              "duration_ms",
              "function_id",
              "invocation_id",
              "observer_id",
              "started_at_ms",
              "status"
            ],
            "type": "object"
          },
          "ParentCaller": {
            "description": "[`Caller::parent`]: a caller without a parent of its own.",
            "properties": {
              "function_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "invocation_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "The two shapes [`DeliverInput`] documents in its schema.",
        "title": "DeliverInput"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "delivered": {
            "description": "Whether the target was dispatched this fire.",
            "type": "boolean"
          },
          "gate": {
            "description": "Which gate or condition stopped it. Present iff `!delivered`.",
            "type": [
              "string",
              "null"
            ]
          },
          "note": {
            "description": "Why. Present iff `!delivered`.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "delivered"
        ],
        "title": "DeliverResult",
        "type": "object"
      }
    },
    {
      "description": "Remove one observer a session created, by observer id (the engine observer and the durable record); a still-armed wake notifies its parked owner. `session_id` must name the owner; in-turn calls may omit it.",
      "metadata": {},
      "name": "harness::observers::dispose",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "observer_id": {
            "description": "The observer to remove (`id` is accepted as an alias).",
            "type": "string"
          },
          "session_id": {
            "default": null,
            "description": "The observer's owner session; in-turn calls may omit it (the calling session is injected).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "observer_id"
        ],
        "title": "ObserversDisposeRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "removed": {
            "description": "False when no record existed (already removed) — honest, not an error.",
            "type": "boolean"
          }
        },
        "required": [
          "removed"
        ],
        "title": "ObserversDisposeResponse",
        "type": "object"
      }
    },
    {
      "description": "List the observers a session created with harness::observe: observer id, observed function with its args and filters, target (absent = notifies the owner), label, conditions, lifecycle, and fire count. In-turn calls may omit `session_id`.",
      "metadata": {},
      "name": "harness::observers::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "default": null,
            "description": "Owner session whose observers to list; in-turn calls may omit it (the calling session is injected).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "ObserversListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ConditionSpec": {
            "description": "One declared condition. Evaluated at fire time with the typed decision contract; ordinary iii functions, so a barrier or a claim is just a function someone wrote.",
            "properties": {
              "config": {
                "description": "Passed to the condition function AS its `condition_config`: give its fields (e.g. `id`, `expect`) directly, not wrapped in `condition_config`."
              },
              "function_id": {
                "type": "string"
              }
            },
            "required": [
              "function_id"
            ],
            "type": "object"
          },
          "ObserverRow": {
            "description": "One binding, as data. `function_id`, `args` and `filters` are what its observer observes.",
            "properties": {
              "action": {
                "description": "Human-readable event text declared as `action`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "args": true,
              "conditions": {
                "items": {
                  "$ref": "#/definitions/ConditionSpec"
                },
                "type": "array"
              },
              "created_at": {
                "format": "int64",
                "type": "integer"
              },
              "expires_at": {
                "format": "int64",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "filters": true,
              "fires": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "function_id": {
                "description": "The observed function.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "max_fires": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "namespace": {
                "description": "Where the observed function is hosted, when the observer names it.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "observer_id": {
                "type": "string"
              },
              "once": {
                "type": "boolean"
              },
              "target": {
                "description": "The function a delivery calls. Absent for a wake — the delivery notifies the owner session.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "created_at",
              "fires",
              "observer_id",
              "once"
            ],
            "type": "object"
          }
        },
        "properties": {
          "observers": {
            "items": {
              "$ref": "#/definitions/ObserverRow"
            },
            "type": "array"
          }
        },
        "required": [
          "observers"
        ],
        "title": "ObserversListResponse",
        "type": "object"
      }
    },
    {
      "description": "A durable ask was accepted or changed state. Carries the whole entry. For UIs and infrastructure only (filter on input.session_id): agents cannot observe it.",
      "metadata": {},
      "name": "harness::on-ask",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "additionalProperties": false,
            "properties": {
              "choice": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "choices": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "header": {
                "type": "string"
              },
              "other": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "skipped": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "header"
            ],
            "type": "object"
          },
          "AnswerBy": {
            "properties": {
              "channel": {
                "$ref": "#/definitions/Channel"
              },
              "user": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "channel"
            ],
            "type": "object"
          },
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          },
          "AskState": {
            "enum": [
              "open",
              "answering",
              "answered",
              "dismissed",
              "withdrawn",
              "expired"
            ],
            "type": "string"
          },
          "Channel": {
            "enum": [
              "chat",
              "control-plane",
              "kanban",
              "expiry"
            ],
            "type": "string"
          },
          "Outcome": {
            "enum": [
              "answered",
              "dismissed",
              "withdrawn",
              "expired_default",
              "not_delivered"
            ],
            "type": "string"
          }
        },
        "properties": {
          "about": {
            "$ref": "#/definitions/AskAbout"
          },
          "answer_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "answers": {
            "items": {
              "$ref": "#/definitions/Answer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "asked_at": {
            "format": "int64",
            "type": "integer"
          },
          "asked_by": {
            "description": "Asking agent profile id, when the session has a frozen profile.",
            "type": [
              "string",
              "null"
            ]
          },
          "by": {
            "anyOf": [
              {
                "$ref": "#/definitions/AnswerBy"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "expires_in_min": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "on_expiry": {
            "$ref": "#/definitions/AskExpiry"
          },
          "outcome": {
            "anyOf": [
              {
                "$ref": "#/definitions/Outcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "question_id": {
            "type": "string"
          },
          "questions": {
            "items": {
              "$ref": "#/definitions/AskQuestion"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          },
          "settled_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "state": {
            "$ref": "#/definitions/AskState"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "about",
          "asked_at",
          "on_expiry",
          "question_id",
          "questions",
          "session_id",
          "state",
          "turn_id"
        ],
        "title": "Entry",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "additionalProperties": false,
            "properties": {
              "choice": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "choices": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "header": {
                "type": "string"
              },
              "other": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "skipped": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "header"
            ],
            "type": "object"
          },
          "AnswerBy": {
            "properties": {
              "channel": {
                "$ref": "#/definitions/Channel"
              },
              "user": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "channel"
            ],
            "type": "object"
          },
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          },
          "AskState": {
            "enum": [
              "open",
              "answering",
              "answered",
              "dismissed",
              "withdrawn",
              "expired"
            ],
            "type": "string"
          },
          "Channel": {
            "enum": [
              "chat",
              "control-plane",
              "kanban",
              "expiry"
            ],
            "type": "string"
          },
          "Outcome": {
            "enum": [
              "answered",
              "dismissed",
              "withdrawn",
              "expired_default",
              "not_delivered"
            ],
            "type": "string"
          }
        },
        "properties": {
          "about": {
            "$ref": "#/definitions/AskAbout"
          },
          "answer_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "answers": {
            "items": {
              "$ref": "#/definitions/Answer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "asked_at": {
            "format": "int64",
            "type": "integer"
          },
          "asked_by": {
            "description": "Asking agent profile id, when the session has a frozen profile.",
            "type": [
              "string",
              "null"
            ]
          },
          "by": {
            "anyOf": [
              {
                "$ref": "#/definitions/AnswerBy"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "expires_in_min": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "on_expiry": {
            "$ref": "#/definitions/AskExpiry"
          },
          "outcome": {
            "anyOf": [
              {
                "$ref": "#/definitions/Outcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "question_id": {
            "type": "string"
          },
          "questions": {
            "items": {
              "$ref": "#/definitions/AskQuestion"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          },
          "settled_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "state": {
            "$ref": "#/definitions/AskState"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "about",
          "asked_at",
          "on_expiry",
          "question_id",
          "questions",
          "session_id",
          "state",
          "turn_id"
        ],
        "title": "Entry",
        "type": "object"
      }
    },
    {
      "description": "A durable ask was accepted or changed state. Carries the whole entry. For UIs and infrastructure only (filter on input.session_id): agents cannot observe it.",
      "metadata": {},
      "name": "harness::on-ask-settled",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "additionalProperties": false,
            "properties": {
              "choice": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "choices": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "header": {
                "type": "string"
              },
              "other": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "skipped": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "header"
            ],
            "type": "object"
          },
          "AnswerBy": {
            "properties": {
              "channel": {
                "$ref": "#/definitions/Channel"
              },
              "user": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "channel"
            ],
            "type": "object"
          },
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          },
          "AskState": {
            "enum": [
              "open",
              "answering",
              "answered",
              "dismissed",
              "withdrawn",
              "expired"
            ],
            "type": "string"
          },
          "Channel": {
            "enum": [
              "chat",
              "control-plane",
              "kanban",
              "expiry"
            ],
            "type": "string"
          },
          "Outcome": {
            "enum": [
              "answered",
              "dismissed",
              "withdrawn",
              "expired_default",
              "not_delivered"
            ],
            "type": "string"
          }
        },
        "properties": {
          "about": {
            "$ref": "#/definitions/AskAbout"
          },
          "answer_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "answers": {
            "items": {
              "$ref": "#/definitions/Answer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "asked_at": {
            "format": "int64",
            "type": "integer"
          },
          "asked_by": {
            "description": "Asking agent profile id, when the session has a frozen profile.",
            "type": [
              "string",
              "null"
            ]
          },
          "by": {
            "anyOf": [
              {
                "$ref": "#/definitions/AnswerBy"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "expires_in_min": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "on_expiry": {
            "$ref": "#/definitions/AskExpiry"
          },
          "outcome": {
            "anyOf": [
              {
                "$ref": "#/definitions/Outcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "question_id": {
            "type": "string"
          },
          "questions": {
            "items": {
              "$ref": "#/definitions/AskQuestion"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          },
          "settled_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "state": {
            "$ref": "#/definitions/AskState"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "about",
          "asked_at",
          "on_expiry",
          "question_id",
          "questions",
          "session_id",
          "state",
          "turn_id"
        ],
        "title": "Entry",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "additionalProperties": false,
            "properties": {
              "choice": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "choices": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "header": {
                "type": "string"
              },
              "other": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "skipped": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "required": [
              "header"
            ],
            "type": "object"
          },
          "AnswerBy": {
            "properties": {
              "channel": {
                "$ref": "#/definitions/Channel"
              },
              "user": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "channel"
            ],
            "type": "object"
          },
          "AskAbout": {
            "properties": {
              "blocks": {
                "description": "Cards whose work waits on this answer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "class": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AskClass"
                  }
                ],
                "default": "scope",
                "description": "Classify the decision as `security` for credentials or permissions, `publish` for a release or deployment, `external_cost` for paid spend, or `data` for data access, migration, or deletion. Defaults to `scope` for other questions."
              },
              "ticket": {
                "description": "The card this question concerns.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "why": {
                "description": "One paragraph explaining why the answer is needed.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "AskClass": {
            "enum": [
              "security",
              "publish",
              "external_cost",
              "data",
              "scope",
              "run_health",
              "routine"
            ],
            "type": "string"
          },
          "AskExpiry": {
            "anyOf": [
              {
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ],
                "type": "object"
              },
              {
                "$ref": "#/definitions/AskExpiryBlock"
              }
            ]
          },
          "AskExpiryBlock": {
            "enum": [
              "block"
            ],
            "type": "string"
          },
          "AskOption": {
            "properties": {
              "description": {
                "description": "Optional one-line explanation shown under the label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "description": "The choice as the user sees and sends it, 1-80 characters, unique within its question.",
                "maxLength": 80,
                "minLength": 1,
                "type": "string"
              },
              "recommended": {
                "description": "Marks the agent's preferred choice. At most one option per question.",
                "type": "boolean"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "AskQuestion": {
            "properties": {
              "header": {
                "description": "Short label such as `Approach`, shown above the question; prefixes the answer line (`Approach: <label>`). No length limit: the card shows a long one with an ellipsis and the whole text on hover.",
                "minLength": 1,
                "type": "string"
              },
              "multi_select": {
                "default": false,
                "description": "Let the user pick several options (checkboxes) instead of one.",
                "type": "boolean"
              },
              "options": {
                "description": "2-4 discrete choices; do not add an \"Other\" option, the UI adds a free-text one.",
                "items": {
                  "$ref": "#/definitions/AskOption"
                },
                "maxItems": 4,
                "minItems": 2,
                "type": "array"
              },
              "question": {
                "description": "The question, shown as a heading above the options. Lead with the question itself in one short sentence; any context after it is shown smaller and folds when long.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "header",
              "options",
              "question"
            ],
            "type": "object"
          },
          "AskState": {
            "enum": [
              "open",
              "answering",
              "answered",
              "dismissed",
              "withdrawn",
              "expired"
            ],
            "type": "string"
          },
          "Channel": {
            "enum": [
              "chat",
              "control-plane",
              "kanban",
              "expiry"
            ],
            "type": "string"
          },
          "Outcome": {
            "enum": [
              "answered",
              "dismissed",
              "withdrawn",
              "expired_default",
              "not_delivered"
            ],
            "type": "string"
          }
        },
        "properties": {
          "about": {
            "$ref": "#/definitions/AskAbout"
          },
          "answer_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "answers": {
            "items": {
              "$ref": "#/definitions/Answer"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "asked_at": {
            "format": "int64",
            "type": "integer"
          },
          "asked_by": {
            "description": "Asking agent profile id, when the session has a frozen profile.",
            "type": [
              "string",
              "null"
            ]
          },
          "by": {
            "anyOf": [
              {
                "$ref": "#/definitions/AnswerBy"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "expires_in_min": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "on_expiry": {
            "$ref": "#/definitions/AskExpiry"
          },
          "outcome": {
            "anyOf": [
              {
                "$ref": "#/definitions/Outcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "question_id": {
            "type": "string"
          },
          "questions": {
            "items": {
              "$ref": "#/definitions/AskQuestion"
            },
            "type": "array"
          },
          "session_id": {
            "type": "string"
          },
          "settled_at": {
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "state": {
            "$ref": "#/definitions/AskState"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "about",
          "asked_at",
          "on_expiry",
          "question_id",
          "questions",
          "session_id",
          "state",
          "turn_id"
        ],
        "title": "Entry",
        "type": "object"
      }
    },
    {
      "description": "A compaction of a session started (`phase: started`) or finished (`phase: completed`, with `status` ok/busy/empty/failed/cancelled and the user-facing `message`). `trigger` says what started it: command (/compact), auto (the end of a turn past the autocompact threshold), inline (a turn's assembly at the autocompact budget) or limit (at the model's limit); inline and limit emit only `completed`. For UIs and infrastructure only (filter on input.session_id or input.compaction_id): agents cannot observe it.",
      "metadata": {},
      "name": "harness::on-compaction",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CompactFailure": {
            "description": "Why the summariser failed (context-manager 1.3.0, D162).",
            "properties": {
              "error_details": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ErrorDetails"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "A usage limit's details (D147)."
              },
              "kind": {
                "description": "`usage_limit`, `rate_limited`, `input_too_large`, `timeout`, `unavailable` or `other`.",
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "kind",
              "message"
            ],
            "type": "object"
          },
          "ErrorDetails": {
            "description": "The details of a provider error that its kind does not carry (chat-projects contract C). The kind stays `rate_limited`: a usage limit is that kind with `usage_limit: true`, and neither the router nor the harness's transient resume retries it.",
            "properties": {
              "resets_at_ms": {
                "description": "When the window resets, in unix milliseconds.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "usage_limit": {
                "default": false,
                "description": "The account reached its plan's usage limit: retrying before the reset cannot succeed.",
                "type": "boolean"
              },
              "window": {
                "description": "The limit's window: `five_hour` or `week`.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "Rule": {
            "description": "The rule that decided a conversation's setting.",
            "properties": {
              "project_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_name": {
                "description": "The project's name when the rule was read.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "$ref": "#/definitions/RuleScope"
              }
            },
            "required": [
              "scope"
            ],
            "type": "object"
          },
          "RuleScope": {
            "description": "Which level's setting applies.",
            "oneOf": [
              {
                "enum": [
                  "global",
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's own (a side chat's: its conversation's).",
                "enum": [
                  "session"
                ],
                "type": "string"
              }
            ]
          },
          "Trigger": {
            "description": "What started a compaction (chat-projects contract C).",
            "oneOf": [
              {
                "description": "`/compact` or `harness::compact`.",
                "enum": [
                  "command"
                ],
                "type": "string"
              },
              {
                "description": "The end of a turn past the autocompact threshold.",
                "enum": [
                  "auto"
                ],
                "type": "string"
              },
              {
                "description": "A turn's assembly, at the autocompact budget.",
                "enum": [
                  "inline"
                ],
                "type": "string"
              },
              {
                "description": "A turn's assembly, at the model's own limit (as before autocompact).",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "`harness::on-compaction`: a compaction's progress (chat-projects contract C).",
        "properties": {
          "compaction_id": {
            "type": "string"
          },
          "context_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "context_before": {
            "description": "`completed` only: the whole context's tokens before and after.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "entry_ids": {
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "failure": {
            "anyOf": [
              {
                "$ref": "#/definitions/CompactFailure"
              },
              {
                "type": "null"
              }
            ],
            "description": "`completed` with `failed` only: why the summariser failed, as context-manager said (1.3.0)."
          },
          "message": {
            "description": "`completed` only: the user-facing message.",
            "type": [
              "string",
              "null"
            ]
          },
          "phase": {
            "description": "`started` or `completed`. A compaction inside a turn (`inline`, `limit`) emits only `completed`.",
            "type": "string"
          },
          "rule": {
            "anyOf": [
              {
                "$ref": "#/definitions/Rule"
              },
              {
                "type": "null"
              }
            ],
            "description": "`auto` and `inline`: the rule that set the threshold."
          },
          "session_id": {
            "type": "string"
          },
          "source": {
            "description": "`command`, `auto`, `auto_inline` or `limit`, for older readers.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "`completed` only: `ok`, `busy`, `empty`, `failed` or `cancelled` (a Stop abandoned an automatic compaction).",
            "type": [
              "string",
              "null"
            ]
          },
          "threshold_tokens": {
            "description": "`auto` and `inline`: the threshold crossed (`effective_tokens`).",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          },
          "tokens_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "tokens_before": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "trigger": {
            "anyOf": [
              {
                "$ref": "#/definitions/Trigger"
              },
              {
                "type": "null"
              }
            ],
            "description": "What started it: `command`, `auto`, `inline` or `limit`."
          }
        },
        "required": [
          "compaction_id",
          "phase",
          "session_id",
          "timestamp"
        ],
        "title": "CompactionEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CompactFailure": {
            "description": "Why the summariser failed (context-manager 1.3.0, D162).",
            "properties": {
              "error_details": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ErrorDetails"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "A usage limit's details (D147)."
              },
              "kind": {
                "description": "`usage_limit`, `rate_limited`, `input_too_large`, `timeout`, `unavailable` or `other`.",
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "kind",
              "message"
            ],
            "type": "object"
          },
          "ErrorDetails": {
            "description": "The details of a provider error that its kind does not carry (chat-projects contract C). The kind stays `rate_limited`: a usage limit is that kind with `usage_limit: true`, and neither the router nor the harness's transient resume retries it.",
            "properties": {
              "resets_at_ms": {
                "description": "When the window resets, in unix milliseconds.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "usage_limit": {
                "default": false,
                "description": "The account reached its plan's usage limit: retrying before the reset cannot succeed.",
                "type": "boolean"
              },
              "window": {
                "description": "The limit's window: `five_hour` or `week`.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "Rule": {
            "description": "The rule that decided a conversation's setting.",
            "properties": {
              "project_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_name": {
                "description": "The project's name when the rule was read.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "$ref": "#/definitions/RuleScope"
              }
            },
            "required": [
              "scope"
            ],
            "type": "object"
          },
          "RuleScope": {
            "description": "Which level's setting applies.",
            "oneOf": [
              {
                "enum": [
                  "global",
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's own (a side chat's: its conversation's).",
                "enum": [
                  "session"
                ],
                "type": "string"
              }
            ]
          },
          "Trigger": {
            "description": "What started a compaction (chat-projects contract C).",
            "oneOf": [
              {
                "description": "`/compact` or `harness::compact`.",
                "enum": [
                  "command"
                ],
                "type": "string"
              },
              {
                "description": "The end of a turn past the autocompact threshold.",
                "enum": [
                  "auto"
                ],
                "type": "string"
              },
              {
                "description": "A turn's assembly, at the autocompact budget.",
                "enum": [
                  "inline"
                ],
                "type": "string"
              },
              {
                "description": "A turn's assembly, at the model's own limit (as before autocompact).",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "`harness::on-compaction`: a compaction's progress (chat-projects contract C).",
        "properties": {
          "compaction_id": {
            "type": "string"
          },
          "context_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "context_before": {
            "description": "`completed` only: the whole context's tokens before and after.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "entry_ids": {
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "failure": {
            "anyOf": [
              {
                "$ref": "#/definitions/CompactFailure"
              },
              {
                "type": "null"
              }
            ],
            "description": "`completed` with `failed` only: why the summariser failed, as context-manager said (1.3.0)."
          },
          "message": {
            "description": "`completed` only: the user-facing message.",
            "type": [
              "string",
              "null"
            ]
          },
          "phase": {
            "description": "`started` or `completed`. A compaction inside a turn (`inline`, `limit`) emits only `completed`.",
            "type": "string"
          },
          "rule": {
            "anyOf": [
              {
                "$ref": "#/definitions/Rule"
              },
              {
                "type": "null"
              }
            ],
            "description": "`auto` and `inline`: the rule that set the threshold."
          },
          "session_id": {
            "type": "string"
          },
          "source": {
            "description": "`command`, `auto`, `auto_inline` or `limit`, for older readers.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "`completed` only: `ok`, `busy`, `empty`, `failed` or `cancelled` (a Stop abandoned an automatic compaction).",
            "type": [
              "string",
              "null"
            ]
          },
          "threshold_tokens": {
            "description": "`auto` and `inline`: the threshold crossed (`effective_tokens`).",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          },
          "tokens_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "tokens_before": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "trigger": {
            "anyOf": [
              {
                "$ref": "#/definitions/Trigger"
              },
              {
                "type": "null"
              }
            ],
            "description": "What started it: `command`, `auto`, `inline` or `limit`."
          }
        },
        "required": [
          "compaction_id",
          "phase",
          "session_id",
          "timestamp"
        ],
        "title": "CompactionEvent",
        "type": "object"
      }
    },
    {
      "description": "Internal: refresh the cached function-registry snapshot when functions are registered, re-registered or unregistered (an observer of engine::on-functions-changed).",
      "metadata": {
        "internal": true
      },
      "name": "harness::on-functions-change",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Internal `harness::on-functions-change` payload. The handler re-fetches the authoritative registry, so the (advisory) event tag is the only field.",
        "properties": {
          "event": {
            "default": null,
            "description": "Engine event tag (advisory; the handler re-fetches the full list).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "OnFunctionsChangeEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Ack returned by the internal `harness::on-functions-change` handler.",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "OnFunctionsChangeResponse",
        "type": "object"
      }
    },
    {
      "description": "A message parked in a session's server-side queue while its turn streams. For UIs and infrastructure only (filter on input.session_id): agents cannot observe it.",
      "metadata": {},
      "name": "harness::on-message-queued",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::on-message-queued`: a pointer to a message parked in the session's queue; consumers refetch `harness::status` → `queued`.",
        "properties": {
          "entry_id": {
            "type": "string"
          },
          "queued_at": {
            "format": "int64",
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "entry_id",
          "queued_at",
          "session_id",
          "timestamp"
        ],
        "title": "MessageQueuedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::on-message-queued`: a pointer to a message parked in the session's queue; consumers refetch `harness::status` → `queued`.",
        "properties": {
          "entry_id": {
            "type": "string"
          },
          "queued_at": {
            "format": "int64",
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "entry_id",
          "queued_at",
          "session_id",
          "timestamp"
        ],
        "title": "MessageQueuedEvent",
        "type": "object"
      }
    },
    {
      "description": "A session's observer set or fire count changed: refetch harness::observers::list. For UIs and infrastructure only (filter on input.session_id): agents cannot observe it.",
      "metadata": {},
      "name": "harness::on-observers-changed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::on-observers-changed`: a doorbell; consumers refetch `harness::observers::list`.",
        "properties": {
          "session_id": {
            "type": "string"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "session_id",
          "timestamp"
        ],
        "title": "ObserversChangedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::on-observers-changed`: a doorbell; consumers refetch `harness::observers::list`.",
        "properties": {
          "session_id": {
            "type": "string"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "session_id",
          "timestamp"
        ],
        "title": "ObserversChangedEvent",
        "type": "object"
      }
    },
    {
      "description": "The harness completed boot and can accept turns. An observer added later receives the current ready event once it is active, delivered like every call of this function (a call with metadata { for_observer: <observer id> }).",
      "metadata": {},
      "name": "harness::on-ready",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::on-ready`: the harness completed boot and accepts turns.",
        "properties": {
          "status": {
            "description": "Always `ready`.",
            "type": "string"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "status",
          "timestamp"
        ],
        "title": "ReadyEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::on-ready`: the harness completed boot and accepts turns.",
        "properties": {
          "status": {
            "description": "Always `ready`.",
            "type": "string"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "status",
          "timestamp"
        ],
        "title": "ReadyEvent",
        "type": "object"
      }
    },
    {
      "description": "Internal: drop a deleted session's observers. Not called directly.",
      "metadata": {
        "internal": true
      },
      "name": "harness::on-session-deleted",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Caller": {
            "description": "Who made an invocation. `worker_id` / `worker_name` are stamped by the engine from the calling connection; `function_id`, `invocation_id` and `parent` are asserted by the calling SDK.",
            "properties": {
              "function_id": {
                "description": "The handler the call was made from; absent for a top-level call.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "invocation_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "parent": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ParentCaller"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The caller of that handler, one level only."
              },
              "worker_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "InvocationStatus": {
            "enum": [
              "success",
              "error"
            ],
            "type": "string"
          },
          "ObservedError": {
            "description": "What a call failed with: [`Observed::error`], [`Call::error`](crate::Call::error).",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "ParentCaller": {
            "description": "[`Caller::parent`]: a caller without a parent of its own.",
            "properties": {
              "function_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "invocation_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "SessionDeletedEvent": {
            "description": "`session::on-deleted` event (only the field we read).",
            "properties": {
              "session_id": {
                "type": "string"
              }
            },
            "required": [
              "session_id"
            ],
            "type": "object"
          }
        },
        "description": "What an observer's target receives when iii delivers: the observed call, per the observer's `capture`.\n\n```rust,no_run # use iii_sdk::{Error, IIIClient, Observed, RegisterFunction}; # use serde_json::Value; # fn demo(iii: &IIIClient) { iii.register_function( \"alerts::payment-failed\", RegisterFunction::new(|event: Observed<Value>| { println!(\"{} failed: {:?}\", event.function_id, event.error); Ok::<_, Error>(()) }), ); # } ```",
        "properties": {
          "activation_id": {
            "type": "string"
          },
          "caller": {
            "anyOf": [
              {
                "$ref": "#/definitions/Caller"
              },
              {
                "type": "null"
              }
            ]
          },
          "duration_ms": {
            "format": "double",
            "type": "number"
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/definitions/ObservedError"
              },
              {
                "type": "null"
              }
            ]
          },
          "function_id": {
            "type": "string"
          },
          "input": true,
          "invocation_id": {
            "type": "string"
          },
          "metadata": true,
          "namespace": {
            "type": [
              "string",
              "null"
            ]
          },
          "observer_id": {
            "type": "string"
          },
          "output": {
            "anyOf": [
              {
                "$ref": "#/definitions/SessionDeletedEvent"
              },
              {
                "type": "null"
              }
            ]
          },
          "started_at_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "status": {
            "$ref": "#/definitions/InvocationStatus"
          }
        },
        "required": [
          "activation_id",
          "duration_ms",
          "function_id",
          "invocation_id",
          "observer_id",
          "started_at_ms",
          "status"
        ],
        "title": "Observed_for_AnyValue_and_SessionDeletedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "removed": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "ok",
          "removed"
        ],
        "title": "SessionDeletedAck",
        "type": "object"
      }
    },
    {
      "description": "A subtree deletion changed status. Observe it before requesting deletion, with filters on input.session_id or input.operation_id, and recover once by operation_id.",
      "metadata": {},
      "name": "harness::on-session-tree-deletion",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "DeletionStatus": {
            "enum": [
              "deleting",
              "completed",
              "failed"
            ],
            "type": "string"
          }
        },
        "properties": {
          "attempt": {
            "description": "Initial attempt is 1; only an explicit failed-operation retry increments it.",
            "format": "uint32",
            "minimum": 1,
            "type": "integer"
          },
          "deleted_session_ids": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "operation_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/DeletionStatus"
          }
        },
        "required": [
          "attempt",
          "deleted_session_ids",
          "operation_id",
          "session_id",
          "status"
        ],
        "title": "Snapshot",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "DeletionStatus": {
            "enum": [
              "deleting",
              "completed",
              "failed"
            ],
            "type": "string"
          }
        },
        "properties": {
          "attempt": {
            "description": "Initial attempt is 1; only an explicit failed-operation retry increments it.",
            "format": "uint32",
            "minimum": 1,
            "type": "integer"
          },
          "deleted_session_ids": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "operation_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/DeletionStatus"
          }
        },
        "required": [
          "attempt",
          "deleted_session_ids",
          "operation_id",
          "session_id",
          "status"
        ],
        "title": "Snapshot",
        "type": "object"
      }
    },
    {
      "description": "Internal: refresh the cached model-invocable skill catalog.",
      "metadata": {
        "internal": true
      },
      "name": "harness::on-skills-change",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "op": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "OnSkillsChangeEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "OnSkillsChangeResponse",
        "type": "object"
      }
    },
    {
      "description": "One-shot deadline: called once at `at` (epoch ms) with { scheduled_at, actual_at }. Observe it with args { at }; an observer receives the call for its own `at` only. An `at` more than 7 days out is refused (CONFIG_ERROR); an `at` already past is called once as soon as its observers are active. The natural second leg of any armed wake or fan-in gate: 'wake me when X happens, or tell me at T that it did not'. For recurrence observe cron::on-tick.",
      "metadata": {},
      "name": "harness::on-timer",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "What the function is called with, and what its observers observe.",
        "properties": {
          "actual_at": {
            "description": "When the call was made.",
            "format": "int64",
            "type": "integer"
          },
          "scheduled_at": {
            "description": "The observers' `at`.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "actual_at",
          "scheduled_at"
        ],
        "title": "TimerEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "What the function is called with, and what its observers observe.",
        "properties": {
          "actual_at": {
            "description": "When the call was made.",
            "format": "int64",
            "type": "integer"
          },
          "scheduled_at": {
            "description": "The observers' `at`.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "actual_at",
          "scheduled_at"
        ],
        "title": "TimerEvent",
        "type": "object"
      }
    },
    {
      "description": "A harness turn reached a terminal status (completed/cancelled/failed). For UIs and infrastructure only: agents cannot observe it. To wait on a sub-agent, observe `state::on-changed` on the key its task writes.",
      "metadata": {},
      "name": "harness::on-turn-completed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountRef": {
            "description": "`account {id, source}`: what the verbose `harness::status` and the turn events show.",
            "properties": {
              "id": {
                "description": "The tmux account id.",
                "type": "string"
              },
              "source": {
                "$ref": "#/definitions/AccountSource"
              }
            },
            "required": [
              "id",
              "source"
            ],
            "type": "object"
          },
          "AccountSource": {
            "description": "Why a turn runs on its account (contract D).",
            "oneOf": [
              {
                "description": "The conversation names it (`metadata.claude_account`).",
                "enum": [
                  "session"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's project is pinned to it.",
                "enum": [
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "It is the global account (nothing pins the conversation, or it names `\"global\"`).",
                "enum": [
                  "global"
                ],
                "type": "string"
              }
            ]
          },
          "ContextSnapshotV1": {
            "description": "One generation's context accounting. `free = usable - total`, floored at zero: once provider usage lands, `total` is what was billed, which can exceed the `usable` budget the window was fit into — that budget was derived before the generation from an estimate.",
            "properties": {
              "autocompact": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/SnapshotAutocompactV1"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The autocompact threshold the meters mark (chat-projects phase 3): the setting this step followed, where the end of a turn compacts and the inline budget context-manager applied. Absent from a harness that predates it."
              },
              "categories": {
                "$ref": "#/definitions/SnapshotCategoriesV1"
              },
              "compacted": {
                "description": "The context carries a conversation summary: compacted on this step, or anchored on an earlier compaction entry (a previous step, the console's `/compact`). The summary's tokens count in `system_prompt`.",
                "type": "boolean"
              },
              "effective_max_output_tokens": {
                "description": "Output allocation `usable` was derived against.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "estimator": {
                "description": "Which estimator produced the numbers (`heuristic` until the context-manager resolves a real tokenizer). Absent when the context-manager predates the breakdown response.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "free": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "model": {
                "type": "string"
              },
              "prefix_divergences": {
                "description": "Already-sent rows this session's requests rewrote, newest last (at most [`MAX_PREFIX_DIVERGENCES`]), carried from step to step.",
                "items": {
                  "$ref": "#/definitions/PrefixDivergenceV1"
                },
                "type": "array"
              },
              "prompt_sections_fallback": {
                "description": "Why no shared prefix went out: `disabled` (config), `no_stable_prefix` (empty identity prompt) or `prefix_rewritten` (a pre_generate hook replaced the prompt head; its prompt still wins, it just shares nothing).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "prompt_surface_digest": {
                "description": "Identity of the shared prompt prefix this generation went out with (`sha256:` of the stable section) — present only when the request carried `system_sections`. A local identity, never a provider hit; `usage.cache_read` is the reuse signal.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "provider": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_cost_usd": {
                "description": "Running cost of the whole session in USD, accumulated across every generation step. `usage.cost_usd` is one step's bill — on providers with steep cache discounts the per-step number swings two orders of magnitude, so a chip showing it alone reads as a bouncing total.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "summarized_head_tokens": {
                "description": "Size of the history that summary replaced.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "timestamp": {
                "format": "int64",
                "type": "integer"
              },
              "total": {
                "description": "Final request estimate: categories plus post-assembly growth.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": "string"
              },
              "usable": {
                "description": "The input budget the window was fit into.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Usage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Actual provider usage for this generation, stamped after the terminal frame; absent when the provider returned none (or the generation never completed)."
              }
            },
            "required": [
              "categories",
              "compacted",
              "effective_max_output_tokens",
              "free",
              "model",
              "session_id",
              "step",
              "timestamp",
              "total",
              "turn_id",
              "usable"
            ],
            "type": "object"
          },
          "ParentLink": {
            "description": "Sub-agent linkage recorded on a child turn (harness.md § Sub-agents).",
            "properties": {
              "function_call_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "function_call_id",
              "session_id",
              "turn_id"
            ],
            "type": "object"
          },
          "PrefixDivergenceV1": {
            "description": "One generation that rewrote a row an earlier request of the session had already sent: a prefix-matching provider cache (DeepSeek) stops reusing at that row.",
            "properties": {
              "cache_read": {
                "description": "`usage.cache_read` of the rewriting request: what the provider still reused.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "call_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "cause": {
                "description": "What rewrote the row, as far as the harness can tell: `prune` (context-manager pruned or reduced function results to fit the budget that step) or `system_prompt` (row 0: a compaction summary or a prompt change).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "index": {
                "description": "First row (0 = system prompt, then one per message) that differs from the session's previous request. Absent when only the provider's wire mapping changed.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "prev_len": {
                "description": "Rows the previous request carried.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "provider_note": {
                "description": "The provider's own wire-level finding, cause included, when it reported one (a final-message warning starting with [`PROVIDER_PREFIX_NOTE`]).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "role": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "step",
              "turn_id"
            ],
            "type": "object"
          },
          "Rule": {
            "description": "The rule that decided a conversation's setting.",
            "properties": {
              "project_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_name": {
                "description": "The project's name when the rule was read.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "$ref": "#/definitions/RuleScope"
              }
            },
            "required": [
              "scope"
            ],
            "type": "object"
          },
          "RuleScope": {
            "description": "Which level's setting applies.",
            "oneOf": [
              {
                "enum": [
                  "global",
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's own (a side chat's: its conversation's).",
                "enum": [
                  "session"
                ],
                "type": "string"
              }
            ]
          },
          "SnapshotAutocompactV1": {
            "description": "`ContextSnapshotV1.autocompact`: the threshold the meters mark.",
            "properties": {
              "cap_tokens": {
                "description": "The budget inside a turn, `setting + max(10 %, 20k)`; `null` without a setting. context-manager compacts inline at `min(usable, cap)`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "effective_tokens": {
                "description": "Where the conversation compacts at the end of a turn: the setting when it is below `usable`; `null` when the model's own limit applies.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "rule": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Rule"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The level that decided; `null` when none was resolved."
              },
              "setting_tokens": {
                "description": "The resolved setting; `null` for off.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "SnapshotCategoriesV1": {
            "description": "Where the request's tokens sit. Categories are assembly-time estimates; `hook_guidance` is the measured growth after assembly (pre-generate hook appends and orphan-repair patches), 0 when the request left assembly unchanged.",
            "properties": {
              "hook_guidance": {
                "default": 0,
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "messages": {
                "$ref": "#/definitions/SnapshotMessagesV1"
              },
              "overhead": {
                "description": "Provider framing plus response_format / provider_options fields.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "skills": {
                "default": 0,
                "description": "Selected skill bodies contained in the system prompt.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "system_prompt": {
                "description": "Final assembled system prompt excluding tokens attributed to `skills`: identity, per-step aids, and any compaction summary section.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "tools": {
                "description": "Function schemas exposed to the model.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "messages",
              "overhead",
              "system_prompt",
              "tools"
            ],
            "type": "object"
          },
          "SnapshotMessagesV1": {
            "description": "Estimated tokens of the assembled window's messages, by role.",
            "properties": {
              "assistant": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "custom": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "function_result": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "user": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "assistant",
              "custom",
              "function_result",
              "user"
            ],
            "type": "object"
          },
          "Usage": {
            "properties": {
              "cache_read": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cache_write": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cost_usd": {
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "input": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "output": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "reasoning": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "`harness::on-turn-completed`: a turn reached a terminal status. A turn that ended with a wake armed and was then stopped completes twice: `terminal: false`, then `terminal: true` when its last wake is gone.",
        "properties": {
          "account": {
            "anyOf": [
              {
                "$ref": "#/definitions/AccountRef"
              },
              {
                "type": "null"
              }
            ],
            "description": "The Claude Code account the turn ran on and why (`claude-code` turns, chat-projects phase 4)."
          },
          "context": {
            "anyOf": [
              {
                "$ref": "#/definitions/ContextSnapshotV1"
              },
              {
                "type": "null"
              }
            ],
            "description": "The latest generation's context accounting."
          },
          "open_asks": {
            "default": 0,
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "parent": {
            "anyOf": [
              {
                "$ref": "#/definitions/ParentLink"
              },
              {
                "type": "null"
              }
            ]
          },
          "parent_session_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "result": true,
          "result_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "description": "`completed`, `cancelled` or `failed`.",
            "type": "string"
          },
          "terminal": {
            "description": "`false` while the session still owns an armed wake (claimed or not), or when this turn drained a queued message and reseeds the session: the run continues and a later turn carries the real outcome.",
            "type": "boolean"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "status",
          "terminal",
          "timestamp",
          "turn_id"
        ],
        "title": "TurnCompletedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountRef": {
            "description": "`account {id, source}`: what the verbose `harness::status` and the turn events show.",
            "properties": {
              "id": {
                "description": "The tmux account id.",
                "type": "string"
              },
              "source": {
                "$ref": "#/definitions/AccountSource"
              }
            },
            "required": [
              "id",
              "source"
            ],
            "type": "object"
          },
          "AccountSource": {
            "description": "Why a turn runs on its account (contract D).",
            "oneOf": [
              {
                "description": "The conversation names it (`metadata.claude_account`).",
                "enum": [
                  "session"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's project is pinned to it.",
                "enum": [
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "It is the global account (nothing pins the conversation, or it names `\"global\"`).",
                "enum": [
                  "global"
                ],
                "type": "string"
              }
            ]
          },
          "ContextSnapshotV1": {
            "description": "One generation's context accounting. `free = usable - total`, floored at zero: once provider usage lands, `total` is what was billed, which can exceed the `usable` budget the window was fit into — that budget was derived before the generation from an estimate.",
            "properties": {
              "autocompact": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/SnapshotAutocompactV1"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The autocompact threshold the meters mark (chat-projects phase 3): the setting this step followed, where the end of a turn compacts and the inline budget context-manager applied. Absent from a harness that predates it."
              },
              "categories": {
                "$ref": "#/definitions/SnapshotCategoriesV1"
              },
              "compacted": {
                "description": "The context carries a conversation summary: compacted on this step, or anchored on an earlier compaction entry (a previous step, the console's `/compact`). The summary's tokens count in `system_prompt`.",
                "type": "boolean"
              },
              "effective_max_output_tokens": {
                "description": "Output allocation `usable` was derived against.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "estimator": {
                "description": "Which estimator produced the numbers (`heuristic` until the context-manager resolves a real tokenizer). Absent when the context-manager predates the breakdown response.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "free": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "model": {
                "type": "string"
              },
              "prefix_divergences": {
                "description": "Already-sent rows this session's requests rewrote, newest last (at most [`MAX_PREFIX_DIVERGENCES`]), carried from step to step.",
                "items": {
                  "$ref": "#/definitions/PrefixDivergenceV1"
                },
                "type": "array"
              },
              "prompt_sections_fallback": {
                "description": "Why no shared prefix went out: `disabled` (config), `no_stable_prefix` (empty identity prompt) or `prefix_rewritten` (a pre_generate hook replaced the prompt head; its prompt still wins, it just shares nothing).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "prompt_surface_digest": {
                "description": "Identity of the shared prompt prefix this generation went out with (`sha256:` of the stable section) — present only when the request carried `system_sections`. A local identity, never a provider hit; `usage.cache_read` is the reuse signal.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "provider": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_cost_usd": {
                "description": "Running cost of the whole session in USD, accumulated across every generation step. `usage.cost_usd` is one step's bill — on providers with steep cache discounts the per-step number swings two orders of magnitude, so a chip showing it alone reads as a bouncing total.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "summarized_head_tokens": {
                "description": "Size of the history that summary replaced.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "timestamp": {
                "format": "int64",
                "type": "integer"
              },
              "total": {
                "description": "Final request estimate: categories plus post-assembly growth.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": "string"
              },
              "usable": {
                "description": "The input budget the window was fit into.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Usage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Actual provider usage for this generation, stamped after the terminal frame; absent when the provider returned none (or the generation never completed)."
              }
            },
            "required": [
              "categories",
              "compacted",
              "effective_max_output_tokens",
              "free",
              "model",
              "session_id",
              "step",
              "timestamp",
              "total",
              "turn_id",
              "usable"
            ],
            "type": "object"
          },
          "ParentLink": {
            "description": "Sub-agent linkage recorded on a child turn (harness.md § Sub-agents).",
            "properties": {
              "function_call_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "function_call_id",
              "session_id",
              "turn_id"
            ],
            "type": "object"
          },
          "PrefixDivergenceV1": {
            "description": "One generation that rewrote a row an earlier request of the session had already sent: a prefix-matching provider cache (DeepSeek) stops reusing at that row.",
            "properties": {
              "cache_read": {
                "description": "`usage.cache_read` of the rewriting request: what the provider still reused.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "call_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "cause": {
                "description": "What rewrote the row, as far as the harness can tell: `prune` (context-manager pruned or reduced function results to fit the budget that step) or `system_prompt` (row 0: a compaction summary or a prompt change).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "index": {
                "description": "First row (0 = system prompt, then one per message) that differs from the session's previous request. Absent when only the provider's wire mapping changed.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "prev_len": {
                "description": "Rows the previous request carried.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "provider_note": {
                "description": "The provider's own wire-level finding, cause included, when it reported one (a final-message warning starting with [`PROVIDER_PREFIX_NOTE`]).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "role": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "step",
              "turn_id"
            ],
            "type": "object"
          },
          "Rule": {
            "description": "The rule that decided a conversation's setting.",
            "properties": {
              "project_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_name": {
                "description": "The project's name when the rule was read.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "$ref": "#/definitions/RuleScope"
              }
            },
            "required": [
              "scope"
            ],
            "type": "object"
          },
          "RuleScope": {
            "description": "Which level's setting applies.",
            "oneOf": [
              {
                "enum": [
                  "global",
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's own (a side chat's: its conversation's).",
                "enum": [
                  "session"
                ],
                "type": "string"
              }
            ]
          },
          "SnapshotAutocompactV1": {
            "description": "`ContextSnapshotV1.autocompact`: the threshold the meters mark.",
            "properties": {
              "cap_tokens": {
                "description": "The budget inside a turn, `setting + max(10 %, 20k)`; `null` without a setting. context-manager compacts inline at `min(usable, cap)`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "effective_tokens": {
                "description": "Where the conversation compacts at the end of a turn: the setting when it is below `usable`; `null` when the model's own limit applies.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "rule": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Rule"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The level that decided; `null` when none was resolved."
              },
              "setting_tokens": {
                "description": "The resolved setting; `null` for off.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "SnapshotCategoriesV1": {
            "description": "Where the request's tokens sit. Categories are assembly-time estimates; `hook_guidance` is the measured growth after assembly (pre-generate hook appends and orphan-repair patches), 0 when the request left assembly unchanged.",
            "properties": {
              "hook_guidance": {
                "default": 0,
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "messages": {
                "$ref": "#/definitions/SnapshotMessagesV1"
              },
              "overhead": {
                "description": "Provider framing plus response_format / provider_options fields.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "skills": {
                "default": 0,
                "description": "Selected skill bodies contained in the system prompt.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "system_prompt": {
                "description": "Final assembled system prompt excluding tokens attributed to `skills`: identity, per-step aids, and any compaction summary section.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "tools": {
                "description": "Function schemas exposed to the model.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "messages",
              "overhead",
              "system_prompt",
              "tools"
            ],
            "type": "object"
          },
          "SnapshotMessagesV1": {
            "description": "Estimated tokens of the assembled window's messages, by role.",
            "properties": {
              "assistant": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "custom": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "function_result": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "user": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "assistant",
              "custom",
              "function_result",
              "user"
            ],
            "type": "object"
          },
          "Usage": {
            "properties": {
              "cache_read": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cache_write": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cost_usd": {
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "input": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "output": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "reasoning": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "`harness::on-turn-completed`: a turn reached a terminal status. A turn that ended with a wake armed and was then stopped completes twice: `terminal: false`, then `terminal: true` when its last wake is gone.",
        "properties": {
          "account": {
            "anyOf": [
              {
                "$ref": "#/definitions/AccountRef"
              },
              {
                "type": "null"
              }
            ],
            "description": "The Claude Code account the turn ran on and why (`claude-code` turns, chat-projects phase 4)."
          },
          "context": {
            "anyOf": [
              {
                "$ref": "#/definitions/ContextSnapshotV1"
              },
              {
                "type": "null"
              }
            ],
            "description": "The latest generation's context accounting."
          },
          "open_asks": {
            "default": 0,
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "parent": {
            "anyOf": [
              {
                "$ref": "#/definitions/ParentLink"
              },
              {
                "type": "null"
              }
            ]
          },
          "parent_session_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "result": true,
          "result_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "description": "`completed`, `cancelled` or `failed`.",
            "type": "string"
          },
          "terminal": {
            "description": "`false` while the session still owns an armed wake (claimed or not), or when this turn drained a queued message and reseeds the session: the run continues and a later turn carries the real outcome.",
            "type": "boolean"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "status",
          "terminal",
          "timestamp",
          "turn_id"
        ],
        "title": "TurnCompletedEvent",
        "type": "object"
      }
    },
    {
      "description": "A harness turn began executing (first loop step). For UIs and infrastructure only: agents cannot observe it. To wait on a sub-agent, observe `state::on-changed` on the key its task writes.",
      "metadata": {},
      "name": "harness::on-turn-started",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountRef": {
            "description": "`account {id, source}`: what the verbose `harness::status` and the turn events show.",
            "properties": {
              "id": {
                "description": "The tmux account id.",
                "type": "string"
              },
              "source": {
                "$ref": "#/definitions/AccountSource"
              }
            },
            "required": [
              "id",
              "source"
            ],
            "type": "object"
          },
          "AccountSource": {
            "description": "Why a turn runs on its account (contract D).",
            "oneOf": [
              {
                "description": "The conversation names it (`metadata.claude_account`).",
                "enum": [
                  "session"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's project is pinned to it.",
                "enum": [
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "It is the global account (nothing pins the conversation, or it names `\"global\"`).",
                "enum": [
                  "global"
                ],
                "type": "string"
              }
            ]
          },
          "ParentLink": {
            "description": "Sub-agent linkage recorded on a child turn (harness.md § Sub-agents).",
            "properties": {
              "function_call_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "function_call_id",
              "session_id",
              "turn_id"
            ],
            "type": "object"
          }
        },
        "description": "`harness::on-turn-started`: a turn began executing (first loop step).",
        "properties": {
          "account": {
            "anyOf": [
              {
                "$ref": "#/definitions/AccountRef"
              },
              {
                "type": "null"
              }
            ],
            "description": "The Claude Code account the turn runs on and why (`claude-code` turns, chat-projects phase 4)."
          },
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "message_preview": {
            "description": "The first characters of the message that started the turn (a sub-agent's task text for a child).",
            "type": [
              "string",
              "null"
            ]
          },
          "parent": {
            "anyOf": [
              {
                "$ref": "#/definitions/ParentLink"
              },
              {
                "type": "null"
              }
            ],
            "description": "The spawning call, for a sub-agent turn."
          },
          "parent_session_id": {
            "description": "The session this one is displayed under.",
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "session_id",
          "timestamp",
          "turn_id"
        ],
        "title": "TurnStartedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountRef": {
            "description": "`account {id, source}`: what the verbose `harness::status` and the turn events show.",
            "properties": {
              "id": {
                "description": "The tmux account id.",
                "type": "string"
              },
              "source": {
                "$ref": "#/definitions/AccountSource"
              }
            },
            "required": [
              "id",
              "source"
            ],
            "type": "object"
          },
          "AccountSource": {
            "description": "Why a turn runs on its account (contract D).",
            "oneOf": [
              {
                "description": "The conversation names it (`metadata.claude_account`).",
                "enum": [
                  "session"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's project is pinned to it.",
                "enum": [
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "It is the global account (nothing pins the conversation, or it names `\"global\"`).",
                "enum": [
                  "global"
                ],
                "type": "string"
              }
            ]
          },
          "ParentLink": {
            "description": "Sub-agent linkage recorded on a child turn (harness.md § Sub-agents).",
            "properties": {
              "function_call_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "function_call_id",
              "session_id",
              "turn_id"
            ],
            "type": "object"
          }
        },
        "description": "`harness::on-turn-started`: a turn began executing (first loop step).",
        "properties": {
          "account": {
            "anyOf": [
              {
                "$ref": "#/definitions/AccountRef"
              },
              {
                "type": "null"
              }
            ],
            "description": "The Claude Code account the turn runs on and why (`claude-code` turns, chat-projects phase 4)."
          },
          "depth": {
            "description": "0 for a top-level turn.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "message_preview": {
            "description": "The first characters of the message that started the turn (a sub-agent's task text for a child).",
            "type": [
              "string",
              "null"
            ]
          },
          "parent": {
            "anyOf": [
              {
                "$ref": "#/definitions/ParentLink"
              },
              {
                "type": "null"
              }
            ],
            "description": "The spawning call, for a sub-agent turn."
          },
          "parent_session_id": {
            "description": "The session this one is displayed under.",
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "depth",
          "session_id",
          "timestamp",
          "turn_id"
        ],
        "title": "TurnStartedEvent",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: move conversations { session_ids, project: <id> | \"none\" } and their sub-agents and side chats into a project, or keep them out of every project. Answers { updated }.",
      "metadata": {
        "internal": true
      },
      "name": "harness::projects::assign",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "project": {
            "description": "A project id, or `\"none\"` to keep the conversations out of every project on purpose.",
            "type": "string"
          },
          "session_ids": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "project",
          "session_ids"
        ],
        "title": "ProjectAssignRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "updated": {
            "description": "Sessions written: the named ones and their descendants.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "updated"
        ],
        "title": "ProjectAssignResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: create a chat project { name, color, folders, account?, autocompact?, bring_existing? }; account is { mode: \"global\" } (the default) or { mode: \"pinned\", account_id } (invalid_account otherwise); autocompact is { mode: \"inherit\" } (the default), { mode: \"off\" } or { mode: \"tokens\", tokens } with 20,000-2,000,000 tokens (bad_setting, bad_tokens otherwise); bring_existing stamps the root conversations already in its folders. Answers { project, moved }.",
      "metadata": {
        "internal": true
      },
      "name": "harness::projects::create",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "account": {
            "additionalProperties": true,
            "default": null,
            "description": "The project's Claude Code account: `{mode: \"global\"}` (the default) or `{mode: \"pinned\", account_id}`. Anything else is `invalid_account`.",
            "type": [
              "object",
              "null"
            ]
          },
          "autocompact": {
            "additionalProperties": true,
            "default": null,
            "description": "The project's autocompact setting (chat-projects phase 3): `{mode: \"inherit\"}` (the default), `{mode: \"off\"}` or `{mode: \"tokens\", tokens}` with 20,000-2,000,000 tokens. Anything else is `bad_setting` or `bad_tokens`.",
            "type": [
              "object",
              "null"
            ]
          },
          "bring_existing": {
            "default": null,
            "description": "Stamp the root conversations already in these folders whose `project_id` is missing or `\"none\"`.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "color": {
            "description": "blue, purple, teal, green, amber or rose.",
            "type": "string"
          },
          "folders": {
            "description": "1-20 absolute folders; `~` is expanded on the engine's computer.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "color",
          "folders",
          "name"
        ],
        "title": "ProjectCreateRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Project": {
            "description": "One project.",
            "properties": {
              "account": {
                "additionalProperties": true,
                "default": {
                  "mode": "global"
                },
                "description": "The project's Claude Code account (phase 4); `{mode: \"global\"}` until then. Kept whole, whatever fields it carries.",
                "type": "object"
              },
              "autocompact": {
                "additionalProperties": true,
                "default": {
                  "mode": "inherit"
                },
                "description": "The project's autocompact setting (phase 3); `{mode: \"inherit\"}` until then. Kept whole, whatever fields it carries.",
                "type": "object"
              },
              "color": {
                "description": "One of `blue`, `purple`, `teal`, `green`, `amber`, `rose`.",
                "type": "string"
              },
              "created_at_ms": {
                "format": "int64",
                "type": "integer"
              },
              "folders": {
                "description": "1-20 absolute, normalised folders on the engine's computer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "`prj_` + a ULID, made by the server.",
                "type": "string"
              },
              "name": {
                "description": "1-40 characters, trimmed, unique on the engine without regard to case.",
                "type": "string"
              },
              "updated_at_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "color",
              "created_at_ms",
              "folders",
              "id",
              "name",
              "updated_at_ms"
            ],
            "type": "object"
          }
        },
        "properties": {
          "moved": {
            "description": "Conversations `bring_existing` stamped.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "project": {
            "$ref": "#/definitions/Project"
          }
        },
        "required": [
          "moved",
          "project"
        ],
        "title": "ProjectWriteResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: delete a chat project { id }; its conversations go to No project ({ released }). { path } without an id forwards to harness::folders::delete (apps released before projects).",
      "metadata": {
        "internal": true
      },
      "name": "harness::projects::delete",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "id": {
            "default": null,
            "description": "The project to delete.",
            "type": [
              "string",
              "null"
            ]
          },
          "path": {
            "default": null,
            "description": "Deprecated: without `id`, forget this saved folder (harness::folders::delete).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "ProjectDeleteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "$ref": "#/definitions/ProjectDeleted"
          },
          {
            "$ref": "#/definitions/FolderDeleted"
          }
        ],
        "definitions": {
          "FolderDeleted": {
            "properties": {
              "deleted": {
                "type": "boolean"
              }
            },
            "required": [
              "deleted"
            ],
            "type": "object"
          },
          "ProjectDeleted": {
            "properties": {
              "released": {
                "description": "Conversations that left the project (now under No project).",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "released"
            ],
            "type": "object"
          }
        },
        "title": "ProjectDeleteResponse"
      }
    },
    {
      "description": "List the chat projects: named, coloured groups of folders, and the conversations started in them (a conversation's `metadata.project_id`). Always send `{ \"version\": 2 }`; it answers { version, revision, projects: [{ id, name, color, folders, account, autocompact, created_at_ms, updated_at_ms }] }. Without `version: 2` it answers the old saved-folder list, kept for apps released before projects.",
      "metadata": {
        "internal": true
      },
      "name": "harness::projects::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "version": {
            "default": null,
            "description": "`2` lists the chat projects. Without it, the saved-folder catalogue in its pre-projects shape (deprecated).",
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "title": "ProjectsListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "$ref": "#/definitions/ProjectsListV2"
          },
          {
            "$ref": "#/definitions/LegacyFolderList"
          }
        ],
        "definitions": {
          "LegacyFolderList": {
            "description": "The saved folders, as `harness::projects::list` answered before projects.",
            "properties": {
              "projects": {
                "items": {
                  "$ref": "#/definitions/SavedFolder"
                },
                "type": "array"
              }
            },
            "required": [
              "projects"
            ],
            "type": "object"
          },
          "Project": {
            "description": "One project.",
            "properties": {
              "account": {
                "additionalProperties": true,
                "default": {
                  "mode": "global"
                },
                "description": "The project's Claude Code account (phase 4); `{mode: \"global\"}` until then. Kept whole, whatever fields it carries.",
                "type": "object"
              },
              "autocompact": {
                "additionalProperties": true,
                "default": {
                  "mode": "inherit"
                },
                "description": "The project's autocompact setting (phase 3); `{mode: \"inherit\"}` until then. Kept whole, whatever fields it carries.",
                "type": "object"
              },
              "color": {
                "description": "One of `blue`, `purple`, `teal`, `green`, `amber`, `rose`.",
                "type": "string"
              },
              "created_at_ms": {
                "format": "int64",
                "type": "integer"
              },
              "folders": {
                "description": "1-20 absolute, normalised folders on the engine's computer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "`prj_` + a ULID, made by the server.",
                "type": "string"
              },
              "name": {
                "description": "1-40 characters, trimmed, unique on the engine without regard to case.",
                "type": "string"
              },
              "updated_at_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "color",
              "created_at_ms",
              "folders",
              "id",
              "name",
              "updated_at_ms"
            ],
            "type": "object"
          },
          "ProjectsListV2": {
            "properties": {
              "projects": {
                "items": {
                  "$ref": "#/definitions/Project"
                },
                "type": "array"
              },
              "revision": {
                "description": "Goes up on every change of the store.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "version": {
                "description": "Always 2.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "projects",
              "revision",
              "version"
            ],
            "type": "object"
          },
          "SavedFolder": {
            "description": "One saved folder.",
            "properties": {
              "last_used_at": {
                "format": "int64",
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            },
            "required": [
              "last_used_at",
              "name",
              "path"
            ],
            "type": "object"
          }
        },
        "title": "ProjectsListResponse"
      }
    },
    {
      "description": "A chat project was created, updated or deleted: { revision, project_id, change }. Refetch harness::projects::list { version: 2 }.",
      "metadata": {},
      "name": "harness::projects::on-changed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::projects::on-changed`.",
        "properties": {
          "change": {
            "description": "`created`, `updated` or `deleted`.",
            "type": "string"
          },
          "project_id": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "change",
          "project_id",
          "revision"
        ],
        "title": "ProjectsChangedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::projects::on-changed`.",
        "properties": {
          "change": {
            "description": "`created`, `updated` or `deleted`.",
            "type": "string"
          },
          "project_id": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "change",
          "project_id",
          "revision"
        ],
        "title": "ProjectsChangedEvent",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: change a chat project (a patch: only the fields sent change); autocompact is checked as on create (bad_setting, bad_tokens); bring_existing applies to the folders added in this call. Answers { project, moved }.",
      "metadata": {
        "internal": true
      },
      "name": "harness::projects::update",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "account": {
            "additionalProperties": true,
            "default": null,
            "description": "The project's Claude Code account: `{mode: \"global\"}` or `{mode: \"pinned\", account_id}`. Anything else is `invalid_account`.",
            "type": [
              "object",
              "null"
            ]
          },
          "autocompact": {
            "additionalProperties": true,
            "default": null,
            "description": "The project's autocompact setting (chat-projects phase 3), checked as on create: `{mode: \"inherit\" | \"off\"}` or `{mode: \"tokens\", tokens}`.",
            "type": [
              "object",
              "null"
            ]
          },
          "bring_existing": {
            "default": null,
            "description": "Bring the conversations in the folders this call adds.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "color": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          },
          "folders": {
            "default": null,
            "description": "The whole new folder list.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id"
        ],
        "title": "ProjectUpdateRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Project": {
            "description": "One project.",
            "properties": {
              "account": {
                "additionalProperties": true,
                "default": {
                  "mode": "global"
                },
                "description": "The project's Claude Code account (phase 4); `{mode: \"global\"}` until then. Kept whole, whatever fields it carries.",
                "type": "object"
              },
              "autocompact": {
                "additionalProperties": true,
                "default": {
                  "mode": "inherit"
                },
                "description": "The project's autocompact setting (phase 3); `{mode: \"inherit\"}` until then. Kept whole, whatever fields it carries.",
                "type": "object"
              },
              "color": {
                "description": "One of `blue`, `purple`, `teal`, `green`, `amber`, `rose`.",
                "type": "string"
              },
              "created_at_ms": {
                "format": "int64",
                "type": "integer"
              },
              "folders": {
                "description": "1-20 absolute, normalised folders on the engine's computer.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "`prj_` + a ULID, made by the server.",
                "type": "string"
              },
              "name": {
                "description": "1-40 characters, trimmed, unique on the engine without regard to case.",
                "type": "string"
              },
              "updated_at_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "color",
              "created_at_ms",
              "folders",
              "id",
              "name",
              "updated_at_ms"
            ],
            "type": "object"
          }
        },
        "properties": {
          "moved": {
            "description": "Conversations `bring_existing` stamped.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "project": {
            "$ref": "#/definitions/Project"
          }
        },
        "required": [
          "moved",
          "project"
        ],
        "title": "ProjectWriteResponse",
        "type": "object"
      }
    },
    {
      "description": "Deprecated: forwards to harness::folders::upsert (apps released before chat projects).",
      "metadata": {
        "internal": true
      },
      "name": "harness::projects::upsert",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "name": {
            "default": null,
            "description": "A custom display name. Omit to keep the current name (or use the folder name for a new folder); pass blank to reset to the folder name.",
            "type": [
              "string",
              "null"
            ]
          },
          "path": {
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "FolderUpsertRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SavedFolder": {
            "description": "One saved folder.",
            "properties": {
              "last_used_at": {
                "format": "int64",
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            },
            "required": [
              "last_used_at",
              "name",
              "path"
            ],
            "type": "object"
          }
        },
        "description": "`project` is the key the catalogue answered with before the rename; the shape stays the same (D25). `folder` carries the same record under its new name.",
        "properties": {
          "folder": {
            "$ref": "#/definitions/SavedFolder"
          },
          "project": {
            "$ref": "#/definitions/SavedFolder"
          }
        },
        "required": [
          "folder",
          "project"
        ],
        "title": "FolderUpsertResponse",
        "type": "object"
      }
    },
    {
      "description": "Re-run a session's last turn, which must have failed (e.g. on a Claude Code account's usage limit), from its transcript: no new user message, the failed turn's options and a newly resolved Claude Code account (chat-projects D142). When the failed turn left partial output, the turn resumes from it. Refused with `nothing_to_retry` when the last turn did not fail, and `busy` while a turn runs. Returns the new turn's id.",
      "metadata": {
        "internal": true
      },
      "name": "harness::retry",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "RetryRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "turn_id": {
            "description": "The turn that re-runs the failed one.",
            "type": "string"
          }
        },
        "required": [
          "turn_id"
        ],
        "title": "RetryResponse",
        "type": "object"
      }
    },
    {
      "description": "Entry point: ensure the session, persist the incoming message, and kick off a turn; returns fast (or merges into a running turn).",
      "metadata": {
        "internal": true
      },
      "name": "harness::send",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ExposeMode": {
            "description": "How allowed functions reach the model (harness.md § Exposure modes).",
            "enum": [
              "agent_call",
              "native"
            ],
            "type": "string"
          },
          "FunctionPolicy": {
            "description": "The fail-closed dispatch policy (harness.md § Functions). Absent on the send => every call denied (a plain chat loop).",
            "properties": {
              "allow": {
                "default": [],
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "deny": {
                "default": [],
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "expose": {
                "allOf": [
                  {
                    "$ref": "#/definitions/ExposeMode"
                  }
                ],
                "default": "agent_call"
              }
            },
            "type": "object"
          },
          "OutputContract": {
            "description": "Free text by default; `json` constrains the final answer to a JSON value, validated against `schema` when supplied.",
            "oneOf": [
              {
                "properties": {
                  "type": {
                    "enum": [
                      "text"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "schema": true,
                  "type": {
                    "enum": [
                      "json"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "type"
                ],
                "type": "object"
              }
            ]
          },
          "ReasoningPreset": {
            "description": "An effort the harness resolves from the model's catalog row.",
            "enum": [
              "lowest"
            ],
            "type": "string"
          },
          "SendOptions": {
            "description": "Per-send options frozen onto the turn record (harness.md § `harness::send`).",
            "properties": {
              "agent": {
                "description": "Directory agent profile id (`directory::agents::*`) replacing the built-in identity; new sessions only, refused with a prompt field.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "continuation_entry_id": {
                "description": "Explicit continuation of a user entry on this session's active path. Resolved and bounded by Harness; never inferred from message text.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "functions": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/FunctionPolicy"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Fail-closed dispatch policy; omitted means deny all on a new session and inherit on an existing one (`{ allow: [] }` strips explicitly)."
              },
              "max_cost_usd": {
                "description": "Hard USD budget for the complete root-and-subagent session tree. Every model used by the tree must advertise catalog pricing.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "max_output_tokens": {
                "description": "Per-generation output-token ceiling forwarded to the router.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_total_tokens": {
                "description": "Hard input-plus-output token budget for the complete root-and-subagent session tree.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_turns": {
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_validation_retries": {
                "description": "Per-turn override of the validation-retry budget.",
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "metadata": {
                "description": "Tracing passthrough."
              },
              "output": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/OutputContract"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The turn's deliverable; default `{ type: \"text\" }`."
              },
              "provider_options": {
                "additionalProperties": true,
                "description": "Provider-native per-call options, namespaced by provider id.",
                "type": [
                  "object",
                  "null"
                ]
              },
              "reasoning": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ReasoningPreset"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Ask the harness to pick the effort from the model's catalog row instead of naming one: `lowest` is the model's lowest reasoning effort (never `off`), or the provider default when the model offers no effort choices. Exclusive with `thinking_level` and `provider_options`; the choice is returned as `reasoning` on the send response."
              },
              "require_existing_session": {
                "description": "Refuse a missing session and never ensure/create it. Durable ask delivery uses this so an answer cannot resurrect a deleted session.",
                "type": "boolean"
              },
              "skills": {
                "description": "Exact skill ids advertised to the model; omitted or empty means all on a new session (existing: omitted inherits, empty resets).",
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "system_prompt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "system_prompt_strategy": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/SystemPromptStrategy"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "How `system_prompt` combines with the built-in prompt; omitting both prompt fields on an existing session inherits the prior prompt."
              },
              "thinking_level": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ThinkingLevel"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Omitting both reasoning fields on an existing session inherits the prior turn's; naming either resolves fresh (`provider_options: {}` resets to the provider default)."
              }
            },
            "type": "object"
          },
          "SessionInit": {
            "description": "Session create/ensure options applied when this send creates the session.",
            "properties": {
              "kind": {
                "description": "Session kind stored on creation: `user` (default), `automation` or `e2e`. Opaque to the harness; validated by session-manager.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "metadata": true,
              "title": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "SystemPromptStrategy": {
            "description": "How a caller-supplied system prompt combines with the built-in identity prompt.",
            "oneOf": [
              {
                "description": "Caller prompt replaces the built-in prompt verbatim.",
                "enum": [
                  "override"
                ],
                "type": "string"
              },
              {
                "description": "Caller prompt is appended to the built-in identity prompt.",
                "enum": [
                  "enrich"
                ],
                "type": "string"
              },
              {
                "description": "No system prompt is sent to the model.",
                "enum": [
                  "disabled"
                ],
                "type": "string"
              }
            ]
          },
          "ThinkingLevel": {
            "oneOf": [
              {
                "enum": [
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh"
                ],
                "type": "string"
              },
              {
                "description": "No reasoning at all; honoured only where the model advertises `supports_thinking_off` (elsewhere the provider falls back to its own lowest setting, or omits the parameter, and warns).",
                "enum": [
                  "off"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "idempotency_key": {
            "description": "Webhook dedupe: a repeated key returns the original `{session_id, turn_id}` and appends nothing.",
            "type": [
              "string",
              "null"
            ]
          },
          "message": {
            "description": "The incoming user message text.",
            "type": "string"
          },
          "model": {
            "description": "Required on a new session unless `options.agent` supplies a model; an existing session inherits its last turn's model when omitted.",
            "type": [
              "string",
              "null"
            ]
          },
          "options": {
            "anyOf": [
              {
                "$ref": "#/definitions/SendOptions"
              },
              {
                "type": "null"
              }
            ]
          },
          "provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "session": {
            "anyOf": [
              {
                "$ref": "#/definitions/SessionInit"
              },
              {
                "type": "null"
              }
            ],
            "description": "Applied when this send creates/ensures the session."
          },
          "session_id": {
            "description": "Omit to create a new session.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "message"
        ],
        "title": "SendRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CompactionStarted": {
            "description": "What a `/compact` send started.",
            "properties": {
              "compaction_id": {
                "type": "string"
              },
              "entry_id": {
                "description": "The transcript row its start notice takes (the `idempotency_key`'s `e_idem_` id when the send carried one).",
                "type": "string"
              }
            },
            "required": [
              "compaction_id",
              "entry_id"
            ],
            "type": "object"
          },
          "ResolvedReasoning": {
            "description": "What a `reasoning` preset resolved to for this send. `reasoning_effort` is the provider-native effort (the catalog's own string); both fields are absent when the model offers no effort choices and the provider decides.",
            "properties": {
              "reasoning_effort": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "thinking_level": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ThinkingLevel"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "type": "object"
          },
          "ThinkingLevel": {
            "oneOf": [
              {
                "enum": [
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh"
                ],
                "type": "string"
              },
              {
                "description": "No reasoning at all; honoured only where the model advertises `supports_thinking_off` (elsewhere the provider falls back to its own lowest setting, or omits the parameter, and warns).",
                "enum": [
                  "off"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "accepted": {
            "type": "boolean"
          },
          "compaction": {
            "anyOf": [
              {
                "$ref": "#/definitions/CompactionStarted"
              },
              {
                "type": "null"
              }
            ],
            "description": "Set when the message was the `/compact` command: nothing was appended and no turn ran. The compaction runs in the background; its start and outcome reach every client through the transcript and `harness::on-compaction`."
          },
          "deduplicated": {
            "description": "True when `idempotency_key` matched an earlier send.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "merged": {
            "description": "True when folded into an in-flight turn (steering).",
            "type": [
              "boolean",
              "null"
            ]
          },
          "queued": {
            "description": "True when the message was queued while a step was streaming; it lands in the transcript when the stream ends.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "reasoning": {
            "anyOf": [
              {
                "$ref": "#/definitions/ResolvedReasoning"
              },
              {
                "type": "null"
              }
            ],
            "description": "What `options.reasoning` resolved to; absent when the send named none."
          },
          "session_id": {
            "type": "string"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "accepted",
          "session_id",
          "turn_id"
        ],
        "title": "SendResponse",
        "type": "object"
      }
    },
    {
      "description": "Read the durable root-and-descendant session tree for one harness run.",
      "metadata": {},
      "name": "harness::session-tree",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "root_session_id": {
            "type": "string"
          }
        },
        "required": [
          "root_session_id"
        ],
        "title": "SessionTreeRequestV1",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "SessionTreeNodeV1": {
            "additionalProperties": false,
            "properties": {
              "depth": {
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "parent_session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "parent_turn_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              }
            },
            "required": [
              "depth",
              "session_id"
            ],
            "type": "object"
          }
        },
        "properties": {
          "complete": {
            "type": "boolean"
          },
          "root_session_id": {
            "type": "string"
          },
          "sessions": {
            "items": {
              "$ref": "#/definitions/SessionTreeNodeV1"
            },
            "type": "array"
          }
        },
        "required": [
          "complete",
          "root_session_id",
          "sessions"
        ],
        "title": "SessionTreeResponseV1",
        "type": "object"
      }
    },
    {
      "description": "Set this conversation's one-line description, shown under its name in every client. Call it when the goal or the state of the work changes in a way the user would want to see at a glance: once you understand the task, when you open a pull request, when you get blocked. Under 100 characters, plain text, no trailing period. Call it together with your other tool calls or beside your reply text; never in a step with nothing else in it, and never mention it. Pass `title` only for a new conversation, as a short name of 2 to 6 words.",
      "metadata": {},
      "name": "harness::set-description",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "description": {
            "description": "1-140 characters, one line.",
            "maxLength": 140,
            "minLength": 1,
            "type": "string"
          },
          "title": {
            "description": "1-60 characters; honoured once, for a conversation nobody named yet.",
            "maxLength": 60,
            "minLength": 1,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "description"
        ],
        "title": "SetDescriptionRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "title_ignored": {
            "description": "Set when a `title` was passed and not written: the user named the conversation, or the agent already did.",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "ok"
        ],
        "title": "SetDescriptionResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: close a side chat. One in which nothing was sent is deleted (`deleted: true`); one with messages is kept (`deleted: false`).",
      "metadata": {
        "internal": true
      },
      "name": "harness::side-chat::close",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`close`, `keep` and `summarize` name the side chat.",
        "properties": {
          "session_id": {
            "description": "The side chat's session id.",
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "SideChatRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "deleted": {
            "description": "True when the side chat was empty and its deletion was accepted.",
            "type": "boolean"
          },
          "operation_id": {
            "description": "The `harness::delete-session-tree` operation that deletes it, when `deleted` (read it with `harness::delete-session-tree-status`).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "deleted"
        ],
        "title": "SideChatCloseResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: make a side chat an ordinary conversation, in its conversation's project: its link to the conversation and its lock go.",
      "metadata": {
        "internal": true
      },
      "name": "harness::side-chat::keep",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`close`, `keep` and `summarize` name the side chat.",
        "properties": {
          "session_id": {
            "description": "The side chat's session id.",
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "SideChatRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "meta": {
            "description": "The conversation's session record after the write."
          }
        },
        "required": [
          "meta"
        ],
        "title": "SideChatKeepResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: open a side chat of a conversation, forked at one of its entries (default: its last user or assistant message). The side chat runs on the conversation's model, effort and account, and writes nothing into it. Refused for a side chat (`nested_side_chat`) and for a conversation with no turn yet (`nothing_to_fork`).",
      "metadata": {
        "internal": true
      },
      "name": "harness::side-chat::open",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SideChatQuote": {
            "description": "A passage of the conversation the side chat asks about.",
            "properties": {
              "agent": {
                "description": "Who wrote the message, for the quote card's label.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "message_id": {
                "description": "The conversation's message the passage came from (its entry id).",
                "type": "string"
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "message_id",
              "text"
            ],
            "type": "object"
          }
        },
        "properties": {
          "entry_id": {
            "description": "The conversation's entry to fork at. Default: its last user or assistant message (a reply still streaming is skipped).",
            "type": [
              "string",
              "null"
            ]
          },
          "quote": {
            "anyOf": [
              {
                "$ref": "#/definitions/SideChatQuote"
              },
              {
                "type": "null"
              }
            ],
            "description": "A passage the side chat asks about, recorded in `side_chat_quotes`."
          },
          "session_id": {
            "description": "The conversation to open a side chat of.",
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "SideChatOpenRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "meta": {
            "description": "The side chat's session record after it was tagged (as `session::get` answers it in `meta`)."
          },
          "session_id": {
            "description": "The side chat's session id.",
            "type": "string"
          }
        },
        "required": [
          "meta",
          "session_id"
        ],
        "title": "SideChatOpenResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: ask a side chat for a summary for its conversation (a turn with a fixed prompt). When the reply completes, its entry id is appended to the side chat's `side_chat_summaries`.",
      "metadata": {
        "internal": true
      },
      "name": "harness::side-chat::summarize",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`close`, `keep` and `summarize` name the side chat.",
        "properties": {
          "session_id": {
            "description": "The side chat's session id.",
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "SideChatRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "turn_id": {
            "description": "The summary turn.",
            "type": "string"
          }
        },
        "required": [
          "turn_id"
        ],
        "title": "SideChatSummarizeResponse",
        "type": "object"
      }
    },
    {
      "description": "Spawn a sub-agent in a child session (never an observer target) and return { child_session_id, child_turn_id } immediately; the child's outcome reaches you only through whatever destination its task names. Arm a wake on that destination (e.g. `harness::observe` on `state::on-changed`) BEFORE spawning, then end your turn once every child is spawned. `harness::status` gives child health; a child transcript read while its status is running is partial. Children are leaves unless options.orchestrator is true.",
      "metadata": {},
      "name": "harness::spawn",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ExposeMode": {
            "description": "How allowed functions reach the model (harness.md § Exposure modes).",
            "enum": [
              "agent_call",
              "native"
            ],
            "type": "string"
          },
          "FunctionPolicy": {
            "description": "The fail-closed dispatch policy (harness.md § Functions). Absent on the send => every call denied (a plain chat loop).",
            "properties": {
              "allow": {
                "default": [],
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "deny": {
                "default": [],
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "expose": {
                "allOf": [
                  {
                    "$ref": "#/definitions/ExposeMode"
                  }
                ],
                "default": "agent_call"
              }
            },
            "type": "object"
          },
          "OutputContract": {
            "description": "Free text by default; `json` constrains the final answer to a JSON value, validated against `schema` when supplied.",
            "oneOf": [
              {
                "properties": {
                  "type": {
                    "enum": [
                      "text"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "schema": true,
                  "type": {
                    "enum": [
                      "json"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "type"
                ],
                "type": "object"
              }
            ]
          },
          "SpawnOptions": {
            "properties": {
              "filesystem_root": {
                "description": "Absolute filesystem root for the child turn; omit to inherit the parent's (a reused child keeps its own).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "functions": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/FunctionPolicy"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Dispatch policy for the child, intersected with the parent's (narrow, never escalate)."
              },
              "max_children": {
                "description": "Fan-out guard for the child's own spawns.",
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_output_tokens": {
                "description": "Inherits the parent's ceiling unless explicitly narrowed/overridden.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_turns": {
                "description": "Turn cap for the child, capped at the parent's remaining budget; omit unless required (small values strand the child).",
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_validation_retries": {
                "description": "Override of the child's validation-retry budget.",
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "orchestrator": {
                "description": "Let the child spawn, send, and remove observers (still capped by the parent's policy); default false makes it a leaf.",
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "output": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/OutputContract"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The child's deliverable: text / json / json+schema."
              },
              "skills": {
                "description": "Exact skill ids advertised to the child; omitted or empty means all (a reused child inherits when omitted).",
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "system_prompt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "system_prompt_strategy": {
                "allOf": [
                  {
                    "$ref": "#/definitions/SystemPromptStrategy"
                  }
                ],
                "default": "enrich",
                "description": "How `system_prompt` combines with the built-in prompt."
              },
              "thinking_level": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ThinkingLevel"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "type": "object"
          },
          "SubagentColor": {
            "description": "Closed palette consumed by UIs. A colour outside it (models like to say `orange`) falls back to `neutral` instead of failing the whole spawn on a display-only field — a rejected spawn cost a live orchestrator a step and a re-dispatch (MOT-4718).",
            "enum": [
              "neutral",
              "blue",
              "purple",
              "teal",
              "green",
              "amber",
              "rose"
            ],
            "type": "string"
          },
          "SubagentDisplay": {
            "description": "Display-only identity for a spawned child. The name becomes the session title; icon and color are closed semantic tokens consumed by UIs.",
            "properties": {
              "color": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/SubagentColor"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "icon": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/SubagentIcon"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "name": {
                "description": "Short functional name such as `Frontend`; trimmed, and cut to its first 48 characters when longer.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "name"
            ],
            "type": "object"
          },
          "SubagentIcon": {
            "enum": [
              "agent",
              "code",
              "search",
              "terminal",
              "database",
              "test",
              "review",
              "docs",
              "design"
            ],
            "type": "string"
          },
          "SystemPromptStrategy": {
            "description": "How a caller-supplied system prompt combines with the built-in identity prompt.",
            "oneOf": [
              {
                "description": "Caller prompt replaces the built-in prompt verbatim.",
                "enum": [
                  "override"
                ],
                "type": "string"
              },
              {
                "description": "Caller prompt is appended to the built-in identity prompt.",
                "enum": [
                  "enrich"
                ],
                "type": "string"
              },
              {
                "description": "No system prompt is sent to the model.",
                "enum": [
                  "disabled"
                ],
                "type": "string"
              }
            ]
          },
          "ThinkingLevel": {
            "oneOf": [
              {
                "enum": [
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh"
                ],
                "type": "string"
              },
              {
                "description": "No reasoning at all; honoured only where the model advertises `supports_thinking_off` (elsewhere the provider falls back to its own lowest setting, or omits the parameter, and warns).",
                "enum": [
                  "off"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "agent": {
            "description": "Directory agent profile id (`directory::agents::*`) supplying the child's prompt, skills, model, and display; refused with `options.system_prompt`. Omitted, an in-turn spawn continues the parent turn's profile (name `options.system_prompt` for a child that needs a different identity).",
            "type": [
              "string",
              "null"
            ]
          },
          "display": {
            "anyOf": [
              {
                "$ref": "#/definitions/SubagentDisplay"
              },
              {
                "type": "null"
              }
            ],
            "description": "Display-only name/icon/color for the child session; never affects ids, policy, or routing."
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "options": {
            "anyOf": [
              {
                "$ref": "#/definitions/SpawnOptions"
              },
              {
                "type": "null"
              }
            ]
          },
          "parent_session_id": {
            "description": "Display-only parent for the console tree when there is no live parent turn; grants no policy inheritance.",
            "type": [
              "string",
              "null"
            ]
          },
          "provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "description": "Session id to spawn into, created if absent; an existing id may be reused only inside the caller's own tree.",
            "type": [
              "string",
              "null"
            ]
          },
          "task": {
            "description": "The child's self-contained goal, its opening user message; name every required resource selector literally (the child cannot infer them).",
            "type": "string"
          }
        },
        "required": [
          "task"
        ],
        "title": "SpawnRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "child_session_id": {
            "type": "string"
          },
          "child_turn_id": {
            "type": "string"
          },
          "reused": {
            "default": false,
            "description": "The named session already existed and was reused — its prior transcript and parent linkage were retained (only possible with an explicit `session_id`).",
            "type": "boolean"
          }
        },
        "required": [
          "child_session_id",
          "child_turn_id"
        ],
        "title": "SpawnResponse",
        "type": "object"
      }
    },
    {
      "description": "Read a session's current turn. Returns a lean summary by default; pass verbose: true for the full runtime report and untruncated result.",
      "metadata": {},
      "name": "harness::status",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "type": "string"
          },
          "verbose": {
            "default": false,
            "description": "Include the full runtime report and unmodified result.",
            "type": "boolean"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "StatusRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "$ref": "#/definitions/StatusReport"
          },
          {
            "type": "null"
          }
        ],
        "definitions": {
          "AccountRef": {
            "description": "`account {id, source}`: what the verbose `harness::status` and the turn events show.",
            "properties": {
              "id": {
                "description": "The tmux account id.",
                "type": "string"
              },
              "source": {
                "$ref": "#/definitions/AccountSource"
              }
            },
            "required": [
              "id",
              "source"
            ],
            "type": "object"
          },
          "AccountSource": {
            "description": "Why a turn runs on its account (contract D).",
            "oneOf": [
              {
                "description": "The conversation names it (`metadata.claude_account`).",
                "enum": [
                  "session"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's project is pinned to it.",
                "enum": [
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "It is the global account (nothing pins the conversation, or it names `\"global\"`).",
                "enum": [
                  "global"
                ],
                "type": "string"
              }
            ]
          },
          "AgentMessage": {
            "anyOf": [
              {
                "$ref": "#/definitions/AssistantMessage"
              },
              {
                "$ref": "#/definitions/FunctionResultMessage"
              },
              {
                "$ref": "#/definitions/CustomMessage"
              },
              {
                "$ref": "#/definitions/UserMessage"
              }
            ],
            "description": "The canonical transcript message union. Untagged: the single-variant role tags disambiguate deserialization (assistant/function_result/custom are tried before user so their required fields gate the match)."
          },
          "ArmedWake": {
            "description": "One armed wake as `harness::status` reports it — enough for a console or a poller to say \"parked on state operation_meta/status since T, deadline T2\" instead of showing a session that just looks quietly done.",
            "properties": {
              "args": true,
              "created_at": {
                "format": "int64",
                "type": "integer"
              },
              "expires_at": {
                "format": "int64",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "filters": true,
              "function_id": {
                "description": "The observed function and the observer's args and filters. Absent on records without a source.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "observer_id": {
                "type": "string"
              }
            },
            "required": [
              "created_at",
              "observer_id"
            ],
            "type": "object"
          },
          "AssistantMessage": {
            "properties": {
              "content": {
                "items": {
                  "$ref": "#/definitions/ContentBlock"
                },
                "type": "array"
              },
              "error_details": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ErrorDetails"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "What a `rate_limited` error says beyond its kind (D147): a Claude Code account's usage limit, its window and its reset. Absent on any other message; a reader that predates it ignores the field."
              },
              "error_kind": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ErrorKind"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "error_message": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "model": {
                "type": "string"
              },
              "native_stop_reason": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "provider": {
                "type": "string"
              },
              "role": {
                "$ref": "#/definitions/AssistantRoleTag"
              },
              "stop_reason": {
                "$ref": "#/definitions/StopReason"
              },
              "streaming": {
                "description": "The reply is still streaming into the transcript: `stop_reason` is a placeholder until the final write records the real one and the session store clears this flag. A streaming reply whose turn is no longer running (`harness::status`) was abandoned mid-stream.",
                "type": "boolean"
              },
              "timestamp": {
                "format": "int64",
                "type": "integer"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Usage"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "warnings": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              }
            },
            "required": [
              "content",
              "model",
              "provider",
              "role",
              "stop_reason",
              "timestamp"
            ],
            "type": "object"
          },
          "AssistantRoleTag": {
            "enum": [
              "assistant"
            ],
            "type": "string"
          },
          "ChildRef": {
            "properties": {
              "function_call_id": {
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "function_call_id",
              "session_id",
              "turn_id"
            ],
            "type": "object"
          },
          "ContentBlock": {
            "oneOf": [
              {
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "text"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "text",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "attachment_id": {
                    "description": "Optional link to the stored original of this inline image (`session::put-attachment`, resolvable with `session::get-attachment`). Lets readers ask `session::messages { include_image_data: false }` and fetch the bytes lazily instead of receiving them inline. Persisted verbatim on the transcript; model-bound consumers never see it (see [`ContentBlock::strip_files`]). Omitted on the wire when absent so legacy transcripts stay byte-identical.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "data": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "image"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "data",
                  "mime",
                  "type"
                ],
                "type": "object"
              },
              {
                "description": "Reference to an original upload in the session-manager attachment store (resolvable with `session::get-attachment`). A REFERENCE ONLY: the bytes are never inline. Persisted verbatim on user messages; every model-bound copy replaces it with an `<attachment>` text block naming the call that reads it (see [`ContentBlock::strip_files`]).",
                "properties": {
                  "attachment_id": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "size": {
                    "format": "uint64",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "type": {
                    "enum": [
                      "file"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "attachment_id",
                  "mime",
                  "name",
                  "size",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "signature": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "text": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "thinking"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "text",
                  "type"
                ],
                "type": "object"
              },
              {
                "description": "Opaque redacted thinking payload — replayed verbatim on the wire.",
                "properties": {
                  "data": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "redacted_thinking"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "data",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "arguments": true,
                  "function_id": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "function_call"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "arguments",
                  "function_id",
                  "id",
                  "type"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "content": {
                    "items": {
                      "$ref": "#/definitions/ContentBlock"
                    },
                    "type": "array"
                  },
                  "function_call_id": {
                    "type": "string"
                  },
                  "is_error": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "type": {
                    "enum": [
                      "function_result"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "content",
                  "function_call_id",
                  "type"
                ],
                "type": "object"
              }
            ]
          },
          "ContextSnapshotV1": {
            "description": "One generation's context accounting. `free = usable - total`, floored at zero: once provider usage lands, `total` is what was billed, which can exceed the `usable` budget the window was fit into — that budget was derived before the generation from an estimate.",
            "properties": {
              "autocompact": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/SnapshotAutocompactV1"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The autocompact threshold the meters mark (chat-projects phase 3): the setting this step followed, where the end of a turn compacts and the inline budget context-manager applied. Absent from a harness that predates it."
              },
              "categories": {
                "$ref": "#/definitions/SnapshotCategoriesV1"
              },
              "compacted": {
                "description": "The context carries a conversation summary: compacted on this step, or anchored on an earlier compaction entry (a previous step, the console's `/compact`). The summary's tokens count in `system_prompt`.",
                "type": "boolean"
              },
              "effective_max_output_tokens": {
                "description": "Output allocation `usable` was derived against.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "estimator": {
                "description": "Which estimator produced the numbers (`heuristic` until the context-manager resolves a real tokenizer). Absent when the context-manager predates the breakdown response.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "free": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "model": {
                "type": "string"
              },
              "prefix_divergences": {
                "description": "Already-sent rows this session's requests rewrote, newest last (at most [`MAX_PREFIX_DIVERGENCES`]), carried from step to step.",
                "items": {
                  "$ref": "#/definitions/PrefixDivergenceV1"
                },
                "type": "array"
              },
              "prompt_sections_fallback": {
                "description": "Why no shared prefix went out: `disabled` (config), `no_stable_prefix` (empty identity prompt) or `prefix_rewritten` (a pre_generate hook replaced the prompt head; its prompt still wins, it just shares nothing).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "prompt_surface_digest": {
                "description": "Identity of the shared prompt prefix this generation went out with (`sha256:` of the stable section) — present only when the request carried `system_sections`. A local identity, never a provider hit; `usage.cache_read` is the reuse signal.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "provider": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_cost_usd": {
                "description": "Running cost of the whole session in USD, accumulated across every generation step. `usage.cost_usd` is one step's bill — on providers with steep cache discounts the per-step number swings two orders of magnitude, so a chip showing it alone reads as a bouncing total.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "summarized_head_tokens": {
                "description": "Size of the history that summary replaced.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "timestamp": {
                "format": "int64",
                "type": "integer"
              },
              "total": {
                "description": "Final request estimate: categories plus post-assembly growth.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": "string"
              },
              "usable": {
                "description": "The input budget the window was fit into.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Usage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Actual provider usage for this generation, stamped after the terminal frame; absent when the provider returned none (or the generation never completed)."
              }
            },
            "required": [
              "categories",
              "compacted",
              "effective_max_output_tokens",
              "free",
              "model",
              "session_id",
              "step",
              "timestamp",
              "total",
              "turn_id",
              "usable"
            ],
            "type": "object"
          },
          "CustomMessage": {
            "properties": {
              "content": {
                "items": {
                  "$ref": "#/definitions/ContentBlock"
                },
                "type": "array"
              },
              "custom_type": {
                "type": "string"
              },
              "details": true,
              "display": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "role": {
                "$ref": "#/definitions/CustomRoleTag"
              },
              "timestamp": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "content",
              "custom_type",
              "role",
              "timestamp"
            ],
            "type": "object"
          },
          "CustomRoleTag": {
            "enum": [
              "custom"
            ],
            "type": "string"
          },
          "DeliveryChannel": {
            "description": "How a message reached a session: `direct` from a person (or a client acting as one), `notification` from an observer or the system, `invoked-agent` as a sub-agent's opening task.",
            "enum": [
              "direct",
              "invoked-agent",
              "notification"
            ],
            "type": "string"
          },
          "ErrorDetails": {
            "description": "The details of a provider error that its kind does not carry (chat-projects contract C). The kind stays `rate_limited`: a usage limit is that kind with `usage_limit: true`, and neither the router nor the harness's transient resume retries it.",
            "properties": {
              "resets_at_ms": {
                "description": "When the window resets, in unix milliseconds.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "usage_limit": {
                "default": false,
                "description": "The account reached its plan's usage limit: retrying before the reset cannot succeed.",
                "type": "boolean"
              },
              "window": {
                "description": "The limit's window: `five_hour` or `week`.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "ErrorKind": {
            "enum": [
              "auth_expired",
              "rate_limited",
              "context_overflow",
              "transient",
              "permanent"
            ],
            "type": "string"
          },
          "FunctionResultMessage": {
            "properties": {
              "content": {
                "items": {
                  "$ref": "#/definitions/ContentBlock"
                },
                "type": "array"
              },
              "details": true,
              "function_call_id": {
                "type": "string"
              },
              "function_id": {
                "type": "string"
              },
              "is_error": {
                "type": "boolean"
              },
              "role": {
                "$ref": "#/definitions/FunctionResultRoleTag"
              },
              "timestamp": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "content",
              "details",
              "function_call_id",
              "function_id",
              "is_error",
              "role",
              "timestamp"
            ],
            "type": "object"
          },
          "FunctionResultRoleTag": {
            "enum": [
              "function_result"
            ],
            "type": "string"
          },
          "PrefixDivergenceV1": {
            "description": "One generation that rewrote a row an earlier request of the session had already sent: a prefix-matching provider cache (DeepSeek) stops reusing at that row.",
            "properties": {
              "cache_read": {
                "description": "`usage.cache_read` of the rewriting request: what the provider still reused.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "call_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "cause": {
                "description": "What rewrote the row, as far as the harness can tell: `prune` (context-manager pruned or reduced function results to fit the budget that step) or `system_prompt` (row 0: a compaction summary or a prompt change).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "index": {
                "description": "First row (0 = system prompt, then one per message) that differs from the session's previous request. Absent when only the provider's wire mapping changed.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "prev_len": {
                "description": "Rows the previous request carried.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "provider_note": {
                "description": "The provider's own wire-level finding, cause included, when it reported one (a final-message warning starting with [`PROVIDER_PREFIX_NOTE`]).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "role": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": "string"
              }
            },
            "required": [
              "step",
              "turn_id"
            ],
            "type": "object"
          },
          "QueuedMessage": {
            "description": "One message parked while a step was streaming, waiting for the loop's drain to append it to the transcript (harness.md § Concurrency & steering).",
            "properties": {
              "channel": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/DeliveryChannel"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "How the message reached the session: `direct` is a person (or a client acting as one), `notification` an observer or system notice, `invoked-agent` a sub-agent's opening task. Absent on rows parked by a harness that predates the field. The console hides every row that is not `direct` from the person's queued-messages strip."
              },
              "entry_id": {
                "description": "Deterministic transcript entry id the drain appends under, so a redelivered drain is a no-op.",
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "message": {
                "$ref": "#/definitions/AgentMessage"
              },
              "origin": true,
              "queued_at": {
                "format": "int64",
                "type": "integer"
              },
              "session_id": {
                "type": "string"
              }
            },
            "required": [
              "entry_id",
              "id",
              "message",
              "queued_at",
              "session_id"
            ],
            "type": "object"
          },
          "Rule": {
            "description": "The rule that decided a conversation's setting.",
            "properties": {
              "project_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_name": {
                "description": "The project's name when the rule was read.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "$ref": "#/definitions/RuleScope"
              }
            },
            "required": [
              "scope"
            ],
            "type": "object"
          },
          "RuleScope": {
            "description": "Which level's setting applies.",
            "oneOf": [
              {
                "enum": [
                  "global",
                  "project"
                ],
                "type": "string"
              },
              {
                "description": "The conversation's own (a side chat's: its conversation's).",
                "enum": [
                  "session"
                ],
                "type": "string"
              }
            ]
          },
          "SnapshotAutocompactV1": {
            "description": "`ContextSnapshotV1.autocompact`: the threshold the meters mark.",
            "properties": {
              "cap_tokens": {
                "description": "The budget inside a turn, `setting + max(10 %, 20k)`; `null` without a setting. context-manager compacts inline at `min(usable, cap)`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "effective_tokens": {
                "description": "Where the conversation compacts at the end of a turn: the setting when it is below `usable`; `null` when the model's own limit applies.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "rule": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Rule"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The level that decided; `null` when none was resolved."
              },
              "setting_tokens": {
                "description": "The resolved setting; `null` for off.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "SnapshotCategoriesV1": {
            "description": "Where the request's tokens sit. Categories are assembly-time estimates; `hook_guidance` is the measured growth after assembly (pre-generate hook appends and orphan-repair patches), 0 when the request left assembly unchanged.",
            "properties": {
              "hook_guidance": {
                "default": 0,
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "messages": {
                "$ref": "#/definitions/SnapshotMessagesV1"
              },
              "overhead": {
                "description": "Provider framing plus response_format / provider_options fields.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "skills": {
                "default": 0,
                "description": "Selected skill bodies contained in the system prompt.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "system_prompt": {
                "description": "Final assembled system prompt excluding tokens attributed to `skills`: identity, per-step aids, and any compaction summary section.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "tools": {
                "description": "Function schemas exposed to the model.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "messages",
              "overhead",
              "system_prompt",
              "tools"
            ],
            "type": "object"
          },
          "SnapshotMessagesV1": {
            "description": "Estimated tokens of the assembled window's messages, by role.",
            "properties": {
              "assistant": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "custom": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "function_result": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "user": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "assistant",
              "custom",
              "function_result",
              "user"
            ],
            "type": "object"
          },
          "StatusReport": {
            "properties": {
              "account": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/AccountRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The Claude Code account the turn runs on and why (`claude-code` turns, chat-projects phase 4). Verbose only."
              },
              "armed_wakes": {
                "description": "WHAT the session is parked on, when `expects_wake`: each armed wake's watch and deadline, so \"parked 12m on state operation_meta/status — never written\" is readable from the outside instead of the session just looking quietly done.",
                "items": {
                  "$ref": "#/definitions/ArmedWake"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "children": {
                "items": {
                  "$ref": "#/definitions/ChildRef"
                },
                "type": "array"
              },
              "context": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ContextSnapshotV1"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The last generate step's context accounting (budget, categories, provider-exact usage once it lands) — what a UI meter should show instead of re-estimating the transcript. Verbose only; absent before the first generate."
              },
              "depth": {
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "expects_wake": {
                "default": false,
                "description": "The session owns an armed wake (a one-shot notify subscription, claimed or not, until its delivery has seeded the woken turn), or its finished turn drained a queued message and is about to be reseeded: a completed turn here is NOT the run's outcome — a later turn in this session carries it. Mirrors the `terminal` flag on `harness::on-turn-completed` (`expects_wake == !terminal`). Pollers (e.g. workflow reconcile) must treat `completed && expects_wake` as still running.",
                "type": "boolean"
              },
              "failure": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/TurnFailure"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Why a `failed` turn failed: `code`, and `retryable` when the failure is temporary, so a later send into this session may succeed. Present in the lean report too, only on a failed turn; its `details` (a usage limit's window, reset and account) are verbose only."
              },
              "max_transient_resumes": {
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_turns": {
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_validation_retries": {
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "open_asks": {
                "default": 0,
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "partial_result_available": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "pending_function_calls": {
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "queued": {
                "description": "Messages queued while a step streams, in arrival order; they land in the transcript when the stream ends.",
                "items": {
                  "$ref": "#/definitions/QueuedMessage"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "result": true,
              "result_error": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": "string"
              },
              "status": {
                "$ref": "#/definitions/TurnStatus"
              },
              "step": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "stop_reason": {
                "default": null,
                "description": "Why a `completed` turn stopped when the model did not end it itself (`max_turns`). Present in the lean report too: a poller that reads `completed` with no error must still be able to tell an exhausted budget from a finished task.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "transient_resumes": {
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "turn_count": {
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "turn_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "validation_retries": {
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "children",
              "session_id",
              "status",
              "step",
              "turn_count"
            ],
            "type": "object"
          },
          "StopReason": {
            "enum": [
              "end",
              "length",
              "function_call",
              "aborted",
              "error"
            ],
            "type": "string"
          },
          "TurnFailure": {
            "description": "The failure a `failed` turn ended on.",
            "properties": {
              "code": {
                "description": "The failure code, e.g. `router/provider_transient` or `harness.turn_internal`.",
                "type": "string"
              },
              "details": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/TurnFailureDetails"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "What the code alone does not say: for `llm.usage_limit`, the limit's window and reset and the account that hit it; for `harness.unknown_account`, the account that is gone."
              },
              "retryable": {
                "description": "The failure is temporary, so a later send into the session may succeed: a provider outage, rate limit or cut stream that outlasted the turn's `max_transient_resumes` recovery generations, or a turn the harness could not schedule.",
                "type": "boolean"
              }
            },
            "required": [
              "code",
              "retryable"
            ],
            "type": "object"
          },
          "TurnFailureDetails": {
            "description": "[`TurnFailure::details`] (chat-projects contract D).",
            "properties": {
              "account": {
                "description": "The tmux account id the turn ran on, or was pinned to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "resets_at_ms": {
                "description": "When the limit's window resets, in unix milliseconds.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "usage_limit": {
                "description": "The Claude Code account reached its plan's usage limit.",
                "type": "boolean"
              },
              "window": {
                "description": "The limit's window: `five_hour` or `week`.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "TurnStatus": {
            "description": "The coarse, harness-internal turn lifecycle (harness.md § API Reference). Finer-grained than the session's `status`, which the loop derives from it.",
            "enum": [
              "running",
              "awaiting_functions",
              "completed",
              "cancelled",
              "failed"
            ],
            "type": "string"
          },
          "Usage": {
            "properties": {
              "cache_read": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cache_write": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cost_usd": {
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "input": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "output": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "reasoning": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "UserMessage": {
            "properties": {
              "content": {
                "items": {
                  "$ref": "#/definitions/ContentBlock"
                },
                "type": "array"
              },
              "role": {
                "$ref": "#/definitions/UserRoleTag"
              },
              "timestamp": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "content",
              "role",
              "timestamp"
            ],
            "type": "object"
          },
          "UserRoleTag": {
            "enum": [
              "user"
            ],
            "type": "string"
          }
        },
        "title": "Nullable_StatusReport"
      }
    },
    {
      "description": "Request cancellation of an in-flight turn (cascades to spawned children).",
      "metadata": {
        "internal": true
      },
      "name": "harness::stop",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "quiet_deadlines": {
            "description": "For a stop that means no more turns: a session parked on a wake has no turn to cancel, so also record the stop on it. That wake's deadline then retires it without starting a turn, and the last one ends the session as cancelled; a delivery still wakes it. Omit to leave a parked session to end on its next wake, its deadline included.",
            "type": "boolean"
          },
          "session_id": {
            "type": "string"
          },
          "turn_id": {
            "description": "Omit to stop the current turn.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "session_id"
        ],
        "title": "StopRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "stopping": {
            "type": "boolean"
          }
        },
        "required": [
          "stopping"
        ],
        "title": "StopResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal cron sweep: resolve pending function calls past their timeout and re-enqueue the step of running turns left without one, so a turn never wedges; then move finished turn records' inline prompts to shared bodies and delete unused bodies. Not called directly.",
      "metadata": {
        "internal": true
      },
      "name": "harness::sweep-pending",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Cron event payload (ignored — the sweep scans all turn records). A struct keeps the request schema concrete.",
        "properties": {
          "scheduled_at": {
            "default": null,
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "title": "SweepEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "converted": {
            "default": 0,
            "description": "Finished turn records rewritten with prompt refs.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "ok": {
            "type": "boolean"
          },
          "prompts_collected": {
            "default": 0,
            "description": "Unreferenced prompt bodies deleted.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "redriven": {
            "default": 0,
            "description": "Number of orphaned running turns whose step was re-enqueued.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "resolved": {
            "description": "Number of expired pending calls resolved this sweep.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "ok",
          "resolved"
        ],
        "title": "SweepResponse",
        "type": "object"
      }
    },
    {
      "description": "Preview the system prompt layers a session will use without making a model request.",
      "metadata": {
        "internal": true
      },
      "name": "harness::system-prompt::get",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SelectedSystemPrompt": {
            "properties": {
              "body": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "strategy": {
                "allOf": [
                  {
                    "$ref": "#/definitions/SystemPromptStrategy"
                  }
                ],
                "default": "enrich"
              }
            },
            "required": [
              "body",
              "name"
            ],
            "type": "object"
          },
          "SystemPromptStrategy": {
            "description": "How a caller-supplied system prompt combines with the built-in identity prompt.",
            "oneOf": [
              {
                "description": "Caller prompt replaces the built-in prompt verbatim.",
                "enum": [
                  "override"
                ],
                "type": "string"
              },
              {
                "description": "Caller prompt is appended to the built-in identity prompt.",
                "enum": [
                  "enrich"
                ],
                "type": "string"
              },
              {
                "description": "No system prompt is sent to the model.",
                "enum": [
                  "disabled"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "default_only": {
            "default": false,
            "description": "Return only the built-in default layer, without session, runtime, registry, or hook layers.",
            "type": "boolean"
          },
          "filesystem_root": {
            "type": [
              "string",
              "null"
            ]
          },
          "selected_prompt": {
            "anyOf": [
              {
                "$ref": "#/definitions/SelectedSystemPrompt"
              },
              {
                "type": "null"
              }
            ]
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "SystemPromptRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SystemPromptPart": {
            "properties": {
              "body": {
                "type": "string"
              },
              "kind": {
                "$ref": "#/definitions/SystemPromptPartKind"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "body",
              "kind"
            ],
            "type": "object"
          },
          "SystemPromptPartKind": {
            "enum": [
              "built_in",
              "selected",
              "skills",
              "runtime",
              "injected"
            ],
            "type": "string"
          }
        },
        "properties": {
          "parts": {
            "items": {
              "$ref": "#/definitions/SystemPromptPart"
            },
            "type": "array"
          }
        },
        "required": [
          "parts"
        ],
        "title": "SystemPromptPreview",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: remove the observers a root harness session tree created.",
      "metadata": {
        "internal": true
      },
      "name": "harness::teardown",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "root_session_id": {
            "type": "string"
          }
        },
        "required": [
          "root_session_id"
        ],
        "title": "TeardownRequestV1",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "removed": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "removed"
        ],
        "title": "TeardownResponseV1",
        "type": "object"
      }
    },
    {
      "description": "Internal durable loop step (enqueued onto the harness-turn queue); not called directly.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "harness::turn",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "The enqueued `harness::turn` step payload.",
        "properties": {
          "depth": {
            "default": 0,
            "description": "Sub-agent depth carried from the turn record (0 = top-level).",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "message_preview": {
            "description": "Preview carried from the turn record so the step can stamp the `iii.tag.message` baggage before any state read.",
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "step": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "step",
          "turn_id"
        ],
        "title": "TurnStepPayload",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "TurnStatus": {
            "description": "The coarse, harness-internal turn lifecycle (harness.md § API Reference). Finer-grained than the session's `status`, which the loop derives from it.",
            "enum": [
              "running",
              "awaiting_functions",
              "completed",
              "cancelled",
              "failed"
            ],
            "type": "string"
          }
        },
        "properties": {
          "next_step": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "skipped": {
            "default": false,
            "description": "True when a redelivered/stale step was acked and dropped.",
            "type": "boolean"
          },
          "status": {
            "$ref": "#/definitions/TurnStatus"
          }
        },
        "required": [
          "session_id",
          "status"
        ],
        "title": "TurnStepResult",
        "type": "object"
      }
    },
    {
      "description": "Serve the harness worker's injected console UI assets (the target of its ade::ui::asset observers; the console calls it through each asset's observer with {path}).",
      "metadata": {
        "internal": true
      },
      "name": "harness::ui-content",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Input of the content function: the console asks for one asset by path.",
        "properties": {
          "path": {
            "description": "The asset path from the observer's args (e.g. `state/page.js`).",
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "UiContentInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Output of the content function.",
        "properties": {
          "content": {
            "description": "The asset source, verbatim.",
            "type": "string"
          },
          "content_type": {
            "description": "MIME type the console should serve the asset with.",
            "type": "string"
          }
        },
        "required": [
          "content",
          "content_type"
        ],
        "title": "UiContentResult",
        "type": "object"
      }
    },
    {
      "description": "Remove an observer the current harness session created (`id` is the observer_id harness::observe returned).",
      "metadata": {},
      "name": "harness::unobserve",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Agent-facing unobserve contract. The id is the `observer_id` `harness::observe` returned.",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "title": "UnobserveArgs",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "removed": {
            "type": "boolean"
          }
        },
        "required": [
          "removed"
        ],
        "title": "UnobserveResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: remove a still-parked queued message by entry_id (the console's edit-queued path).",
      "metadata": {
        "internal": true
      },
      "name": "harness::unqueue",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "entry_id": {
            "description": "The queued row's transcript entry id, as surfaced by `harness::status` → `queued[].entry_id`. Stable and client-visible (the internal row id is not), so removals target it.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          }
        },
        "required": [
          "entry_id",
          "session_id"
        ],
        "title": "UnqueueRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "removed": {
            "description": "False when no still-parked row matched — already drained or unknown.",
            "type": "boolean"
          }
        },
        "required": [
          "removed"
        ],
        "title": "UnqueueResponse",
        "type": "object"
      }
    }
  ]
}
```
