Tencent/WeKnora · error
old_string and new_string are identical; no change would be
Error message
old_string and new_string are identical; no change would be made
What it means
applySandboxEdit in internal/agent/tools/sandbox_edit.go validates a file-edit request before applying it. It throws this error when the caller passes an edit where old_string and newString are byte-for-byte identical, which would be a no-op. The tool rejects it early so the agent/user notices the mistake instead of silently doing nothing.
Source
Thrown at internal/agent/tools/sandbox_edit.go:281
"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, nil
}
View on GitHub (pinned to 988cbb0330)
Solutions
- Re-read the current file content and diff it against your intended final state to see what actually still needs changing.
- Make newString genuinely different from oldString, or skip the edit entirely if the file already has the desired content.
- If many arguments were passed positionally, verify oldString and newString weren't swapped or duplicated.
Example fix
// before
applySandboxEdit(content, oldString, oldString, false)
// after
if oldString == newString {
return content // no-op; skip edit
}
newContent, _, err := applySandboxEdit(content, oldString, newString, false) Defensive patterns
Strategy: validation
Validate before calling
if oldString == newString {
return fmt.Errorf("skipping edit: old_string equals new_string")
} Try / catch
newContent, n, err := applySandboxEdit(content, oldString, newString, replaceAll)
if err != nil && strings.Contains(err.Error(), "identical") {
// treat as no-op: re-read file and confirm desired state already present
return content, nil
} Prevention
- Re-read the file after every edit before constructing the next one.
- Compare oldString vs newString before calling and skip no-op edits.
- Track which edits have already been applied to avoid resending them.
When it happens
Trigger: Calling the sandbox edit tool (via Execute) with old_string equal to new_string, e.g. retrying an edit after it already succeeded so the target text now equals the replacement, or copy-pasting the same block into both fields.
Common situations: An LLM agent re-sends a previously applied edit; a developer constructs an edit programmatically with the same variable for both arguments; whitespace-only 'changes' that turn out identical; retry loops without re-reading the file.
Related errors
- model ID cannot be empty
- unknown credential field:
- member_limit must be >= 0
- cannot request upgrade to same or lower role
- E2B timeout must be at least one second
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/8e575138d51cadd2.
Report an issue: GitHub.