Coding agent
Filesystem helpers are rooted at the current directory by default. Shell execution is denied until a ShellPolicy enables a scoped executable.
Terminal
pip install "opentine[openai]"
export OPENAI_API_KEY="..."coder.py
1from opentine import Agent
2from opentine.policies import ShellPolicy
3from opentine.models.openai import OpenAI
4from opentine.tools.fs import edit, ls, read, write
5from opentine.tools.shell import run as shell_run
6
7test_policy = ShellPolicy(enabled=True, executables=("python",), cwd_root=".")
8
9def run_tests() -> str:
10 """Run the project test suite."""
11 return shell_run("python -m pytest", policy=test_policy)
12
13agent = Agent(
14 model=OpenAI("gpt-5.6"),
15 tools=[read, write, edit, ls, run_tests],
16 system="Inspect before editing. Make the smallest change and verify it.",
17 max_steps=50,
18)
19run = agent.run_sync("Add validation to the registration endpoint")
20run.save("validation-feature.tine")
21print(run.total_duration, run.total_cost)
Scope the tools
For production, pass explicit filesystem policies through narrow wrappers too. This example exposes one fixed test command, not arbitrary shell access.
Fork and retry
retry.py
1from opentine import Run
2
3failed = Run.load("validation-feature.tine")
4fixed = agent.resume_sync(
5 failed,
6 from_step=failed.steps[-2].id,
7 prompt="Continue using the test failure as the constraint.",
8)
9fixed.save("validation-feature-fixed.tine")