Debian Codegraph @

src/anthropic/lib/tools/_deprecations.py

raw
1 """Deprecated-parameter checks shared by the agent toolset and the environment worker.
2
3 Kept free of host-only imports so `anthropic.lib.environments` can use it at
4 module level without pulling in `anthropic.lib.tools.agent_toolset`.
5 """
6
7 from __future__ import annotations
8
9 from ..._types import NotGiven
10
11 __all__ = ["UNRESTRICTED_PATHS_DEPRECATION", "reject_unrestricted_paths"]
12
13 UNRESTRICTED_PATHS_DEPRECATION = (
14 "unrestricted_paths is no longer supported. The file tools are now always confined to the "
15 "working directory plus any allowed_roots (the environment worker adds the session's memory "
16 "folders there itself), which is neither of the behaviors this flag used to choose between. "
17 "Remove the unrestricted_paths argument; to let the file tools reach another directory, add it "
18 "to AgentToolContext.allowed_roots."
19 )
20
21
22 def reject_unrestricted_paths(value: bool | NotGiven) -> None:
23 """Raise `TypeError` if the deprecated `unrestricted_paths` was passed at all."""
24 if isinstance(value, NotGiven):
25 return
26 raise TypeError(UNRESTRICTED_PATHS_DEPRECATION)