Set Snapshot Root • AI Agent SDK

set_snapshot_root: Root filesystem change-tracking at “project_path“.

set_snapshot_root

Method

</div>

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

Root filesystem change-tracking at `project_path`.

Bots/gateway resolve file tools against a per-chat `Workspace and attach it after construction, but the FileSnapshot backing :meth:undo/:meth:redo/:meth:diff was created at __init__ time rooted at os.getcwd(). Without this, /undo` tracks the wrong directory (never where the tools actually wrote). Call this once after the workspace is known so change tracking follows the tools.

Rooting at a new directory clears the undo/redo stacks (they belong to the previous root). A no-op when the root is unchanged. Returns `True when a snapshot manager is rooted at project_path`.

Signature

python
def set_snapshot_root(project_path: str) -> bool

Parameters

ParamField str

No description available.

Returns

ResponseField bool

The result of the operation.

Uses

  • abspath
  • FileSnapshot
  • logger.debug

Source

View on GitHub

praisonaiagents/agent/agent.py at line 4411