> ## Documentation Index
> Fetch the complete documentation index at: https://openclaw.veiseule.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Công cụ apply_patch

# công cụ apply\_patch

Apply file changes using a structured patch format. This is ideal for multi-file
or multi-hunk edits where a single `edit` call would be brittle.

Công cụ chấp nhận một chuỗi `input` duy nhất, bao bọc một hoặc nhiều thao tác trên tệp:

```
*** Begin Patch
*** Add File: path/to/file.txt
+line 1
+line 2
*** Update File: src/app.ts
@@
-old line
+new line
*** Delete File: obsolete.txt
*** End Patch
```

## Tham số

* `input` (bắt buộc): Toàn bộ nội dung bản vá, bao gồm `*** Begin Patch` và `*** End Patch`.

## Ghi chú

* Đường dẫn được phân giải tương đối so với thư mục gốc của workspace.
* `tools.exec.applyPatch.workspaceOnly` mặc định là `true` (giới hạn trong workspace). Chỉ đặt thành `false` nếu bạn cố ý muốn `apply_patch` ghi/xóa bên ngoài thư mục workspace.
* `*** End of File` đánh dấu chèn chỉ-EOF khi cần.
* `*** End of File` đánh dấu chèn chỉ-EOF khi cần.
* Experimental and disabled by default. Enable with `tools.exec.applyPatch.enabled`.
* OpenAI-only (including OpenAI Codex). Optionally gate by model via
  `tools.exec.applyPatch.allowModels`.
* Cấu hình chỉ nằm dưới `tools.exec`.

## Ví dụ

```json theme={"theme":{"light":"min-light","dark":"min-dark"}}
{
  "tool": "apply_patch",
  "input": "*** Begin Patch\n*** Update File: src/index.ts\n@@\n-const foo = 1\n+const foo = 2\n*** End Patch"
}
```
