← Writing

Building an operating system for autonomous coding agents

Yunseop Im · Georgia Tech M.S. Computer Science · AI agents / LLM systems engineering

Everyone talks about giving an AI agent a better prompt. After months of running autonomous agents on a production multi-tenant SaaS, I'm convinced the prompt is the least important layer. What actually determines whether an agent is safe to leave unsupervised is the harness around it — the deterministic machinery that decides what the agent is allowed to do, records what it did, and judges whether the result is real.

This post is a teardown of devin-harness, the open-source harness I extracted from that production work. It is not a prompt collection and it is not a wrapper. It is an operating system for agentic repos: lifecycle hooks, review gates, a dispatch contract, a skills library, and a written pattern corpus.

1. The failure mode nobody talks about: gray failures

Most agent disasters are not crashes. A crash is loud and recoverable. The dangerous class is the gray failure: the session ends "successfully" while a queue silently stops draining, a deploy reports green while a migration never ran, an edit touches a secret file and nothing notices. A diff review cannot catch these, because the damage is not in the diff — it is in what the agent didn't do.

The design consequence is the core thesis of the harness:

A rule enforced at the tool-call boundary beats a rule the agent might remember from a prompt.

Every component below exists to move a class of failure from "the model might avoid it" to "the model cannot do it."

2. Lifecycle hooks: checkpoints at every transition

Modern agent harnesses expose lifecycle events — moments where the host can inject code around the agent's actions. devin-harness wires five of them:

HookEventWhat runs
session-start.mjsSessionStartDirty-tree detection, stale locks, open review obligations, incident index — the session begins already informed about repo state.
agent-guard.mjsPreToolUseExec guard: deterministic regex rules that block dangerous shell commands before they run. Sub-50ms, zero model calls.
file-guard.mjsPreToolUse (edit/write)Blocks writes to secret files, migration files, and runtime-state files at the boundary.
agent-ledger.mjsPostToolUseAppends every tool call — secrets redacted — to action-log.jsonl. The session becomes auditable as a trace, not just a diff.
prompt-guard.mjsUserPromptSubmitDetects questions that require external knowledge and injects a mandatory source-verification instruction.
claim-guard.mjsStopIf files changed but no test ran afterward, the session ends with a loud "unverified" advisory instead of a silent green.

Two design choices matter here. First, the guards are deterministic: regex and path rules, not model judgments. They cost microseconds and cannot be persuaded. Second, they fail closed — a blocked command produces an error the agent must route around legitimately, not a warning it can ignore.

3. The review gate stack: from diff to judgment

Prevention is only half the system. The other half is judgment — deciding whether what the agent produced is actually good. The gate stack runs in escalating cost order:

  1. gate.mjs — deterministic suppression and secret scanning across the diff. Free, instant, catches the mechanical failures.
  2. dep-audit.mjs — npm supply-chain audit on dependency changes. Catches the "agent added a typosquatted package" failure class.
  3. jev-gate.mjs — a typed LLM judgment over the diff: 14 typed constraints, plan-drift aware, backed by a persistent state.json so findings the author already resolved never re-block. This is the interesting piece: the judge has memory, which turns review from a stateless opinion into a tracked obligation.
  4. predeploy.example.mjs — the deploy-gate skeleton that composes the above into a promotion check.

The pattern worth stealing: cheap deterministic checks first, expensive model judgment last, and persistent state so judgment accumulates instead of repeating.

4. The dispatch contract: agents that can spawn agents

ops/dispatch/ contains devin-session.mjs and dispatch-rules.md — a contract for delegating work to autonomous sessions. This is where the harness stops being "guardrails for one agent" and becomes an orchestration layer: rules for when a task is dispatchable, what context the child session receives, and how results are verified before merging.

5. Skills and the knowledge corpus

The repo ships eleven domain skills under .devin/skills/ — SEO, ads-ops, copywriting, landing pages, CRO, ICP research, audience research, quality judging, and verify-with-sources, which forces primary-source research before answering external-knowledge questions. Skills are the harness's answer to "the agent doesn't know my domain": packaged, versioned expertise the agent auto-invokes.

Alongside them sits docs/ — roughly thirty pattern documents covering agent orchestration, agent memory, agent perception, context engineering, decision models, observability, on-call playbooks, release engineering, security-and-CI, testing strategy, OSS adoption, and harness-vs-labs comparisons. The skills teach the agent how to do a task; the docs teach it how this organization thinks.

6. Templates: the doctrine as files

templates/ ships AGENTS.root.template.md, AGENTS.subtree.template.md, an ADR template, and an incident template — the organizational memory of how work gets specified, decided, and reviewed. Combined with AGENTS.example.md (the multi-tenant data rules, gray-failure doctrine, secret registry, deploy-gate rule), the harness encodes operating doctrine, not just tooling.

7. Why this architecture wins

Three properties make it hold up in production:

The repo is MIT-licensed and installs in one command: node setup.mjs /path/to/your/repo. The bet I'm making is that the next generation of engineering leverage doesn't come from better models alone — it comes from better harnesses around them.

Repo: github.com/signalgap9-del/devin-harness
Related: How I built a real-time freight risk SaaS · profile & projects · LinkedIn