replace_in_body
Replace a snippet within one function body, scoped so text elsewhere never matches; ambiguous or missing snippets are rejected to prevent unintended edits.
Instructions
Replace a snippet inside a function's body; the match is scoped to that body, so text elsewhere in the file never matches. A snippet found nowhere is refused; one found in several places is refused with their line numbers: add context.
Use this when: changing one statement or block in a long body. Don't use this when: replacing the whole body (replace_function_body), or editing a sub-expression no unique snippet can locate (your normal edit tool).
Example (a block written without its indentation): target="handle" old_snippet="if retry:\n wait()" new_snippet="if retry:\n backoff()\n wait()"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Function or method name as list_symbols lists it, dotted for nesting ('LRUCache.get'); overloads take parameter types ('A.m(int)'). | |
| file_path | Yes | Absolute path to the source or config file. | |
| new_snippet | Yes | Replacement text; its lines move with the match's indentation, keeping their relative indentation, and text already at the file's indentation goes in as written. '' deletes the snippet. | |
| old_snippet | Yes | Text in the target's body, matching one place: its exact text at token boundaries, or else whole lines with the same indentation added to or removed from each. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |