patch_kb_doc
Replace a specific text span in a knowledge-base document to patch content or name without rewriting the entire body.
Instructions
Performs string replacements in a knowledge-base document — same idea as Cursor StrReplace for files. USE THIS instead of update_kb_doc when the document body is large and you only need to change a specific section. Workflow: get_kb_doc → copy the span into old_string (include enough surrounding context to make it unique) → new_string is the replacement → this tool patches content (or name) and PATCHes the KB doc. Prefer an exact copy from get_kb_doc; minor whitespace/line-ending drift is tolerated as a fallback. Prefer this over rewriting the entire content field. Only use replace_all=true when you intentionally want every occurrence changed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docId | Yes | The KB document ID | |
| field | No | Which KB field to patch. Default content (document body). | |
| agentId | Yes | The agent ID | |
| new_string | Yes | Replacement text for the matched span. Use an empty string to delete the matched text. | |
| old_string | Yes | Text to find in the KB field. Prefer an exact copy from get_kb_doc; minor whitespace/line-ending drift is tolerated. Include surrounding context so the match is unique unless replace_all is true. | |
| replace_all | No | If false (default), fails when old_string matches more than once. If true, replaces every occurrence. |