patch_doc
Replace one exact text match in a document without resending the whole file. Ideal for small edits to large files, rejecting zero or multiple matches instead of guessing.
Instructions
Replace one exact substring in a document (str_replace semantics) without resending the whole file. THE PREFERRED WAY TO MAKE SMALL EDITS to large docs like STATE.md. old_str must match EXACTLY ONCE - zero or multiple matches are rejected rather than guessed. Pass new_str as an empty string to delete. Same versioning, archiving, and sha256 read-back as write_doc.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| edits | No | Several replacements in one revision. Each old_str must match the current text exactly once. Applied together, so a failed edit writes nothing. | |
| doc_id | Yes | ||
| origin | No | Required when a board edit adds a row id. Names the session, chat or drop the row came from. | |
| reason | Yes | Required, at least 10 characters. A removed or closed board row says why. | |
| source | No | Source tag - which host produced this write. One name on every write since 2026-09-27. | |
| new_str | No | Replacement text. Empty string deletes the matched text. | |
| old_str | No | Exact text to replace. Must occur exactly once in the current text. Omit when `edits` is set. | |
| exchange | No | The exchange (turn) this write belongs to, counting from 1. A write for exchange n while exchange n-1 was never appended is refused by the session graph until n-1 is appended. | |
| session_id | No | Transcript session id. The floor is measured from the size when this session first touched the document. | |
| updated_by | No | Alias of `source` (the older name, kept one release). Prefer `source`. | |
| expected_version | No | Optional optimistic-concurrency guard. |