replace_function
Rewrites an entire function or method (decorators, signature, and body) by supplying complete new source for its AST span, preserving indentation and surrounding shared-line code.
Instructions
Replace a whole symbol (decorators, signature and body) with new content.
The replaced span is what read_symbol returns: decorators, a JS/TS
export, a C++ template <...> header and code that only wraps the
symbol are part of it, so keep them in content. read_symbol's text,
edited or not, goes in as it is, and may become several members;
content written from column 0 is re-indented to the symbol's level. A
symbol that shares a line with other code has only its own text
replaced. For one name of int a, b; the content must keep the others.
Refused in JSON, YAML and TOML files (use replace_value).
Use this when: rewriting a symbol top to bottom (name, parameters and body). Don't use this when: only the body changes (replace_function_body), only the signature (replace_signature), or a few lines (replace_in_body).
Example: target="LRUCache.get" content='def get(self, key, default=None):\n return self.items.get(key, default)'
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file_path": "<file_path>",
"target": "<target>",
"content": "<content>"
},
"name": "replace_function"
}
}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)'). | |
| content | Yes | Complete new source of the symbol, decorators included, in read_symbol's shape or written from column 0. | |
| file_path | Yes | Absolute path to the source or config file. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |