Как Claude Code с Opus 5.5 читает файлы, вызывает tools и возвращает JSON? 2026 strict Tools и Structured Output
Около ноября 2026 Structured Outputs вышли в GA на Opus 5.5, а Claude Code получил более сильный Plan Mode (редактируемый plan.md) на той же модели. Инженерное разделение прежнее: чтение — JSON tool_use, правки репо выполняет хост, сводки для UI/CI — output_config.format — не смешивайте три объекта в один markdown.
Перед чтением
| Фаза | Claude Code / API | JSON хоста |
|---|---|---|
| Чтение репо | Read / Glob / Grep tool_use.input | file_path, аудит offset/limit |
| Правки и запуск | Edit / Write / Bash; strict-параметры | ворота, cwd, разрешённые roots |
| Структурированная поставка | output_config.format json_schema | deliverable_schema, risk, next_tool |
| Plan Mode | Человек правит plan.md, затем выполнение | plan_path, turn, plan_mode |
| Длинные задачи | По-прежнему Messages + цикл tools | Статья про Compaction — не здесь |
Факты на 2026-11-05: Anthropic Structured Outputs / strict tool use, Claude Code Plan Mode с Opus 5.5. Пути и toolu_read_01 вымышлены.
Сначала Read, затем strict tools, json_schema для deliverables
Типичный цикл Claude Code на Opus 5.5 делится на три JSON-контракта:
- Наблюдение: модель шлёт
Read/Greptool_use; хост возвращает фрагменты или hits вtool_result— не «притворное чтение». - Исполнение: для replay-harness ставьте
strict: trueна tools, чтобыinputпроходилinput_schema; Claude Code оборачивает те же формы в продукте. - Поставка: дашборды, шаблоны PR или CI gates используют
output_config.format.type: json_schema, отдельно от args tool — Structured Output это что Claude говорит; strict это как вызываются функции.
Ввод по продукту: Ввод Coding Agent. Messages Opus 5.5 и effort: Opus 5.5 tool JSON. Compaction и checklist state: state длинной задачи — эта статья только про чтение + структурированную поставку.
Блок Read, strict tools, Structured Output, turn хоста
1. Read tool_use. На Opus 5.5 по-прежнему content blocks; обычный первый шаг в Claude Code:
{
"type": "tool_use",
"id": "toolu_read_01",
"name": "Read",
"input": {
"file_path": "src/orders/lookup.ts",
"offset": 1,
"limit": 120
}
}
2. Запись tool_result. Хост добавляет номера строк и обрезает; модель дальше видит только эту строку:
{
"type": "tool_result",
"tool_use_id": "toolu_read_01",
"content": " 1|export function lookupOrder(id: string) {\n 2| // TODO: validate A-1042 pattern\n 3| return fetch(`/api/orders/${id}`);\n 4|}"
}
3. Таблица strict tools (Messages). Зеркало Claude Code для offline replay или compliance:
{
"model": "claude-opus-5-5",
"max_tokens": 8192,
"tools": [
{
"name": "Read",
"description": "Read a slice of a file. Paths must stay under the workspace root.",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"file_path": { "type": "string" },
"offset": { "type": "integer", "minimum": 1 },
"limit": { "type": "integer", "minimum": 1, "maximum": 500 }
},
"required": ["file_path"],
"additionalProperties": false
}
},
{
"name": "Grep",
"description": "Search the repo with ripgrep.",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"pattern": { "type": "string" },
"path": { "type": "string" },
"glob": { "type": "string" }
},
"required": ["pattern"],
"additionalProperties": false
}
}
],
"messages": [{
"role": "user",
"content": "Find where order A-1042 is validated before calling lookup."
}]
}
4. Структурированный deliverable. Тот же или следующий request; поля для UI/gates:
{
"model": "claude-opus-5-5",
"max_tokens": 4096,
"tools": [{ "name": "Read", "strict": true, "input_schema": { "type": "object", "properties": { "file_path": { "type": "string" } }, "required": ["file_path"], "additionalProperties": false } }],
"output_config": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"order_id": { "type": "string", "pattern": "^[A-Z]-\\d{4}$" },
"files_touched": { "type": "array", "items": { "type": "string" } },
"risk": { "type": "string", "enum": ["low", "medium", "high"] },
"next_tool": { "type": "string", "enum": ["Read", "Edit", "Bash", "none"] }
},
"required": ["order_id", "files_touched", "risk", "next_tool"],
"additionalProperties": false
}
}
},
"messages": []
}
5. Turn хоста (иллюстрация). Plan Mode и версия deliverable в state для diff сессии:
{
"session_id": "cc_sess_demo_01",
"model": "claude-opus-5-5",
"plan_mode": true,
"plan_path": ".claude/plan.md",
"turn": 3,
"last_blocks": ["tool_use:Read", "tool_result", "tool_use:Grep"],
"deliverable_schema": "task_summary_v1",
"awaiting": "tool_result"
}
Три роли JSON
Отделение chat markdown от машинных объектов упрощает review:
| Объект | Кто создаёт | Типичные поля |
|---|---|---|
| tool_use / tool_result | Модель предлагает, хост исполняет | name, input, tool_use_id |
| strict input_schema | Constrained sampling API | additionalProperties: false |
| output_config.format | Финальный текстовый блок | order_id, risk, next_tool |
| plan.md | Plan Mode, правка человеком | Список шагов — не args tool |
Bash / Edit через permission gates; Read свободнее, но должен оставаться в workspace roots. См. права.
Пять шагов с вымышленным заказом A-1042
Прогон в staging перед prod-репо:
- Сначала только Read + Grep. Найти логику валидации; без Bash на шаге один.
- Логировать tool_use / tool_result. Выравнивать ids; last_blocks в state.
- Edit только когда нужно. Пути должны быть в allowlist.
- Поставка через json_schema. risk / next_tool для человека или CI — не копировать secrets из tool_result.
- Plan Mode: сначала plan.md. Человек правит шаги, затем auto; plan_path в state для diff.
Все пять на JSON-объектах — иначе сессии Claude Code не replayable.
Смотреть трассы, не prose
Structured Output Opus 5.5 снижает parse errors; не заменяет review прав:
- форматировать для messages; проверка Schema для strict и deliverable schemas.
- JSONPath для путей вроде
$.content[?(@.type=='tool_use')].input.file_path. - JSON Diff state вокруг Plan Mode; убедиться, что deliverable_schema не потерян.
- Structured order_id должен совпадать с цепочкой tool (A-1042).
- JSONSort локально в браузере — не загружать реальные репо или ключи.
Deliverable JSON должен валидироваться сам по себе — это structured output, не pretty print.
Частые ошибки
- Считать Structured Output args tool. format формирует текст ответа; Edit всё ещё через tool_use.
- Edit до Read. Opus 5.5 правит агрессивно — хост должен enforce read-first.
- strict на половине tool surface. Read strict, Edit loose — audit ломается.
- Смешивать plan.md и deliverable schema. plan для людей; schema для программ.
- Неограниченные логи tool_result. Всё ещё JSON-строка; format, затем усечь поля отображения.
- Переписывать Coding Agent 101. См. вводную статью; здесь только Opus 5.5 read/tools/structured.
FAQ
Нужен ли strict на встроенных tools Claude Code?
Терминальный продукт оборачивает исполнение и подтверждения. Для offline replay, compliance или своего harness зеркалируйте input_schema на Messages и включите strict.
Structured Output и strict tools в одном request?
Да. Anthropic документирует их как дополняющие: params tool vs финальный json_schema reply.
plan.md — это JSON?
Нет — Markdown. Машиночитаемый прогресс — в deliverable schema или JSON state хоста.
Какой размер Read limit?
Политика хоста. Пример cap 500 строк против огромного tool_result; пагинация больших файлов.
Связь с новостями Gemini structured output?
Тот же заголовок «schema-constrained sampling»; Claude Code остаётся на Messages + strict + output_config. Cross-vendor: статья Opus vs Astra — не здесь.
Вывод
С Claude Code на Opus 5.5 чтение — JSON tool_use, безопасные правки — permissions + strict tools, вывод для систем — output_config.format. Plan Mode держит планы человеческими; Structured Output держит deliverables привязанными к schema.
Модель только заполняет JSON; диск, shells и validation schema — у хоста. Сделайте A-1042 replayable перед full auto.
Дальше
- Claude Code и цепочки tools GPT Agent Ввод Coding Agent и JSON-цикл
- Claude Opus 5.5 и JSON tools Messages, effort, tool_use
- Opus 5.5 длинная задача JSON State Compaction, checklist
- Модель прав Coding Agent Shell, Git, filesystem
- Все статьи Ещё про JSON и AI-разработку
Журнал: Первая публикация