from ai_infra.llm import WorkspaceUnified workspace configuration for all agent file operations. The Workspace class provides a single way to configure how agents interact with the filesystem. It bridges: - deepagents backends (for deep=True agents) - proj_mgmt tools (for regular agents with file tools)
root: The workspace root directory. Defaults to current directory. mode: How the agent can access files: - "virtual": In-memory only. Files don't persist. Safe for untrusted code. - "sandboxed": Real filesystem, but confined to root. Recommended for most use. - "full": Full filesystem access. Use only for trusted automation. Example - Local development (sandboxed to project):
agent = Agent(
deep=True,
workspace=Workspace(".", mode="sandboxed"),
)
# Agent can read/write files in current directory onlyExample - Cloud/untrusted (virtual filesystem):
agent = Agent(
deep=True,
workspace=Workspace(mode="virtual"),
)
# Files exist only in memory, safe for untrusted promptsExample - Trusted automation (full access):
agent = Agent(
deep=True,
workspace=Workspace("/", mode="full"),
)
# Agent has full filesystem access - use with caution!