{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.invalid/schemas/agent-config-v1",
  "title": "Local teaching Agent configuration",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "name",
    "max_steps",
    "timeout_seconds",
    "tools"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[a-z][a-z0-9-]*$"
    },
    "max_steps": {
      "type": "integer",
      "minimum": 1,
      "maximum": 20
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 1,
      "maximum": 120
    },
    "tools": {
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
        "$ref": "#/$defs/tool"
      }
    }
  },
  "$defs": {
    "tool": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "mode",
        "requires_approval"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]{0,63}$"
        },
        "mode": {
          "enum": [
            "read",
            "write"
          ]
        },
        "requires_approval": {
          "type": "boolean"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "mode": {
                "const": "write"
              }
            },
            "required": [
              "mode"
            ]
          },
          "then": {
            "properties": {
              "requires_approval": {
                "const": true
              }
            }
          }
        }
      ]
    }
  }
}

