FoundationAgents/OpenManus · error · ToolError

No edit history found for {path}.

Error message

No edit history found for {path}.

What it means

Thrown by str_replace_editor's undo_edit when the per-file edit history stack (self._file_history[path]) is empty. The tool keeps an in-memory history keyed by path; if no prior edit was recorded for that exact path in this session/process, there is nothing to revert.

Source

Thrown at app/tool/str_replace_editor.py:399

        self._file_history[path].append(file_text)

        # Prepare success message
        success_msg = f"The file {path} has been edited. "
        success_msg += self._make_output(
            snippet,
            "a snippet of the edited file",
            max(1, insert_line - SNIPPET_LINES + 1),
        )
        success_msg += "Review the changes and make sure they are as expected (correct indentation, no duplicate lines, etc). Edit the file again if necessary."

        return CLIResult(output=success_msg)

    async def undo_edit(
        self, path: PathLike, operator: FileOperator = None
    ) -> CLIResult:
        """Revert the last edit made to a file."""
        if not self._file_history[path]:
            raise ToolError(f"No edit history found for {path}.")

        old_text = self._file_history[path].pop()
        await operator.write_file(path, old_text)

        return CLIResult(
            output=f"Last edit to {path} undone successfully. {self._make_output(old_text, str(path))}"
        )

    def _make_output(
        self,
        file_content: str,
        file_descriptor: str,
        init_line: int = 1,
        expand_tabs: bool = True,
    ) -> str:
        """Format file content for display with line numbers."""
        file_content = maybe_truncate(file_content)
        if expand_tabs:

View on GitHub (pinned to 52a13f2a57)

Solutions

  1. Only call undo_edit after at least one successful edit through the same editor instance and the same path spelling.
  2. Check history length before undoing (if the API exposes it) or track edit counts on your side.
  3. Use a canonical absolute path for every edit and undo so history keys always match.
  4. If history was lost (restart), restore content from version control instead of undo_edit.

Example fix

// before
await editor.undo_edit('app/main.py')  // process restarted, history empty -> error
// after
if editor._file_history.get('app/main.py'):  # or track edits yourself
    await editor.undo_edit('app/main.py')
else:
    await operator.write_file('app/main.py', restore_from_git_or_backup())
Defensive patterns

Strategy: validation

Validate before calling

if not editor._file_history.get(path):
    raise RuntimeError(f'no history for {path}; restore from VCS instead')

Try / catch

try:
    await editor.undo_edit(path)
except ToolError as e:
    if 'No edit history found' in str(e):
        await operator.write_file(path, git_checkout(path))  # fallback restore
    else:
        raise

Prevention

When it happens

Trigger: Calling undo_edit on a file that was never edited via this editor instance, or calling undo_edit more times than edits were made (each undo pops one entry). Also occurs after process restart, since history is in-memory only, or when the path key differs (e.g. relative vs absolute path spelling of the same file).

Common situations: Agent flows that assume persistent undo across sessions; mixing edits made through other tools or manual writes (not tracked in history); path normalization mismatches ('./app/main.py' vs 'app/main.py') creating distinct history keys.

Related errors


AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15). Data as JSON: /api/errors/ca8866bdcd450787. Report an issue: GitHub.