workspace_tools#
Universal workspace tools — factories that produce callables bound to a
specific Agent’s workspace registry.
Each factory returns a list of plain Python callables (not Tool
instances) — the agent layer wraps them via Agent.add_tool(). Two
families are exposed:
build_workspace_read_tools()—list_directory,read_file. Always safe to register: read-only operations work on any workspace.build_workspace_write_tools()—write_file,create_file,delete_file. The agent only registers these when at least one workspace haswritable=Trueso the LLM never sees mutating tools when the entire setup is read-only. Per-workspace enforcement happens insideWorkspaceitself.
Both factories close over the agent so the tools dispatch to the right
workspace at call time via Agent._resolve_workspace(). Splitting the
factories into “read” and “write” lets the agent enable each family
independently based on its workspace registry.
- baf.library.tool.workspace_tools.build_workspace_read_tools(agent)[source]#
Return the universal read-only workspace tools.
- Parameters:
agent (Agent) – the agent whose
_workspacesregistry the returned callables will dispatch into.- Returns:
[list_directory, read_file]. The function names match the tool names the LLM will see in the schema.- Return type:
list[Callable]
- baf.library.tool.workspace_tools.build_workspace_write_tools(agent)[source]#
Return the universal mutating workspace tools.
The tools dispatch to the chosen workspace’s mutating methods, which raise
WorkspaceErroron read-only workspaces — so even if the LLM picks a read-only workspace from a mixed setup, the per-workspace check still applies.- Parameters:
agent (Agent) – the agent whose
_workspacesregistry the returned callables will dispatch into.- Returns:
[write_file, create_file, delete_file].- Return type:
list[Callable]