undo • AI Agent SDK

undo: Undo the last set of file changes.

undo

Method

</div>

This is a method of the Agent class in the agent module.

Undo the last set of file changes.

Restores files to the state before the last autonomous run. Requires `autonomy=AutonomyConfig(track_changes=True, snapshot=True)` so run_autonomous() records a pre-run snapshot.

Signature

python
def undo() -> bool

Returns

ResponseField bool

:

agent = Agent(autonomy=AutonomyConfig(level=”full_auto”, snapshot=True)) result = agent.start(“Refactor utils.py”) agent.undo() # Restore original files

Uses

  • get_current_hash
  • restore
  • logger.debug

Source

View on GitHub

praisonaiagents/agent/agent.py at line 4448