undo • AI Agent SDK
undo: Undo the last set of file changes.
undo
Method
</div>
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
def undo() -> boolReturns
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_hashrestorelogger.debug
Source
View on GitHubpraisonaiagents/agent/agent.py at line 4448