{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://genai-security-project.github.io/agent-control-standard/schema/v0.1.0/hooks/subagent-stop.json",
  "title": "steps/subagentStop payload",
  "description": "Fires when an in-process subagent terminates. The envelope's metadata.session_id is the PARENT's session (the parent receives the subagent-stop notification on its own audit chain); the subagent's own session has by this point already emitted its sessionEnd with its own final_chain_hash. This hook lets the parent's audit chain reference the subagent's terminal state without merging the two chains. Not decision-eligible — the subagent has already terminated.",
  "type": "object",
  "required": ["subagent_session_id", "outcome", "final_chain_hash"],
  "properties": {
    "subagent_session_id": {
      "type": "string",
      "format": "uuid",
      "description": "session_id of the terminated subagent. Matches the subagent_session_id from the originating subagentStart."
    },
    "outcome": {
      "type": "string",
      "enum": ["completed", "failed", "cancelled", "timeout", "denied_at_spawn"],
      "description": "Terminal status. 'completed' = subagent returned normally. 'failed' = subagent errored. 'cancelled' = parent or external signal cancelled it. 'timeout' = subagent exceeded its timeout. 'denied_at_spawn' = Guardian denied the original subagentStart; this stop is recorded for audit symmetry even though no subagent ran."
    },
    "final_chain_hash": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "The subagent's final SessionContext chain_hash at sessionEnd. Lets parent-side audit replay verify the subagent's chain integrity without the parent maintaining a copy of it."
    },
    "summary": {
      "type": "object",
      "description": "Optional value the subagent returned to the parent. Provenance: origin='agent_generated' and derived_from = the subagent's response lineage. The summary's content becomes data the parent can act on; its effective trust classification is computed by the parent-side Guardian against local policy from the lineage's origins, and MUST not exceed the minimum effective trust of the lineage (monotonicity). v0.1 does not carry a trust field on the wire — see §7.1.",
      "required": ["value", "provenance"],
      "properties": {
        "value": {},
        "provenance": { "$ref": "../provenance.json" }
      }
    },
    "subagent_step_count": {
      "type": "integer",
      "minimum": 0,
      "description": "Optional. Total steps the subagent executed. Useful for resource-accounting policies."
    }
  }
}
