Explainers

Inside Agentsitter 0.2.0 (Alpha): Git Hooks, ssh-keygen Approvals, and Cross-Family Tripwires

·November 21, 2026·9 min read
Agentsitter 0.2.0 (alpha) architecture diagram mapping routine Lane 1 work, cross-family Lane 2 advisor consults and signed Lane 3 approvals
Agentsitter 0.2.0 (alpha) wires three enforcement points (git hooks, harness hook, and CLI runner). It is a tripwire, not a sandbox.

Autonomous coding sessions create an awkward repository boundary: prompt instructions alone degrade across long contexts, while locking down every shell command destroys autonomy. Agentsitter 0.2.0 (alpha) from Search-Sherpa/agentsitter (MIT license) takes a pragmatic middle step. It wraps coding agents in a three-lane tripwire built from standard-library Python 3.9+, four POSIX advisor wrappers, git hooks, and OpenSSH ssh-keygen -Y signatures.

The repository is explicit about what it is not. It is a 0.2.0 alpha tripwire, not a sandbox. The agent still runs under your user account permissions. All 169 automated tests across 7 modules (44 tracked files) pass all 10/10 CI matrix jobs on commit a352d68 (CI run 44875717343) across Linux (Python 3.9 to 3.14), macOS (Python 3.9 and 3.14), and Windows (Python 3.9 and 3.14) using stub CLIs and throwaway keys. A real approval at a terminal, with a passphrase-protected key, has been checked by hand once on Windows 11 (OpenSSH for Windows 9.5 in PowerShell) only, with release 0.1.0 (named agent-babysitter; 0.2.0 renames it).

Repository layout and GitHub-only distribution

Everything lives in a compact Python package (dependencies = [] in pyproject.toml) plus four shell wrappers, a harness hook config example, a SKILL.md, and a unittest suite:

agentsitter/
  cli.py           CLI entrypoint (agentsitter / python -m agentsitter)
  lanes.py         Regex and path classifier for Lane 1, Lane 2, and Lane 3
  gate.py          Canonical JSON digests, ssh-keygen -Y sign/verify, TTL and replay checks
  consult.py       Cross-family routing, VERDICT: check, consult budget, receipts
  hooks.py         JSON-on-stdin agent hook and git hook installation (-I -S)
  enforce.py       Shared check/run/checkpoint enforcement logic
  state.py         User-level state under ~/.local/state/agentsitter
  config.py        Defaults deep-merged with ~/.config/agentsitter/config.json
  codes.py         Exit codes (0, 2, 4, 10-14, 20-22)
  advisors/        _runner.sh, ask-claude.sh, ask-codex.sh, ask-gemini.sh, ask-grok.sh
examples/          agent-hook-settings.json (PreToolUse + Stop)
skill/             SKILL.md instructions for governed agents
tests/             7 test modules (169 tests) + stub CLIs under tests/stubs/

There is deliberately no per-repository configuration file. An agent edits files inside the working tree continuously, so the config, allowed_signers trust anchor, and state directory all live outside the repository under the user home directory (~/.config/agentsitter and ~/.local/state/agentsitter). If you govern Search-Sherpa/agentsitter development itself via pip install -e ., edits to the package require Lane 3 approval, so use a separate copy when editing Agentsitter.

Search-Sherpa/agentsitter is distributed on GitHub only, not PyPI. Never run `pip install agentsitter`: that PyPI package name belongs to an unrelated cost-monitoring tool, and several unrelated GitHub repositories also share the bare name. Always clone https://github.com/Search-Sherpa/agentsitter.git and install with pip install ..

How signed approvals bind to exact actions

A plain approval file on disk proves nothing if the agent can write files. gate.py hashes a canonical ASCII JSON representation of the requested action (action_digest), writes a pending request, and requires the human approver to run agentsitter approve <request_id> in their own interactive terminal. ssh-keygen -Y sign signs the approval JSON (which includes a 16-byte random nonce and a default 900-second expiry), and verification runs ssh-keygen -Y verify against allowed_signers under the configured namespace (agentsitter).

  • Commits: bound to the repository, staged tree, parent commit, and merge parents if concluding a merge. Restaging different content invalidates the approval.
  • Pushes: bound to the repository, remote, and exact ref updates.
  • Rebases: bound to the repository, upstream, branch (by name and target commit), and HEAD; rebases carrying options (--onto, -i) also require a command-level approval because git passes only upstream and branch to the hook.
  • Protected-file edits: bound to the tool name, target path, and full edit payload hash (input_sha256). agentsitter approve displays the edit and refuses to sign if the request payload no longer matches.
  • Other Lane 3 commands: bound to the exact command string and working directory only. Approving npm publish authorizes whatever is in that directory while the 900s TTL holds.

To reduce accidental self-signing, agentsitter approve exits 22 when stdin is not a TTY, when ADVISOR_DEPTH is set, or when a session marker such as CLAUDECODE is present. That check is only a secondary guard: the private signing key must be passphrase-protected or hardware-backed (`ed25519-sk`), because file reads are not gated and an unencrypted key would let the agent invoke ssh-keygen directly.

Git hooks with Python -I -S and deferral rules

Running agentsitter install-hooks installs pre-commit, pre-merge-commit, pre-push, and pre-rebase hooks (refusing to overwrite foreign hooks without --force). Each hook records the exact Python interpreter and package path at install time and launches Python with -I -S so working-tree files, PYTHON* environment variables, and site-packages startup hooks cannot shadow the standard library or package code.

