{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.connectsoft.ai/reference/schemas/agent-task-contract.schema.json",
  "title": "AgentTaskContract (agent-task-contract-v1)",
  "description": "What an agent receives for one step attempt: the task, the pinned snapshot references, the context snapshot, the tools it may call with their side-effect classes, limits and the expected output descriptor. Replaces the 2025 task/workflow-instance contract.",
  "type": "object",
  "required": ["taskId", "runId", "stepId", "attemptId", "agentId", "snapshotId", "objective", "inputs", "allowedTools", "expectedOutput", "limits"],
  "additionalProperties": false,
  "properties": {
    "taskId": { "type": "string", "format": "uuid" },
    "runId": { "type": "string", "format": "uuid" }, "stepId": { "type": "string", "format": "uuid" }, "attemptId": { "type": "string", "format": "uuid" },
    "agentId": { "type": "string" }, "agentVersion": { "type": "string" }, "skillIds": { "type": "array", "items": { "type": "string" } },
    "snapshotId": { "type": "string", "format": "uuid" },
    "objective": { "type": "string" },
    "acceptanceCriteria": { "type": "array", "items": { "type": "string" } },
    "inputs": { "type": "array", "items": { "type": "object", "required": ["name", "descriptor", "ref"], "properties": { "name": { "type": "string" }, "descriptor": { "type": "string" }, "ref": { "type": "string", "description": "Artifact or context reference." } } } },
    "contextSnapshotId": { "type": "string", "format": "uuid" },
    "allowedTools": { "type": "array", "items": { "type": "object", "required": ["toolId", "sideEffectClass", "approval"], "properties": { "toolId": { "type": "string" }, "sideEffectClass": { "type": "string" }, "approval": { "enum": ["autonomous", "approval"] } } } },
    "modelProfileId": { "type": "string" },
    "expectedOutput": { "type": "object", "required": ["descriptor"], "properties": { "descriptor": { "type": "string" }, "schemaRef": { "type": "string" }, "validation": { "type": "array", "items": { "type": "string" } } } },
    "limits": { "type": "object", "properties": { "maxTokens": { "type": "integer" }, "maxCostUsd": { "type": "number" }, "deadline": { "type": "string", "format": "date-time" }, "maxToolCalls": { "type": "integer" } } },
    "previousAttempt": { "type": "object", "properties": { "attemptId": { "type": "string" }, "failureClass": { "type": "string" }, "feedbackRef": { "type": "string" } } }
  }
}
