Shell and Python tools
Both subprocess tools are disabled by default.
defaults.py
1from opentine.tools.python import execute
2from opentine.tools.shell import run
3
4print(run("git status"))
5# Error: shell execution disabled by policy
6
7print(execute("print('hello')"))
8# Error: Python execution disabled by policy
Enable with policy
policies.py
1from opentine.policies import PythonPolicy, ShellPolicy
2from opentine.tools.python import execute
3from opentine.tools.shell import run
4
5shell_policy = ShellPolicy(enabled=True, executables=("git", "pytest"), cwd_root=".")
6python_policy = PythonPolicy(enabled=True, inherit_env=False, timeout_seconds=30)
7
8status = run("git status", policy=shell_policy)
9result = execute("print(2 + 2)", policy=python_policy)
Shell commands are parsed into argument arrays and run with shell=False. Scope executable names, working-directory root, environment inheritance, time, and output. Timeouts terminate the owned process group or Windows Job Object and retain bounded diagnostics.
Expose narrow wrappers
Wrap a fixed policy in a small typed function so the policy itself is not model-controlled input.
agent_tools.py
1from opentine import Agent
2from opentine.policies import PythonPolicy, ShellPolicy
3from opentine.models.anthropic import Anthropic
4from opentine.tools.python import execute
5from opentine.tools.shell import run
6
7def git_status() -> str:
8 """Show the current repository status."""
9 return run("git status", policy=ShellPolicy(enabled=True, executables=("git",)))
10
11def python_eval(code: str) -> str:
12 """Run Python in an isolated temporary directory."""
13 return execute(code, policy=PythonPolicy(enabled=True))
14
15agent = Agent(model=Anthropic(), tools=[git_status, python_eval])
Environment behavior
With inherit_env=False, only explicitly allowlisted names are passed. Python's legacy inherit mode still removes environment names matching common secret-bearing terms. These controls constrain a process; they do not provide an OS sandbox.