AI-разработка

Как настроить permission для AI Agent в 2026? Schema, sandbox, tool policy и четырёхслойная JSON-модель

Около 16 мин

Permission — не один allow-лист. В 2026 для AI Agent обычно четыре JSON-слоя: Schema, tool permission, runtime sandbox, identity + audit. Продолжение intro-поста, не повтор OpenShell L7.

Кратко

Слой Факт 2026 В JSON
① Schema Host валидирует input до execute pattern, additionalProperties
② Tool policy Claude permissions; managed always_*; SDK mode allow, ask, deny
③ Sandbox Bash session; OpenShell per-binary egress per_binary, sandbox_id
④ Audit Вердикт по слоям layers.*
Harness Отдельные файлы schema/manifest/policy/audit messages vs state

Факты на 2026-11-07. A-1042 и sb_agent_demo_7f3a вымышлены.

Permission agent = Schema + policy + sandbox + audit

Intro — allow/ask/deny в сессии (harness). Полный стек 2026 — четыре слоя:

  • Schema: схема на tool, A-1042.
  • Policy: deny→ask→allow; managed sub-agents.
  • Sandbox: Bash + OpenShell network_policies.
  • Audit: agent.identity.

База: модель permission coding agent. OpenShell: runtime sandbox OpenShell. Harness: harness agent и JSON state. Schema: зачем AI JSON Schema. Agents API: OpenAI Agents API и JSON Schema.

Schema первым, audit снаружи

Четыре JSON-поверхности; Landlock при создании sandbox; chat Allow не заменяет регистрацию binary.

Один JSON на слой

1. Schema input.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "lookup_order_input",
  "type": "object",
  "additionalProperties": false,
  "required": ["order_id"],
  "properties": {
    "order_id": {
      "type": "string",
      "pattern": "^[A-Z]-[0-9]{4}$",
      "description": "Warehouse order id, e.g. A-1042"
    },
    "include_line_items": {
      "type": "boolean",
      "default": false
    }
  }
}

2. Permission manifest.

{
  "version": "2026-09",
  "permission_mode": "default",
  "eval_order": ["deny", "ask", "allow"],
  "managed_agents": {
    "Explore": "always_allow",
    "Plan": "always_ask",
    "BashReview": "auto"
  },
  "tools": {
    "Bash": {
      "default": "ask",
      "sandbox": "workspace-write",
      "rules": [
        { "pattern": "git status", "decision": "allow" },
        { "pattern": "git diff *", "decision": "allow" },
        { "pattern": "git push *", "decision": "deny" }
      ]
    },
    "Edit": { "default": "ask" },
    "mcp__orders": { "default": "allow" }
  },
  "sdk": {
    "permission_mode": "acceptEdits",
    "bypass_permissions": false
  }
}

3. network_policies.

{
  "network_policies_version": "2026.11",
  "hot_reload": true,
  "per_binary": [
    {
      "binary": "/opt/agent/runner",
      "egress_default": "deny",
      "allow": [
        { "host": "orders.example.com", "port": 443, "path_prefix": "/mcp" }
      ]
    },
    {
      "binary": "/usr/bin/python3",
      "egress_default": "deny",
      "allow": [
        { "host": "pypi.org", "port": 443 }
      ]
    }
  ],
  "landlock_note": "filesystem_policy applies at sandbox create, not via this file"
}

4. Audit event.

{
  "event_id": "evt_9c2f8a01",
  "ts": "2026-11-07T06:22:11Z",
  "agent": {
    "id": "agt_codereview_v3",
    "session_id": "sess_7f3a",
    "identity": "service-account:ci-bot",
    "sandbox_id": "sb_agent_demo_7f3a",
    "supervisor": "openshell-sandbox"
  },
  "layers": {
    "schema": { "tool": "lookup_order", "valid": true, "validator": "draft-2020-12" },
    "permission": { "decision": "allow", "matched": "mcp__orders", "rule": "default" },
    "sandbox": { "binary": "/opt/agent/runner", "egress": "allowed" }
  },
  "tool_use_id": "toolu_order_01",
  "input_digest": "sha256:8f3e…",
  "outcome": "executed"
}

Слои не заменяют друг друга

Типичные дыры при одном слое:

Слой Что держит Только он
JSON Schema Форма arguments git push / egress
Tool permission Имена tools, Bash IDE Allow ≠ binary
Runtime sandbox Процесс, Landlock Без order_id pattern
Audit / identity Кто, session, sandbox Нет доказательств

модель permission coding agent, runtime sandbox OpenShell, зачем AI JSON Schema — слои складываются.

Пять шагов

Staging с A-1042:

  1. Schema в CI.
  2. Manifest в репо.
  3. Разделить session и runtime sandbox.
  4. Append-only audit.
  5. Отказ по четырём слоям.

Diffable JSON для диагностики.

Четыре JSON

tool_use + manifest + policies + audit.

Выравнивание показывает причину.

Типичные ошибки

  • Только Schema.
  • bypass_permissions в проде.
  • Allow без OpenShell.
  • managed always_allow.
  • Audit без layers.
  • Вместо OpenShell L7.

FAQ

Отличие от ai-coding-agent-permissions-json?

Intro vs full stack.

Schema на модели?

Только host.

Bash или OpenShell?

Оба; JSON раздельно.

managed auto?

Между ask и allow.

Хранение audit?

Compliance; маскировать PII.

Итог

Стабильный control — четыре JSON-слоя.

Сначала intro permissions; OpenShell L7 отдельно.

Читать дальше

Изменения: Первая публикация