Skip to content
Projects

About

Context discipline, secret/live-tree guardrails, cache-warm CI waiter, token & cache audit, and multi-agent pipeline for Codex & Antigravity

Developer Tools

How these counts are measured

Measured 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.md and 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:

  1. Uncached polling storms (200K–400K tokens per PR): running gh pr checks --watch or ad-hoc sleep loops inside a thick coordinator session (>100K–120K tokens) outlives the ~3-minute prompt KV-cache TTL. Every wake-up re-bills the entire conversation prefix at 0% cache hit rate.
  2. Reasoning degradation past 140K–150K context: dumping 1,500-line files via cat, streaming verbose pytest/vitest output, 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.
  3. Silent .env and credential leaks: agents read live .env files "just to check variable names", print secrets in shell pipelines, or bypass naive filename filters through heredocs (python3 - <<'EOF') and subshells.
  4. Direct edits on live checkouts: without hard path guards, agents edit /srv/my-saas on the live branch instead of working in isolated git worktree checkouts, 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 under 70K–100K tokens and never reads raw product source on large tasks.
  • Model & KV-cache discipline: battle-tested rules for Gemini 4 in Antigravity (3.0x Carbon/Argon vs ~2.0x Neon vs 1.0x Hydrogen quota multipliers, ~3-minute prefix KV-cache protection, Reactive Wakeup with zero polling) and OpenAI Codex (fork_turns="none" past 40K, 240K auto-compaction boundary).
  • Ready-to-use rule templates (templates/en/, templates/ru/): root AGENTS.md contract plus modular docs/{delegation,instruction-routing,model-preferences,runtime-tools,skill-scopes}.md, sized strictly under Antigravity's 24,000-byte per-rule ceiling.
  • 5 core skills: large-task-pipeline, systematic-debugging, verification-before-completion, agent-audit, and antigravity-cli-usage (in English and Russian).

2. Hard Security & Context-Hygiene Hooks (src/agent_harness/{core,codex,antigravity,shell_hooks}/)

  • .env & credential blocking across OpaqueShell: 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 guards protected_ports, protected_containers, and protected_processes.
  • Context compaction & rule auto-injection: turns >400-line cat dumps on source files into compact structural outlines, auto-injects path-scoped .agent/rules/ / .claude/rules/ and nested AGENTS.md rules 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

  1. Copy rule templates from templates/en/ (or templates/ru/) into ~/AGENTS.md and ~/docs/agent-rules/, replacing <PROJECT_SLUG> and /srv/my-app, then link global agent entrypoints:
    agent-harness sync-instructions --apply
    agent-harness check-rules
    
  2. Preview and enable runtime hooks (always inspect --dry-run first, 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
    
  3. 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:

  1. 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 exact line..end_line signatures, route_usage, component_usage, and callers_of for TypeScript/Next.js/Express and Python/FastAPI).
  2. Safe Customer DB & Multi-GB Log Navigators (dbq + logq) — zero-credential scoped customer cards, schema-checked read-only SQL wrappers, and O(log N) binary-search log correlation across journalctl, nginx, and application logs with automatic secret redaction.
  3. 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.md for the defense-in-depth threat model (runtime hooks vs OS user isolation, 0600 grant state, and responsible disclosure).
  • Released under the MIT License. Copyright (c) 2026 Arckep / contributors.

Explore related projects

Loading…