When the JSON-on-stdin harness hook (agentsitter hook agent) is active, a plain git commit, git push, or git rebase defers to the installed git hook so approval binds to the exact staged tree or ref updates. That deferral only triggers when every command on the line is plain git (or behind time or rtk), carries no --no-verify/-n or --amend, passes no pre-subcommand options (-C, -c, --git-dir, --work-tree, --config-env), changes no directory or environment variables (such as HOME=...), adds no rebase flags, and matches the exact installed hook bytes. Anything else requires a command-level approval on top.

Cross-family advisor wrappers and what was tested

Lane 2 rules catch dependency changes (npm install <pkg>, pip install <pkg>, cargo add), schema migration authoring (alembic revision, prisma migrate dev), and large or sensitive change sets checked by agentsitter checkpoint / the harness Stop hook (default: >8 files, >300 lines, or migrations/CI/Docker/Terraform/auth/payments/manifests).

Family identity comes from AGENTSITTER_HOST_FAMILY or session marker environment variables (CLAUDECODE, GEMINI_CLI), not IDE detection. agentsitter consult refuses an advisor from the builder's own model family with exit 13 (or 14 if family cannot be established). Each wrapper in agentsitter/advisors/ refuses positive non-zero ADVISOR_DEPTH (exit 4; non-numeric values exit 2 in wrappers and 4 in agentsitter consult), unknown builder families (AGENTSITTER_HOST_FAMILY, exit 6), and same-family consults (exit 7), closes stdin (</dev/null via _runner.sh, or finite prompt file < "$PROMPT_IN" in ask-codex.sh), enforces wall-clock timeouts (timeout, gtimeout, or perl watchdog), and treats empty output as failure (exit 3, or exit 1 for Codex).

  • CI matrix (10/10 green): .github/workflows/ci.yml (run 44875717343 on commit a352d68) runs all 7 test modules (169 tests) plus pip install --no-deps . packaging checks across ubuntu-latest (Python 3.10 to 3.14), ubuntu-24.04 (Python 3.9), macos-latest (Python 3.9 and 3.14), and windows-latest (Python 3.9 and 3.14). CI runs against stub CLIs in tests/stubs/ and throwaway keys; it never calls live models.
  • Clean-room test (`tests/test_clean_room.py`): scans every repository file for absolute machine paths, emails outside example.invalid, pinned model IDs, CR line endings, and optional external ban lists (AGENTSITTER_LINT_BANNED / AGENTSITTER_LINT_BANNED_FILE).
  • Live CLI smoke checks (2026-11-19, Windows 11): one-word live calls passed exit 0 on ask-claude.sh (Claude Code 2.1.319), ask-codex.sh (codex-cli 0.162.1), and ask-gemini.sh (agy 1.5.13). ask-grok.sh (grok 1.0.77) stopped at exit 5 in its login-expiry preflight. These calls prove flags were accepted on those versions; they do not test each vendor CLI's runtime lockdown.
  • Manual passphrase check: verified once by hand on Windows 11 with OpenSSH for Windows 9.5 in PowerShell, with release 0.1.0 only (visible prompt, valid signature, one-time run, second run refused). Untested on 0.2.0 and untested on Linux or macOS terminals.

Upgrading from 0.1.0 and backwards-guard behavior

If a 0.1.0 copy remains installed alongside 0.2.0, 0.2.0 still guards the legacy command names, BABYSITTER_* environment variables, and ~/.config/agent-babysitter / ~/.local/state/agent-babysitter directories so an agent cannot approve itself through an old binary or edit old state paths. When following Upgrading from agent-babysitter 0.1.0, update the harness hook from babysitter hook agent to agentsitter hook agent before running pip uninstall agent-babysitter so tool calls are not waved through when the old command disappears (Claude Code blocks only on exit 2).

Documented threat model and known bypasses

Maintainers evaluating v0.2.0 (alpha) should read What this does and does not enforce before deploying it on sensitive repos:

  • Not a sandbox: without the harness hook, agentsitter run and agentsitter check are opt-in, an agent can pass --no-verify to git, and it can edit ~/.config/agentsitter or ~/.local/state/agentsitter. Protect important branches on the remote server.
  • Pattern-matching gaps: indirection through a script or Makefile target bypasses built-in regexes unless added to rules.extra. Known gaps documented in README include git rm without --force, globs traversing symlinks outside scratch dirs, HTTPie implicit POSTs, local-URL waivers combined with a second bare destination or --connect-to, and shell redirects through symlinks to protected files.
  • Python runtime not protected: a home-directory or virtualenv Python interpreter and standard library remain writable by the user account running the agent.
  • Commit TOCTOU race: pre-commit reads the staged tree and validates the approval before git constructs the commit object; a concurrent process restaging between those two steps can alter what commits.
  • Lane 2 is advisory: the builder writes the brief, two failed consults unlock self-proceed (logged), and budget counting happens after each consult so concurrent consults can overrun the window cap. Architectural forks without a rule still depend on the agent choosing to ask.

Verify locally before wiring into a repo

Command: git clone https://github.com/Search-Sherpa/agentsitter.git
Command: cd agentsitter && pip install .
Command: python -m unittest discover -s tests -t .
Command: python -m agentsitter classify -- "npm install left-pad && git push"
Needs Python 3.9+, git, bash, and ssh-keygen. Never run pip install agentsitter (unrelated PyPI project).

Cross-site resources and repository links

Related Resources & Skills

Explore tools, repositories, and categories referenced in this guide:

About the Authors

Jeremy Bengtson

Jeremy Bengtson

Founder & AI Systems Architect · The Search Sherpa

Founder of The Search Sherpa and AI systems engineer designing autonomous agent harnesses, Model Context Protocol (MCP) integrations, 3-tier memory architectures, and disciplined engineering frameworks across Learn Claude Skills and Claude Skills GitHub.