Skip to content
Sign in

harness

v1.9.19

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

license: Apache-2.0Used in 4 kitsagentautonomousharnessloop

Install

bash
iii call compose::add worker=harness@1.9.19

Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.

Agent-ready brief for v1.9.19
Install, config, dependencies, readme, skills and API reference, all in one place. Fetch as agent-context.md for an LLM to consume.
The same content rendered as discrete blocks below is exposed as a single markdown document at /registry/workers/harness.md?version=1.9.19. Paste it into an LLM prompt or pipe it through curl from a worker.

Install

iii call compose::add worker=harness@1.9.19

Dependencies

Readme

README.md

harness

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

Install: iii call compose::add worker=harness License: Apache 2.0 Built with Rust harness on the workers registry ade on the workers registry

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 (transcript), context-manager (token budgeting, soft dependency), and 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:

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
# New terminal, same folder. `compose::add` updates this Compose project.
cd iii-app
iii call compose::add worker=harness worker=ade
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.

Harness turn waterfall in the iii console

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 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 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 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):

{
  "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:

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  # durable operator project catalog (default: data/harness-projects.json under III_COMPOSE_DIR / cwd)
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.

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): 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. 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 — 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.

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.

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, 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 and optional provider-native reasoning_effort are authoritative for the session, and — 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/effort slot in the same way (model precedence profile → explicit model → parent, without dragging the parent's provider onto a foreign model), 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.

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 (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. Unconfirmed work fails closed with data retained. See recovery, safety boundaries and tests.

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.

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;
  • 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.

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.

{ "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:

{ "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:

{ "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.

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? }: a turn began executing (first loop step); depth is 0 at the top level.
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? }: 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, ... }: an explicit compaction started (phase: started) or finished (phase: completed with status ok/busy/empty/failed, the user-facing message, tokens_before / tokens_after and the transcript entry_ids).
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::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.

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, 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:

// 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 for the hook contract and chain semantics.

Skills

API reference (JSON)

agent-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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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": "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": {
          "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": "How an explicit compaction ended — also what `harness::on-compaction` carries on completion.",
        "properties": {
          "compaction_id": {
            "type": "string"
          },
          "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"
          },
          "message": {
            "description": "The outcome as every client shows it.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/Status"
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "tokens_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "tokens_before": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "compaction_id",
          "entry_ids",
          "message",
          "session_id",
          "status"
        ],
        "title": "Outcome",
        "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: 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": {
              "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"
          },
          "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"
          },
          "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": "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; filter on input.session_id.",
      "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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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; filter on input.session_id.",
      "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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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 chip label such as `Approach`; 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 full question text shown above the options.",
                "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": "An explicit compaction of a session started (`phase: started`) or finished (`phase: completed`, with `status` ok/busy/empty/failed and the user-facing `message`). Filter on input.session_id or input.compaction_id.",
      "metadata": {},
      "name": "harness::on-compaction",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::on-compaction`: an explicit compaction's progress.",
        "properties": {
          "compaction_id": {
            "type": "string"
          },
          "entry_ids": {
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "message": {
            "description": "`completed` only: the user-facing message.",
            "type": [
              "string",
              "null"
            ]
          },
          "phase": {
            "description": "`started` or `completed`.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "description": "`completed` only: `ok`, `busy`, `empty` or `failed`.",
            "type": [
              "string",
              "null"
            ]
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          },
          "tokens_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "tokens_before": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "compaction_id",
          "phase",
          "session_id",
          "timestamp"
        ],
        "title": "CompactionEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "`harness::on-compaction`: an explicit compaction's progress.",
        "properties": {
          "compaction_id": {
            "type": "string"
          },
          "entry_ids": {
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "message": {
            "description": "`completed` only: the user-facing message.",
            "type": [
              "string",
              "null"
            ]
          },
          "phase": {
            "description": "`started` or `completed`.",
            "type": "string"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "description": "`completed` only: `ok`, `busy`, `empty` or `failed`.",
            "type": [
              "string",
              "null"
            ]
          },
          "timestamp": {
            "format": "int64",
            "type": "integer"
          },
          "tokens_after": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "tokens_before": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "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. Filter on input.session_id.",
      "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. Filter on input.session_id.",
      "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). Filter on input.session_id, or on input.parent.session_id / input.parent_session_id.",
      "metadata": {},
      "name": "harness::on-turn-completed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "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": {
              "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"
          },
          "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": {
          "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": {
          "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": {
              "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"
          },
          "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": {
          "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). Filter on input.session_id, or on input.parent.session_id / input.parent_session_id for a sub-agent's parent.",
      "metadata": {},
      "name": "harness::on-turn-started",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "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": {
          "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": {
          "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": {
          "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: remove a project directory from the durable catalog.",
      "metadata": {
        "internal": true
      },
      "name": "harness::projects::delete",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "path": {
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "ProjectDeleteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "deleted": {
            "type": "boolean"
          }
        },
        "required": [
          "deleted"
        ],
        "title": "ProjectDeleteResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: list the operator's durable project catalog.",
      "metadata": {
        "internal": true
      },
      "name": "harness::projects::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "ProjectsListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Project": {
            "properties": {
              "last_used_at": {
                "format": "int64",
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            },
            "required": [
              "last_used_at",
              "name",
              "path"
            ],
            "type": "object"
          }
        },
        "properties": {
          "projects": {
            "items": {
              "$ref": "#/definitions/Project"
            },
            "type": "array"
          }
        },
        "required": [
          "projects"
        ],
        "title": "ProjectsListResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal control-plane: remember, touch, or rename a project directory.",
      "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 project); pass blank to reset to the folder name.",
            "type": [
              "string",
              "null"
            ]
          },
          "path": {
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "ProjectUpsertRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Project": {
            "properties": {
              "last_used_at": {
                "format": "int64",
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            },
            "required": [
              "last_used_at",
              "name",
              "path"
            ],
            "type": "object"
          }
        },
        "properties": {
          "project": {
            "$ref": "#/definitions/Project"
          }
        },
        "required": [
          "project"
        ],
        "title": "ProjectUpsertResponse",
        "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": "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. Check `harness::status` for child health; 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": {
          "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_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"
              },
              "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": {
              "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"
          },
          "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"
          },
          "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": {
              "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."
              },
              "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"
              },
              "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"
          },
          "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"
      }
    }
  ]
}

Search the registry

Find workers, kits and executables, or jump to a page.