Tencent/WeKnora · error
old_string is required; copy the exact text to change, inclu
Error message
old_string is required; copy the exact text to change, including whitespace
What it means
applySandboxEdit precondition guard: old_string is empty, so there is no text to locate and replace; the edit helper refuses to run because an empty search string would match everywhere and corrupt the file.
Source
Thrown at internal/agent/tools/sandbox_edit.go:278
"path": clean,
"root": rootDir,
"name": path.Base(clean),
"size": len(content),
"replacements": replacements,
},
}, nil
}
// Cleanup releases any resources.
func (t *EditSandboxFileTool) Cleanup(ctx context.Context) error {
return nil
}
// applySandboxEdit performs an exact string replacement. replaceAll=false
// requires a unique match.
func applySandboxEdit(content, oldString, newString string, replaceAll bool) (string, int, error) {
if oldString == "" {
return "", 0, fmt.Errorf("old_string is required; copy the exact text to change, including whitespace")
}
if oldString == newString {
return "", 0, fmt.Errorf("old_string and new_string are identical; no change would be made")
}
n := strings.Count(content, oldString)
if n == 0 {
return "", 0, fmt.Errorf("old_string was not found in the file. Copy the exact text (including whitespace) from the file")
}
if n > 1 && !replaceAll {
return "", 0, fmt.Errorf(
"old_string matched %d times. Include more surrounding context so it is unique, or set replace_all=true",
n,
)
}
if replaceAll {
return strings.ReplaceAll(content, oldString, newString), n, nil
}
return strings.Replace(content, oldString, newString, 1), 1, nilView on GitHub (pinned to 988cbb0330)
Solutions
- Copy the exact target text (including whitespace) into old_string
- Validate old_string is non-empty before invoking the edit tool
- For whole-content rewrites use a write tool instead of an edit
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/agent/tools/sandbox_edit.go:278 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/213fa900bbe8bf31.
Report an issue: GitHub.