Conversation
Hooks invoke the guard engine as a bare `python3`, which resolves through the user's PATH. With an activated project virtualenv on Python 3.10 (a common adopter setup, e.g. Apache Airflow) the module-level `import tomllib` raised ModuleNotFoundError on every Bash call: a traceback in the UI each time, and the guard silently never ran. The engine now imports on 3.10 (tomllib is imported where it is used) and, when the interpreter is older than 3.11, re-runs itself under the newest `python3.N` (3.11+) on PATH. When none exists it exits 1 with one actionable line instead of a traceback. Every harness adapter benefits, since the check runs before `cli()` dispatches. Generated-by: Claude Code (Fable 5.1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
magpie-agent-guardPreToolUse hook runs the engine as a barepython3. When that resolves to a pre-3.11 interpreter — typically an activated project virtualenv, e.g. Apache Airflow's.venvon 3.10 — the module-levelimport tomllibfails withModuleNotFoundErroron every Bash call: a traceback in the UI each time, and the guard silently never runs.tomllibis imported where it is used) and, when running under <3.11, re-execs itself under the newestpython3.N(3.11+) found onPATH. When none exists it exits 1 with one actionable line instead of a traceback. The check runs beforecli()dispatches, so every harness adapter (Claude Code, OpenCode, Gemini, Kiro,--check,--exec) benefits.python3, neveruv run.Type of change
tools/*/withpyproject.toml) —tools/agent-guarddocs/,README.md,CONTRIBUTING.md) —tools/agent-guard/README.md,tools/spec-loop/specs/agent-isolation-sandbox.mdisolated_fingerprint.pyregenerated by theisolated-setup-fingerprintprek hook (expected whenevertools/agent-guard/srcchanges)Test plan
prek run --all-filespasses (including lychee, ruff, mypy, pytest, isolated-setup-fingerprint)uv run pytest/ruff check/mypypasses — 4 new tests intests/test_python_version.py(no-op on 3.11+, re-exec picks the newest interpreter, no interpreter found, re-exec marker already set)python3: withpython3.13onPATHthe Co-Authored-By deny fires and--checkstill exits 2; with no newer interpreter onPATHit printsagent-guard: needs Python 3.11+ ...and exits 1RFC-AI-0004 compliance
os.execvof an interpreter already onPATHLinked issues
None found — the symptom was observed on an Apache Airflow adopter machine (53 sessions since the plugin was installed on 2026-09-28).
Notes for reviewers (optional)
commandtouv run --python '>=3.11'— the engine's documented contract is stdlib-only and never viauv, so the hook stays fast and needs no environment.python3.20down topython3.11; the upper bound is aponytail:comment to raise when needed..last-syncwas not bumped: it is 27 commits behindmainand this PR only updates the one spec paragraph it touches.Generated-by: Claude Code (Fable 5.1). AI-assisted; reviewed and submitted by a human.