{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/reasonmachines-com/json-schema/reasonmachines-com-session-schema.json",
  "title": "Session",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/reasonmachines-com-openapi.json#/components/schemas/Session",
  "type": "object",
  "properties": {
    "follow_up": {
      "description": "Opt-in detail field: request fields=follow_up. Null when temporarily unavailable. Durable follow-through state. Pending check-ins do not change lifecycle status; merge is never evidence of deployment or verification.",
      "anyOf": [
        {
          "$ref": "#/$defs/SessionFollowUp"
        },
        {
          "type": "null"
        }
      ]
    },
    "benchmark_profile": {
      "description": "Always null: benchmark_profile is retired.",
      "oneOf": [
        {
          "type": "string",
          "const": "coding-benchmark-v1"
        },
        {
          "type": "null"
        }
      ]
    },
    "runtime_profile": {
      "description": "runtime/reason-sync-yield-v1 on a retired isolated Session that requested it through the retired runtime_profile field. Null otherwise.",
      "oneOf": [
        {
          "type": "string",
          "const": "runtime/reason-sync-yield-v1"
        },
        {
          "type": "null"
        }
      ]
    },
    "experimental_runtime_profile": {
      "description": "The runtime profile the Session's latest Attempt runs: the default C2 harness on every Session that runs it, whether or not its request named it (a Session of the retired runtime/reason-capability-shell-v1 continues on it) — reported as runtime/reason-c2-tools-v7; runtime/reason-v7-sync-yield-v1 or runtime/reason-v7-sync-yield-machine-sdk-v1 on a stored Session of that retired harness; runtime/reason-v7-2026-10, runtime/reason-v7-2026-11, runtime/reason-v8-2026-10, runtime/reason-v8.1-2026-10, runtime/reason-v8.2-2026-10, runtime/reason-agent-1.2, runtime/reason-agent-1.3 or runtime/reason-agent-1.3.1 on a Session that runs it; a Session of a deleted v7 evaluation profile reports the default C2 harness, which it re-admits to. Null otherwise.",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "runtime/reason-c2-tools-v7",
            "runtime/reason-v7-sync-yield-v1",
            "runtime/reason-v7-sync-yield-machine-sdk-v1",
            "runtime/reason-v7-2026-10",
            "runtime/reason-v7-2026-11",
            "runtime/reason-v8-2026-10",
            "runtime/reason-v8.1-2026-10",
            "runtime/reason-v8.2-2026-10",
            "runtime/reason-agent-1.2",
            "runtime/reason-agent-1.3",
            "runtime/reason-agent-1.3.1"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "experimental_runtime_features": {
      "description": "The runtime features the Session's create named (experimental_runtime_features), in canonical order. Null when it named none.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string",
        "enum": [
          "banner",
          "sdk_index",
          "service_tier",
          "output_cap",
          "git_metadata",
          "serial_reads",
          "recovery_defer_idle_hands",
          "fewer_tests_low",
          "fewer_tests_medium",
          "fewer_tests_high",
          "fewer_tests_max",
          "fewer_tests_max_alone",
          "verify_line_alone",
          "addendum_placebo",
          "bash_yield",
          "sync_bash",
          "turn_line_removed",
          "turn_line_questions",
          "output_cap_continue",
          "image_history_append_only",
          "cache_ttl_1h"
        ]
      }
    },
    "session_policy": {
      "type": "object",
      "properties": {
        "version": {
          "type": "number",
          "const": 1,
          "description": "Version of this policy shape."
        },
        "mode": {
          "type": "string",
          "enum": [
            "standard",
            "isolated",
            "ephemeral"
          ],
          "description": "How the Session runs: standard for normal work, ephemeral for a single benchmark trial. isolated is retired: only Sessions created before its retirement report it, and a retry, follow-up, wake or move of one returns 409 session_mode_retired."
        },
        "components": {
          "type": "object",
          "properties": {
            "memoryRead": {
              "type": "boolean",
              "description": "Whether memory reads are enabled."
            },
            "memoryWrite": {
              "type": "boolean",
              "description": "Whether memory writes are enabled."
            },
            "skills": {
              "type": "boolean",
              "description": "Whether skills are enabled."
            },
            "inheritedInstructions": {
              "type": "boolean",
              "description": "Whether inherited instructions are enabled."
            },
            "integrations": {
              "type": "boolean",
              "description": "Whether integrations are enabled."
            },
            "secretInjection": {
              "type": "boolean",
              "description": "Whether secret injection is enabled."
            }
          },
          "required": [
            "memoryRead",
            "memoryWrite",
            "skills",
            "inheritedInstructions",
            "integrations",
            "secretInjection"
          ],
          "description": "The optional capability families, each enabled (true) or disabled (false) for this Session."
        },
        "workspaceOwnership": {
          "type": "string",
          "enum": [
            "managed",
            "externally-managed"
          ],
          "description": "Filesystem persistence owner. Sessions created with the deprecated ara-managed spelling report managed."
        },
        "personalContext": {
          "description": "Present and false when the Session was created with personal_context: false: it runs without its creator's personal skills, memory, secrets and connections. Absent when the creator's personal context loads.",
          "type": "boolean",
          "const": false
        },
        "pullRequestPolicy": {
          "description": "Present as draft_only when the Session was created with pull_request_policy: draft_only: its pull requests stay drafts and it cannot merge, queue, auto-merge or mark one ready. Absent for the normal delivery flow.",
          "type": "string",
          "const": "draft_only"
        }
      },
      "required": [
        "version",
        "mode",
        "components",
        "workspaceOwnership"
      ],
      "description": "Server-resolved immutable Session policy. Enabled components remain subject to normal permissions and configuration."
    },
    "session_id": {
      "type": "string",
      "description": "The Session's stable id; pass it as sessionId to the other session tools."
    },
    "placement_receipt": {
      "$ref": "#/$defs/PlacementReceipt"
    },
    "origin": {
      "type": "string",
      "enum": [
        "ui",
        "external:cli",
        "external:mcp",
        "external:api"
      ],
      "description": "Where the Session was started: ui is the Reason app, external:cli, external:mcp and external:api the CLI, an MCP client and the API."
    },
    "origin_agent": {
      "description": "Name of the agent or client that started the Session, when known.",
      "type": [
        "string",
        "null"
      ]
    },
    "agent_identity_source": {
      "description": "How origin_agent was established: self_reported by the caller, from the credential, or from the Device.",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "self_reported",
            "credential",
            "device"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "running",
        "exit",
        "error",
        "suspended"
      ],
      "description": "Lifecycle state, not task success: running, exit (execution completed), error (execution failed), or suspended (cancelled/quota; suspended_reason says which). An exit can have outcome failure or action_required. The task succeeded if and only if outcome is success; check outcome, result, and diagnostics before treating work as successful."
    },
    "suspended_reason": {
      "description": "Why status is suspended: cancelled (an explicit cancel stopped the Session) or quota_exhausted (the Workspace ran out of quota). Null for every other status.",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "cancelled",
            "quota_exhausted"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "url": {
      "type": "string",
      "description": "Web URL to watch the session."
    },
    "created_at": {
      "description": "When the Session was created.",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "started_at": {
      "description": "When execution started; null before it starts.",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "finished_at": {
      "description": "When execution finished; null while running.",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "updated_at": {
      "description": "When the Session's current Attempt last changed (status, result, pull request, usage); sort or diff on it to see which Sessions moved since a previous read.",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "title": {
      "description": "Display title: the Session's own title, else the issue title, else the start of the opening prompt.",
      "type": [
        "string",
        "null"
      ]
    },
    "prompt": {
      "description": "The opening instruction, truncated to 16 KiB. Check prompt_truncated; read the session messages for the full text.",
      "type": [
        "string",
        "null"
      ]
    },
    "prompt_truncated": {
      "type": "boolean",
      "description": "True when prompt was cut to the 16 KiB echo limit."
    },
    "prompt_bytes": {
      "description": "UTF-8 byte length of the full prompt, before truncation.",
      "type": [
        "integer",
        "null"
      ]
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The Session's tag labels; empty when it has none."
    },
    "project_id": {
      "deprecated": true,
      "description": "Deprecated: Projects are retired in favour of Reasons. Project containing the session, or null for an unassigned session.",
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "reason_id": {
      "description": "The Reason (listReasons) this Session is listed under: the one whose conversation started it, directly or through the Sessions it started. A Session filed in a former Project names that Project's id, which its Reason kept. Null when no Reason started it.",
      "type": [
        "string",
        "null"
      ]
    },
    "created_by_session_id": {
      "description": "The Session whose agent started this one with sessions_create; null when a person, a trigger or a Loop started it.",
      "type": [
        "string",
        "null"
      ]
    },
    "delegation": {
      "type": "object",
      "properties": {
        "max_depth": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5,
          "description": "How deep the tree may nest below its root Session."
        },
        "children_can_create_sessions": {
          "type": "boolean",
          "description": "Whether subagents above the last level may create Sessions that join the tree."
        }
      },
      "required": [
        "max_depth",
        "children_can_create_sessions"
      ],
      "description": "The delegation limits a caller set for this Session's tree (see `delegation` on createSession); absent when none were set, which is the default tree."
    },
    "automation_id": {
      "description": "The automation (Loop) whose trigger started this Session, as listReasonLoops (or listAutomations) names it; null otherwise.",
      "type": [
        "string",
        "null"
      ]
    },
    "target": {
      "anyOf": [
        {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "cloud",
                  "description": "Run on Reason-managed cloud compute."
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "mac"
                },
                "device_id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "root_id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                }
              },
              "required": [
                "kind",
                "device_id",
                "root_id"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "headless",
                  "description": "Run on a CLI-connected computer or externally provisioned worker."
                },
                "device_id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "description": "Connected computer or worker ID returned by listDevices."
                },
                "root_id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "workspace_mode": {
                  "description": "Defaults to a stable Session-managed checkout. project_root explicitly operates the selected existing root.",
                  "type": "string",
                  "enum": [
                    "managed",
                    "project_root"
                  ]
                },
                "workspace_path": {
                  "description": "Absolute path of the project_root on the Device, as the client sees it (for example /app). Read only with workspace_mode project_root, as the working directory the default C2 harness names in its model prompt; ignored otherwise, and rejected when the request names experimental_runtime_profile runtime/reason-c2-tools-v7. It grants nothing and never selects a directory.",
                  "type": "string",
                  "maxLength": 4096,
                  "pattern": "^\\/[^\\u0000\\r\\n]*$"
                }
              },
              "required": [
                "kind",
                "device_id",
                "root_id"
              ],
              "additionalProperties": false
            }
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Present on GET: the execution target this Session was created with (`cloud`, or the Device and root it runs on). A later handoff is not reflected. A Machine target reads back as its placed headless worker; see `machine`."
    },
    "machine": {
      "$ref": "#/$defs/SessionMachine"
    },
    "repo": {
      "description": "The Session's starting repository as owner/name; null for a repository-neutral Session.",
      "type": [
        "string",
        "null"
      ]
    },
    "provider": {
      "description": "Source-control provider for the session repository.",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "github",
            "gitlab"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "model": {
      "description": "Concrete model selected for this session, or null when inherited.",
      "type": [
        "string",
        "null"
      ]
    },
    "reason_version": {
      "description": "The Reason Agent version (X.Y, e.g. 1.4 for Reason Agent 1.4) of the server that executed the Session's latest turn. It names the daily release; reason_commit_sha is the exact build. During a rolling deploy this is the release that actually ran the turn, not the newest one. Null before the turn starts and for turns that ran before versions were recorded.",
      "type": [
        "string",
        "null"
      ]
    },
    "reason_commit_sha": {
      "description": "The commit the server that executed the Session's latest turn was built from. Null when reason_version is null or the build carried no commit.",
      "type": [
        "string",
        "null"
      ]
    },
    "reasoning_effort": {
      "description": "Reasoning effort override the Session runs with; null when none was set.",
      "type": [
        "string",
        "null"
      ]
    },
    "hands_mode": {
      "type": "string",
      "enum": [
        "adaptive",
        "brain_only"
      ],
      "description": "Durable physical execution policy. Brain-only sessions never acquire a shell, browser, sandbox, or physical secret environment."
    },
    "branch": {
      "description": "Name of the Session's working branch in its workspace. It is assigned when the machine starts, before any commit, so it exists on the remote only once the Session pushed to it: check pr_url and branch_has_commits.",
      "type": [
        "string",
        "null"
      ]
    },
    "branch_has_commits": {
      "description": "Whether the working branch reached the remote without a pull request: true when it has pushed commits, false when the Session ended without pushing any (the branch may not exist on the remote). Null while undetermined, and when pr_url is set.",
      "type": [
        "boolean",
        "null"
      ]
    },
    "pr_url": {
      "description": "URL of the pull request the Session opened or continued; null when there is none.",
      "type": [
        "string",
        "null"
      ]
    },
    "pr_title": {
      "description": "Title of that pull request.",
      "type": [
        "string",
        "null"
      ]
    },
    "result_summary": {
      "description": "Text summary of the latest turn's answer; null before a turn finishes.",
      "type": [
        "string",
        "null"
      ]
    },
    "outcome": {
      "description": "The task verdict, and the one field that says whether the work succeeded: the task succeeded if and only if outcome is success. Retrieve a session and List sessions report the same value. With `completion_mode: run_outcome` it is the verdict the agent recorded (success, failure, or action_required when a person or an unavailable dependency must act); a run that stops without recording one never reports success, normally action_required with its reply in result. Recording a verdict is a tool call, so a prompt that forbids tools gets action_required even when the reply is correct. Without `completion_mode` no verdict is recorded: an exit reports success because the execution completed (action_required when the turn ended waiting on a person), which does not say the work was checked. Null while running and when status is error or suspended without a verdict.",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "success",
            "failure",
            "action_required"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "result": {
      "description": "Caller-defined JSON result for a noninteractive completion, or the ordinary final summary for legacy Sessions."
    },
    "blocker": {
      "description": "When outcome is failure or action_required: what blocked the Session and the next step a person takes, in one sentence the agent wrote (for example \"Connect 1password: the deploy reads its token from the vault\"). The agent states it when it records the verdict, or it is the access card the turn waits on. Null when the agent stated none, while running, and when outcome is success. List sessions reports it on each row.",
      "type": [
        "string",
        "null"
      ]
    },
    "failure": {
      "description": "Why the latest turn stopped and how to get it going again, for a caller that does not read the transcript. Null while running and when the turn did not stop on a failure (an agent's own verdict is in `outcome` and `blocker`). List sessions reports it on each row.",
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "category": {
          "type": "string",
          "description": "What kind of stop, for example `cloud_start_failed`, `model_auth`, `provider_model_not_included`, `integration_access` or `runtime_failure`. New categories may appear."
        },
        "title": {
          "type": "string",
          "description": "A few words, as the app titles the notice."
        },
        "message": {
          "type": "string",
          "description": "One or two plain sentences: what happened and how to get going again, the same words the app shows."
        },
        "resolution": {
          "type": "string",
          "enum": [
            "retry",
            "change_request",
            "person",
            "none"
          ],
          "description": "Who can get it going again. `retry`: send the same request again (sendSessionMessage, or create the Session again); nothing needs changing. `change_request`: edit the request or choose another model, then send it. `person`: only someone with access to the workspace or its accounts can fix it (a signed-out model account, credits, a plan, a connection's access); give them `message` and the `actions` link, and retry once they say it is fixed. `none`: a person stopped it on purpose."
        },
        "actions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "description": "The button's words in the app, for example `Reconnect` or `Open Billing`."
              },
              "url": {
                "type": "string",
                "description": "Where the fix is, in the Reason app."
              }
            },
            "required": [
              "label",
              "url"
            ]
          },
          "description": "Links to the fix in the Reason app; empty when there is nothing to open."
        }
      },
      "required": [
        "category",
        "title",
        "message",
        "resolution",
        "actions"
      ]
    },
    "error_class": {
      "description": "Stable runtime failure class when execution did not produce a task outcome. Runtime codes use the run_ prefix (for example run_error, run_timeout, run_cancelled) and cloud execution codes the cloud_ prefix (for example cloud_device_unavailable); since 2026-10 they replace the earlier runtime-internal and ara_cloud_ spellings, which the API no longer reports.",
      "type": [
        "string",
        "null"
      ]
    },
    "usage_limit_resume": {
      "description": "Present on GET: the pending automatic continuation after a connected model account's usage limit. Null when none is pending, including after Stop or newer input. A pending continuation does not guarantee provider capacity. Poll this field instead of repeatedly sending the same request.",
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "resumes_at": {
          "description": "When the provider's usage limit resets and Reason will try to continue automatically. Null means the provider supplied no reset time; the continuation waits for restored usage or a different model account.",
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      },
      "required": [
        "resumes_at"
      ]
    },
    "error_message": {
      "description": "Redacted persisted error preview, bounded to 1000 characters; null when unavailable.",
      "type": [
        "string",
        "null"
      ]
    },
    "failure_diagnostics": {
      "description": "Where and why the latest Attempt failed: the attribution its failure recorded when it ended the Attempt, else derived from the stored failure signature. An unknown stage remains null.",
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "failure_stage": {
          "description": "Execution stage where failure occurred.",
          "type": [
            "string",
            "null"
          ]
        },
        "reason_code": {
          "description": "Specific machine-readable reason code for the failure. Runtime and cloud execution codes use the run_ and cloud_ prefixes, as in error_class.",
          "type": [
            "string",
            "null"
          ]
        },
        "root_cause": {
          "description": "Root cause classification of the failure.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "failure_stage",
        "reason_code",
        "root_cause"
      ]
    },
    "failure_stage": {
      "description": "Execution stage where failure occurred.",
      "type": [
        "string",
        "null"
      ]
    },
    "reason_code": {
      "description": "Specific machine-readable reason code for the failure. Runtime and cloud execution codes use the run_ and cloud_ prefixes, as in error_class.",
      "type": [
        "string",
        "null"
      ]
    },
    "root_cause": {
      "description": "Root cause classification of the failure.",
      "type": [
        "string",
        "null"
      ]
    },
    "previous_attempt_failure": {
      "description": "The most recent failed Attempt of the current Turn before the current Attempt, so a failure stays readable after a retry replaced it (for example a cloud_device_unavailable start failure followed by a successful retry). The current Attempt's own failure is in error_class and failure_diagnostics; this is null when the current Attempt failed, no earlier Attempt of the Turn did, or the current run is not a Session Attempt (a resource transition or wake). Returned by getSession on a full read, or when `fields` names it; not on the Session list.",
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "attempt_id": {
          "type": "string",
          "description": "The failed Attempt's id."
        },
        "status": {
          "type": "string",
          "description": "The failed Attempt's public status (error)."
        },
        "error_class": {
          "description": "That Attempt's failure class, as in error_class.",
          "type": [
            "string",
            "null"
          ]
        },
        "failure_stage": {
          "description": "Execution stage where that Attempt failed.",
          "type": [
            "string",
            "null"
          ]
        },
        "reason_code": {
          "description": "That Attempt's reason code, as in reason_code.",
          "type": [
            "string",
            "null"
          ]
        },
        "root_cause": {
          "description": "That Attempt's root cause classification.",
          "type": [
            "string",
            "null"
          ]
        },
        "finished_at": {
          "description": "When that Attempt finished.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "attempt_id",
        "status",
        "error_class",
        "failure_stage",
        "reason_code",
        "root_cause",
        "finished_at"
      ]
    },
    "diagnostic_message": {
      "description": "Fixed public message selected from an allowlisted persisted error class, never error prose, prompts or tool output. Null when unknown.",
      "type": [
        "string",
        "null"
      ],
      "maxLength": 160
    },
    "duration_ms": {
      "description": "Execution time in milliseconds; null when not recorded.",
      "type": [
        "integer",
        "null"
      ]
    },
    "cost_usd": {
      "description": "Total model spend in USD across the session's turns. Null when usage was never reported.",
      "type": [
        "number",
        "null"
      ]
    },
    "usage": {
      "type": "object",
      "properties": {
        "input_tokens": {
          "description": "Model input tokens across the Session's turns.",
          "type": [
            "integer",
            "null"
          ]
        },
        "output_tokens": {
          "description": "Model output tokens across the Session's turns.",
          "type": [
            "integer",
            "null"
          ]
        },
        "total_tokens": {
          "description": "input_tokens plus output_tokens; null unless both are known.",
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "required": [
        "input_tokens",
        "output_tokens",
        "total_tokens"
      ],
      "description": "Token usage totals for the session. Fields are null for runs that predate usage persistence."
    },
    "context": {
      "type": "object",
      "properties": {
        "tokens": {
          "description": "Tokens in the model's context window after the latest turn.",
          "type": [
            "integer",
            "null"
          ]
        },
        "window": {
          "description": "The model's context window size.",
          "type": [
            "integer",
            "null"
          ]
        },
        "percent": {
          "description": "Context occupancy 0-100, rounded.",
          "type": [
            "integer",
            "null"
          ]
        },
        "compaction_threshold_tokens": {
          "description": "The context size at which the latest turn folded earlier turns into a summary, for the model it ran on: the Session's or workspace's `compaction.threshold_tokens` (at most what the model can hold), else Reason's recommendation. Recorded when a turn ends; absent before the first turn ends and for turns that predate it.",
          "type": [
            "integer",
            "null"
          ]
        },
        "compaction_threshold_source": {
          "description": "What set `compaction_threshold_tokens`: `session` (this Session's `compaction`), `workspace` (the workspace's `compaction` setting) or `recommended` (Reason's own threshold). Present with `compaction_threshold_tokens`.",
          "oneOf": [
            {
              "type": "string",
              "enum": [
                "recommended",
                "workspace",
                "session"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "tokens",
        "window",
        "percent"
      ],
      "description": "Live context occupancy after the latest turn (not billing throughput)."
    },
    "is_archived": {
      "type": "boolean",
      "description": "True when the Session is archived (archiveSession); listSessions hides it unless status is archived or all."
    },
    "session_type": {
      "type": "string",
      "enum": [
        "session",
        "sidechat",
        "subagent"
      ],
      "description": "Session, sidechat fork, or read-only subagent Session."
    },
    "source_session_id": {
      "description": "The fork source for a sidechat or spawning Session for a subagent; null for a normal Session.",
      "type": [
        "string",
        "null"
      ]
    },
    "read_only": {
      "type": "boolean",
      "description": "True only for subagent Sessions."
    },
    "repos": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Every repository currently attached to the session, as owner/name. Present on Retrieve a session only, and only when recorded."
    },
    "run": {
      "$ref": "#/$defs/SessionTurnRun"
    },
    "change_requests": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Pull request or merge request URL."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "completed",
              "retired"
            ],
            "description": "The Session's delivery record for this change request, not its live provider state: it stays active after the pull request merged or closed. Read the pull request itself for whether it is open."
          }
        },
        "required": [
          "url",
          "status"
        ]
      },
      "description": "Every change request the session opened, including ones in repositories other than `repo`. Present on Retrieve a session only, and only when recorded."
    }
  },
  "required": [
    "session_policy",
    "session_id",
    "status",
    "url",
    "created_at"
  ],
  "$defs": {
    "PlacementReceipt": {
      "type": "object",
      "properties": {
        "execution": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "known",
                "unknown",
                "unavailable"
              ]
            },
            "reason": {
              "type": "string"
            },
            "target": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "cloud",
                    "mac",
                    "headless",
                    "cli",
                    "worker"
                  ]
                },
                "computer_id": {
                  "type": "string"
                },
                "device_id": {
                  "type": "string"
                },
                "root_id": {
                  "type": "string"
                }
              },
              "required": [
                "kind"
              ]
            },
            "basis": {
              "type": "string",
              "enum": [
                "applied_placement",
                "transition_source",
                "retained_placement"
              ]
            }
          },
          "required": [
            "status",
            "reason"
          ],
          "description": "Observed Session placement, not launch intent, desktop origin or a requested destination. Known identifies a placement, not permission or a guarantee that a command can run."
        },
        "physical_control": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "known",
                "unknown",
                "unavailable"
              ]
            },
            "reason": {
              "type": "string"
            },
            "target": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "cloud",
                    "mac",
                    "headless",
                    "cli",
                    "worker"
                  ]
                },
                "computer_id": {
                  "type": "string"
                },
                "device_id": {
                  "type": "string"
                },
                "root_id": {
                  "type": "string"
                }
              },
              "required": [
                "kind"
              ]
            }
          },
          "required": [
            "status",
            "reason"
          ],
          "description": "Physical control can target a different computer for each operation. No default target is inferred from execution or desktop provenance."
        },
        "root_grant": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "known",
                "unknown",
                "unavailable"
              ]
            },
            "reason": {
              "type": "string"
            },
            "root_id": {
              "type": "string"
            }
          },
          "required": [
            "status",
            "reason"
          ],
          "description": "A known root id is not proof of a current grant. Operations reauthorize their exact root and actor."
        },
        "browser": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "known",
                "unknown",
                "unavailable"
              ]
            },
            "reason": {
              "type": "string"
            }
          },
          "required": [
            "status",
            "reason"
          ],
          "description": "Browser profile and signed-in identity are operation-specific. Unknown does not mean signed out or unavailable."
        },
        "computer": {
          "description": "Authorized inventory observation only; ready or live does not assert this Session is executing there.",
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "kind": {
              "type": "string",
              "enum": [
                "cloud",
                "mac",
                "cli",
                "worker"
              ]
            },
            "state": {
              "type": "string"
            },
            "live": {
              "type": "boolean"
            }
          },
          "required": [
            "id",
            "kind",
            "state",
            "live"
          ]
        }
      },
      "required": [
        "execution",
        "physical_control",
        "root_grant",
        "browser"
      ],
      "description": "Additive observational receipt. Unknown means this response cannot establish the fact; unavailable means there is affirmative evidence it is not currently usable. Never authorizes an operation. Absent on older servers and on list responses."
    },
    "SessionCheckIn": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The check-in's id; pass it as followupId to cancelSessionFollowup."
        },
        "next_run_at": {
          "type": "string",
          "description": "When it next fires, or its deadline when it waits for an event."
        },
        "every_minutes": {
          "description": "Repeat interval in minutes; null for a one-time check-in.",
          "type": [
            "number",
            "null"
          ]
        },
        "until": {
          "description": "When a repeating check-in stops; null when it has no end or does not repeat.",
          "type": [
            "string",
            "null"
          ]
        },
        "paused": {
          "type": "boolean",
          "description": "True while it is paused and does not fire."
        },
        "waits_for_device": {
          "type": "boolean",
          "description": "True when it fires once a Device becomes available rather than at a fixed time."
        },
        "waits_for_session": {
          "type": "boolean",
          "description": "True when it watches another Session: that Session's report cancels it."
        },
        "waits_for": {
          "description": "The event it waits for; null for a timed check-in.",
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "source": {
              "type": "string",
              "enum": [
                "slack",
                "github",
                "webhook",
                "web"
              ],
              "description": "Where the awaited event comes from."
            },
            "kind": {
              "type": "string",
              "enum": [
                "wait",
                "pr"
              ],
              "description": "pr for a pull request subscription, wait for any other event watch."
            },
            "keep_watching": {
              "type": "boolean",
              "description": "True when every matching event wakes the Session until the deadline, not only the first."
            }
          },
          "required": [
            "source",
            "kind",
            "keep_watching"
          ]
        }
      },
      "required": [
        "id",
        "next_run_at",
        "every_minutes",
        "until",
        "paused",
        "waits_for_device",
        "waits_for_session",
        "waits_for"
      ],
      "description": "A pending check-in. Notes, conditions, URLs, credentials and event bodies are deliberately excluded."
    },
    "SessionFollowUp": {
      "type": "object",
      "properties": {
        "waiting": {
          "type": "boolean",
          "description": "At least one enabled check-in is pending. Does not imply that the Session is idle or that a wake will execute successfully."
        },
        "pending_check_ins": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SessionCheckIn"
          },
          "description": "Pending check-ins, at most 100."
        },
        "pending_check_ins_has_more": {
          "type": "boolean",
          "description": "True when more than 100 check-ins are pending and the rest are left out."
        },
        "pr_subscription": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "armed",
                "ended",
                "skipped",
                "not_recorded"
              ],
              "description": "Any active watch means armed. Otherwise skipped means a persisted skipped attempt for a PR without a watch; ended means watches are recorded. Watch evidence takes precedence for the same PR. No record is not evidence of a skip."
            },
            "items": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/SessionPrSubscription"
              },
              "description": "The Session's pull request subscriptions, at most 100."
            },
            "has_more": {
              "type": "boolean",
              "description": "True when more than 100 subscriptions exist and the rest are left out."
            },
            "latest_attempts": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "The attempt receipt's id."
                  },
                  "repository": {
                    "type": "string",
                    "description": "The pull request's repository, owner/name."
                  },
                  "number": {
                    "type": "integer",
                    "description": "The pull request number."
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "armed",
                      "ended",
                      "skipped"
                    ],
                    "description": "What the attempt recorded for the subscription."
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "watch_active",
                      "subscription_ended",
                      "pending_without_watch",
                      "trigger_not_created",
                      "watch_not_active",
                      "subscription_failed"
                    ],
                    "description": "Why it recorded that status."
                  },
                  "observed_at": {
                    "type": "string",
                    "description": "When the attempt was recorded."
                  }
                },
                "required": [
                  "id",
                  "repository",
                  "number",
                  "status",
                  "reason",
                  "observed_at"
                ]
              },
              "description": "Newest recorded attempt per pull request within the latest 100 receipts. Historical observations, not current subscription state."
            },
            "attempts_has_more": {
              "type": "boolean",
              "description": "True when older receipts beyond the latest 100 were not read."
            }
          },
          "required": [
            "status",
            "items",
            "has_more",
            "latest_attempts",
            "attempts_has_more"
          ],
          "description": "Pull request subscriptions: the overall status, each subscription, and the latest recorded attempt per pull request."
        },
        "latest_wake": {
          "description": "Latest fired check-in and its recorded wake metadata, not proof an Attempt ran or a deployment completed. Null when none has fired.",
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "check_in_id": {
              "type": "string",
              "description": "The check-in that fired."
            },
            "recorded_at": {
              "type": "string",
              "description": "When the wake was recorded."
            },
            "cause": {
              "type": "string",
              "enum": [
                "events",
                "deadline",
                "scheduled",
                "not_recorded"
              ],
              "description": "What fired it: events (the awaited event arrived), deadline (it gave up waiting), scheduled (its time came) or not_recorded."
            },
            "source": {
              "description": "The awaited event's source; null for a timed check-in.",
              "oneOf": [
                {
                  "type": "string",
                  "enum": [
                    "slack",
                    "github",
                    "webhook",
                    "web"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "end_reason": {
              "description": "Why the watch ended at that wake; null when it did not end or no reason was recorded.",
              "oneOf": [
                {
                  "type": "string",
                  "enum": [
                    "merged",
                    "closed",
                    "wake_cap",
                    "repeat_failure",
                    "idle",
                    "cancelled"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "check_in_id",
            "recorded_at",
            "cause",
            "source",
            "end_reason"
          ]
        }
      },
      "required": [
        "waiting",
        "pending_check_ins",
        "pending_check_ins_has_more",
        "pr_subscription",
        "latest_wake"
      ],
      "description": "Read-only, bounded projection of durable Session follow-through. Does not infer deployment or successful completion."
    },
    "SessionMachine": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "name": {
          "type": "string"
        },
        "state": {
          "type": "string",
          "enum": [
            "waiting",
            "placed"
          ]
        },
        "queue_position": {
          "description": "Live attempts ahead in the Machine queue while waiting; null once placed.",
          "type": [
            "integer",
            "null"
          ]
        },
        "device_id": {
          "description": "Worker the attempt was placed on.",
          "type": [
            "string",
            "null"
          ],
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "enqueued_at": {
          "type": "string"
        },
        "placed_at": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "name",
        "state",
        "queue_position",
        "device_id",
        "enqueued_at",
        "placed_at"
      ],
      "description": "Present on GET for a Session attempt that targets a Machine: its queue state, live queue position while waiting, and the worker it was placed on."
    },
    "SessionPrSubscription": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The subscription's id."
        },
        "check_in_id": {
          "type": "string",
          "description": "The check-in that carries it; pass it as followupId to cancelSessionFollowup."
        },
        "repository": {
          "description": "The pull request's repository, owner/name; null when not recorded.",
          "type": [
            "string",
            "null"
          ]
        },
        "number": {
          "description": "The pull request number; null when not recorded.",
          "type": [
            "integer",
            "null"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "armed",
            "ended"
          ],
          "description": "armed while the subscription is active, ended once it stopped."
        },
        "paused": {
          "type": "boolean",
          "description": "True while it is paused."
        },
        "end_reason": {
          "description": "Persisted subscription stop reason. Null means no recognized reason was recorded; cancellation is not inferred.",
          "oneOf": [
            {
              "type": "string",
              "enum": [
                "merged",
                "closed",
                "wake_cap",
                "repeat_failure",
                "idle",
                "cancelled"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "check_in_id",
        "repository",
        "number",
        "status",
        "paused",
        "end_reason"
      ]
    },
    "SessionTurnRun": {
      "type": "object",
      "properties": {
        "requested_model": {
          "description": "The model the turn asked for: the one named on create or by the message that started the turn, else the Session's default. Null when none was recorded.",
          "type": [
            "string",
            "null"
          ]
        },
        "model": {
          "description": "The model the turn actually ran on. It differs from `requested_model` only when model rollover moved the turn to another model; `rollovers` lists each move.",
          "type": [
            "string",
            "null"
          ]
        },
        "requested_model_source_id": {
          "description": "The connected account the Session was set to start on: `model_source_id` on create, or the account agents_spawn or sessions_create gave a child (an id from listModels). Null when none was named and routing chose.",
          "type": [
            "string",
            "null"
          ]
        },
        "model_source_id": {
          "description": "The account that served the turn's model: `ara` for Reason credits, otherwise a connected account's id from listModels. Null when the turn ran without model routing and no account was pinned.",
          "type": [
            "string",
            "null"
          ]
        },
        "billing_mode": {
          "description": "Who paid for the turn's model: `ara_paid` is Reason credits, `customer_paid` a connected subscription or API key. Null when unrecorded.",
          "oneOf": [
            {
              "type": "string",
              "enum": [
                "ara_paid",
                "customer_paid"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "reasoning_effort": {
          "description": "The reasoning effort the turn ran at; null when none was set and the model's default applied. A Reason's own conversation turn reports the lower effort it coordinates at; the Sessions it starts keep the assigned one.",
          "type": [
            "string",
            "null"
          ]
        },
        "speed": {
          "type": "string",
          "enum": [
            "fast",
            "ultrafast",
            "standard"
          ],
          "description": "`fast` when the turn asked the provider for its priority tier (Fast mode), `ultrafast` for a ChatGPT subscription's Ultrafast tier, `standard` otherwise. Fast takes effect only where the provider offers a priority tier."
        },
        "rollovers": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "at": {
                "description": "When the turn moved.",
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "reason": {
                "description": "Why: `capacity` (a usage limit or no credit), `provider_unavailable` (an outage), `declined` (the model refused the request), or `recovered` (back on the earlier account). New values may appear.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "from_model": {
                "description": "The model before the move.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "from_model_source_id": {
                "description": "The account before the move.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "to_model": {
                "description": "The model after the move.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "to_model_source_id": {
                "description": "The account after the move: `ara` for Reason credits.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "to_billing_mode": {
                "description": "Who pays after the move.",
                "oneOf": [
                  {
                    "type": "string",
                    "enum": [
                      "ara_paid",
                      "customer_paid"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "at",
              "reason",
              "from_model",
              "from_model_source_id",
              "to_model",
              "to_model_source_id",
              "to_billing_mode"
            ]
          },
          "description": "Each move model rollover made during the turn, oldest first; empty when the turn stayed where it started. A move decided before the turn started (see `model_rolled_over` on create) shows as `model_source_id` differing from `requested_model_source_id` instead."
        }
      },
      "required": [
        "requested_model",
        "model",
        "requested_model_source_id",
        "model_source_id",
        "billing_mode",
        "reasoning_effort",
        "speed",
        "rollovers"
      ],
      "description": "What one turn asked for and what it actually ran on (model, account, billing, effort, speed) and any rollovers during it. On Retrieve a session it describes the latest turn; on each conversation reply (`kind: reply`), the turn that reply answers. Only ids and model names: never an account's label or credential."
    }
  }
}