Edit

A built-in definition supplied to the request when the tools option was omitted.

Captured description

Performs exact string replacement in a file.

  • You must Read the file in this conversation before editing, or the call will fail.
  • old_string must match the file exactly, including indentation, and be unique — the edit fails otherwise. Strip the Read line prefix (line number + tab) before matching.
  • replace_all: true replaces every occurrence instead.

Input schema

JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "file_path": {
      "description": "The absolute path to the file to modify",
      "type": "string"
    },
    "old_string": {
      "description": "The text to replace",
      "type": "string"
    },
    "new_string": {
      "description": "The text to replace it with (must be different from old_string)",
      "type": "string"
    },
    "replace_all": {
      "description": "Replace all occurrences of old_string (default false)",
      "default": false,
      "type": "boolean"
    }
  },
  "required": [
    "file_path",
    "old_string",
    "new_string"
  ],
  "additionalProperties": false
}

Independent estimate

~329 tokens

The captured tool object was counted against the common baseline. This value supports comparison and is not additive.