SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
14 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
2.7 KB · 40 lines markdown
Rendered Raw Blame History
1# Apply patch (`type: "apply_patch"`)23**Status:** DOCUMENTED · LIVE_VERIFIED (2026-09-18, `gpt-5.4-nano`; streaming revealed undocumented events)4**Sources:** https://developers.openai.com/api/docs/guides/tools-apply-patch · openapi-master.yaml `ApplyPatchToolParam`, `ApplyPatchToolCall`, `ApplyPatchCreateFileOperation|UpdateFileOperation|DeleteFileOperation`, `ApplyPatchToolCallOutputItemParam`, `SpecificApplyPatchParam`5**Last verified:** 2026-09-1867## Definition89`{"type":"apply_patch"}` (+ optional `allowed_callers`). No input schema: the model knows the `operation` format. `tool_choice: {"type":"apply_patch"}` forces a patch (verified).1011## Items1213Output `apply_patch_call`:14```json15{"id":"apc_…","type":"apply_patch_call","status":"completed","call_id":"call_…","operation":{"type":"create_file","path":"hello.txt","diff":"+OK\n"}}16```17`operation.type` ∈ `create_file {path, diff}` · `update_file {path, diff}` · `delete_file {path}`; `status` ∈ `in_progress|completed`.18Input `apply_patch_call_output`: `{"type":"apply_patch_call_output","call_id":"call_…","status":"completed"|"failed","output":"<message>"}` — on failure (file not found, path rejected) return `failed` + a helpful message so the model can re-plan.1920## Streaming — LIVE_DISCOVERED events2122`response.output_item.added` → **`response.apply_patch_call_operation_diff.delta`** (`delta`, `item_id`, `output_index`, `obfuscation`, `sequence_number`) → **`response.apply_patch_call_operation_diff.done`** (`diff`) → `response.output_item.done`. These two event types are **absent from the OpenAPI `ResponseStreamEvent` union and from the streaming-events reference page** at retrieval time; recorded in `generated/fragments/streaming-events/openai-tools.json` with status `LIVE_DISCOVERED`.2324## Models / availability2526Guide table: Responses API only (not Chat Completions/Assistants); GPT-5.5, GPT-5.4, GPT-5.2, GPT-5.1. Model pages additionally list `apply_patch` for gpt-5.4-mini, gpt-5.4-nano (verified), gpt-5.4-pro, gpt-5.6-*, gpt-6-astra, daybreak-*.2728## Guidance (docs)2930Give the model file context (inline snapshot or the `shell` tool for discovery); keep `tools=[{"type":"apply_patch"}]` in follow-ups; validate paths (no traversal, allowed dirs only); run tests/linters and feed failures back; nudge toward minimal edits.3132## Live evidence3334| Probe | Status | Result |35|---|---|---|36| forced `apply_patch`, "create hello.txt containing OK" | 200 | `create_file hello.txt` diff `+OK\n` (nothing applied by us) |37| stream | 200 | 9 events incl. the two undocumented `apply_patch_call_operation_diff.*` |3839Examples: `examples/openai/tools/apply-patch/` (dry-run validation). Test: `test_shell_local_and_apply_patch_proposals`.40