gmen1057/agent-harness
About
Context discipline, secret/live-tree guardrails, cache-warm CI waiter, token & cache audit, and multi-agent pipeline for Codex & Antigravity
Developer ToolsMeasured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Original🇺🇸 English | 🇷🇺 Русский
agent-harness
Production guardrails, token-saving CLI tools, cache-safe CI workflows, and multi-agent pipeline templates for OpenAI Codex and Google Antigravity (agy).
Built in production at Arckep.
🤖 For AI Agents: read
AGENTS.mdand set up this harness for the user automatically.
Why Bare Coding Agents Burn Budgets and Break Production
Out of the box, terminal coding agents fail in four predictable ways on real repositories:
- Uncached polling storms (
200K–400Ktokens per PR): runninggh pr checks --watchor ad-hocsleeploops inside a thick coordinator session (>100K–120Ktokens) outlives the ~3-minute prompt KV-cache TTL. Every wake-up re-bills the entire conversation prefix at0%cache hit rate. - Reasoning degradation past
140K–150Kcontext: dumping 1,500-line files viacat, streaming verbosepytest/vitestoutput, and reading 20 raw source files in the orchestrator window causes measurable tunnel vision — median reasoning depth drops by 40–55%, introducing regressions into neighboring logic. - Silent
.envand credential leaks: agents read live.envfiles "just to check variable names", print secrets in shell pipelines, or bypass naive filename filters through heredocs (python3 - <<'EOF') and subshells. - Direct edits on live checkouts: without hard path guards, agents edit
/srv/my-saason the live branch instead of working in isolatedgit worktreecheckouts, or kill shared database and web ports during test cleanup.
agent-harness packages the exact runtime controls, CLI wrappers, rule templates, and skills we use daily to keep agent sessions thin, cache-warm, and isolated — implemented strictly on Python 3.11+ standard library with zero external pip dependencies.
What's Inside the Core Package
1. Methodology & Multi-Agent Pipeline (templates/, skills/, skills-ru/)
- Structured execution pipeline:
Scout → Contract Passport → Exclusive-File-Ownership Workers → Neighbor-Logic Verifier → Session Relay. The lead orchestrator stays under70K–100Ktokens and never reads raw product source on large tasks. - Model & KV-cache discipline: battle-tested rules for Gemini 4 in Antigravity (
3.0xCarbon/Argonvs~2.0xNeonvs1.0xHydrogenquota multipliers, ~3-minute prefix KV-cache protection,Reactive Wakeupwith zero polling) and OpenAI Codex (fork_turns="none"past40K,240Kauto-compaction boundary). - Ready-to-use rule templates (
templates/en/,templates/ru/): rootAGENTS.mdcontract plus modulardocs/{delegation,instruction-routing,model-preferences,runtime-tools,skill-scopes}.md, sized strictly under Antigravity's24,000-byte per-rule ceiling. - 5 core skills:
large-task-pipeline,systematic-debugging,verification-before-completion,agent-audit, andantigravity-cli-usage(in English and Russian).
2. Hard Security & Context-Hygiene Hooks (src/agent_harness/{core,codex,antigravity,shell_hooks}/)
.env& credential blocking acrossOpaqueShell: intercepts direct file reads, editors, and shell commands — including heredocs,python -c, command substitutions, and subshells — targeting.env, private keys, and cloud credentials. Supports explicit owner-approved TTL grants (env-grant,env-check) with append-only JSONL audit logging.- Live-checkout write protection: blocks direct edits and destructive git commands inside configured
protected_live_trees, steering agents into isolated worktrees (/var/tmp/wt/<slug>), and guardsprotected_ports,protected_containers, andprotected_processes. - Context compaction & rule auto-injection: turns
>400-linecatdumps on source files into compact structural outlines, auto-injects path-scoped.agent/rules//.claude/rules/and nestedAGENTS.mdrules on first file touch, and enforces SHA-256 hook code-hash verification (run_reviewed.py).
3. Token-Saving CLI Suite (bin/)
| Command | Purpose |
|---|---|
test-q |
Compact test wrapper for pytest, vitest, jest, cargo test, go test, and unittest. Injects quiet flags, returns one summary line on pass, and prints targeted failure context + full log path on failure. |
ci-wait & ci-incident |
Cache-warm GitHub PR check waiter (statusCheckRollup fail-fast on first red job, bounded --timeout 90 for 3-minute KV-cache safety, Alembic/Prisma/Supabase migration conflict check) paired with a SQLite coordinator (ci-incident) so parallel agents never stampede gh run rerun on a broken base branch. |
wt-done & wt-auto-cleanup |
Safe post-merge git worktree cleanup: verifies merged PR status, clean working tree, absence of open /proc processes, and writes recovery refs (refs/wt-backup/<slug>) before deleting a worktree. |
env-check & env-grant |
Inspect .env key names / presence without printing secret values (env-check), or issue time-bounded, path-scoped owner grants (env-grant) recorded with 0600 permissions. |
agent-audit |
Read-only SQLite + JSONL session analyzer for Codex and Antigravity: total vs uncached input tokens, cache hit rate, rapid prefix resets (≤120s), quota-weighted spend (3x/2x/1x), Exploration vs Implementation KPI (% uncached tokens before first edit), repeated .env / rg excavations, and >30 KB output outliers. |
agent-harness |
Unified management CLI: environment status (status), instruction symlink sync (sync-instructions), worktree skill-scope builder (sync-skills), Antigravity rule byte/token budget validator (check-rules), and hook installers. |
60-Second Quickstart
Requirements: Linux or macOS, Python >= 3.11 (stdlib only — zero pip packages, no virtualenv or root needed), git, bash (plus gh CLI if using ci-wait / wt-done).
git clone https://github.com/gmen1057/agent-harness.git
cd agent-harness
./install.sh # installs CLI links into ~/.local/bin and starter configs into ~/.config/agent-harness
# (use ./install.sh --lang ru to link Russian skills by default)
export PATH="$HOME/.local/bin:$PATH"
agent-harness status
Configure Your Repositories (~/.config/agent-harness/harness.json)
Edit ~/.config/agent-harness/harness.json to register your live checkouts, worktree root, and protected services:
{
"worktree_root": "/var/tmp/wt",
"protected_live_trees": [
{
"root": "/srv/my-saas",
"subroots": ["backend", "frontend"]
}
],
"repos": [
{
"slug": "my-saas",
"git_dir": "/srv/my-saas",
"github_repo": "acme/my-saas",
"default_branch": "main",
"env_files": ["/srv/my-saas/backend/.env"],
"worktree_links": ["backend/.env.test", "backend/.venv"],
"worktree_hardlink_trees": ["frontend/node_modules"]
}
],
"protected_ports": [5432, 6379, 8000, 3000],
"protected_containers": ["postgres", "redis", "nginx"]
}
Enable Hooks & Adopt Rule Templates
- Copy rule templates from
templates/en/(ortemplates/ru/) into~/AGENTS.mdand~/docs/agent-rules/, replacing<PROJECT_SLUG>and/srv/my-app, then link global agent entrypoints:agent-harness sync-instructions --apply agent-harness check-rules - Preview and enable runtime hooks (always inspect
--dry-runfirst, then restart open agent sessions so new hooks take effect):agent-harness install-hooks --dry-run # After reviewing the rendered hook configs: agent-harness install-hooks --install - Run compact tests & audit your token spend:
test-q pytest agent-audit --days 7
What Else Runs in Our Production — Available on Demand (Roadmap)
On top of this core harness, three larger systems run in our daily production stack. They currently carry framework-specific wiring and need clean decoupling before we can publish them as standalone open-source packages:
- Codegraph MCP Server (~31K LOC) — incremental AST + HTTP route + call-graph + doc-drift and hybrid vector/keyword semantic search index (
plan_change~1,000-token repo maps with exactline..end_linesignatures,route_usage,component_usage, andcallers_offor TypeScript/Next.js/Express and Python/FastAPI). - Safe Customer DB & Multi-GB Log Navigators (
dbq+logq) — zero-credential scoped customer cards, schema-checked read-only SQL wrappers, andO(log N)binary-search log correlation acrossjournalctl, nginx, and application logs with automatic secret redaction. - Automated Session Distiller (
agent-learn) — background post-session analyzer that reviews closed coding transcripts, extracts repeated friction and subtle project gotchas, verifies them against current source code, and updates shared project docs without bloating always-on prompts.
👉 Want us to decouple and open-source any of these next? Give this repository a ⭐ Star and open or upvote an Issue naming the module (codegraph-mcp, dbq-logq, or agent-learn) and your stack. Community demand directly decides our release order.
Security & License
- Read
SECURITY.mdfor the defense-in-depth threat model (runtime hooks vs OS user isolation,0600grant state, and responsible disclosure). - Released under the MIT License. Copyright (c) 2026 Arckep / contributors.
Explore related projects
Loading…