{"slug": "what-an-agent-harness-actually-owns-8-reads-on-loops-cost-routing-exactly-once", "title": "What an agent harness actually owns: 8 reads on loops, cost routing, exactly-once, durability and spec authority", "summary": "A developer's reading roundup examines what an agent harness actually owns across eight write-ups, covering Claude Code's roughly 1,700-line query loop, cache-safe model routing that recovers about 14–21% of model spend in an emulated 10,000-seat company, and the Limbo sandbox paper's 25,930 graded episodes testing where exactly-once semantics should live. The roundup argues that when a read-back can't confirm what happened, the fix belongs in the tool's API via idempotency keys and status queries, and highlights SpecHarness, which compiles specs into source-linked obligations and a versioned ledger so the agent proposes while the runtime commits.", "body_md": "Ask five engineers what an \"agent harness\" is and you'll get five answers. For some it's the while-loop around the model call. For others it's the retry wrapper, the spec checker, the durable store, or the whole repository the agent works in. I spent the last few weeks reading longer write-ups on each of those layers, and the eight below are the ones I keep coming back to. Each gets a short summary in my own words and a link to the full piece.\n\nA textbook ReAct loop fits in five lines of pseudocode. Claude Code's `query.ts` is roughly 1,700. This walkthrough reads that file and pulls out a five-layer pattern: a compaction pipeline that runs before every API call, tools that start executing while the model is still streaming, recovery paths for overflow and rate limits, and so on. It's a good map if you're writing your own loop and wondering what you'll end up adding anyway.\n\nRead: [the agent harness pattern behind Claude Code's core loop](https://redreamality.com/blog/inside-claude-code-agent-harness/)\n\nA preprint from Accenture's Responsible AI group argues that enterprise coding-agent spend is decided less by per-token rates than by the harness: which model answers, what it reads, and whether switching models throws away the prompt cache. In their emulated 10,000-seat company, cache-safe routing recovers about 14–21% of model spend. The post explains why a single turn with 18 tool steps re-sends the same context 19 times, and what procurement should be asking vendors.\n\nRead: [routing and cost governance when you control the harness](https://redreamality.com/blog/control-the-harness-control-the-cost/)\n\nA write times out. Did it go through? Retrying blindly means a second charge or a second deploy; giving up skips work. The Limbo sandbox paper ran 25,930 graded episodes across nine models, three production harnesses and two contract variants to ask where exactly-once should live. The short answer: it depends on whether an immediate read-back can show what happened. When it can't, no model or wrapper saves you, and the fix belongs in the tool's API (idempotency keys, status queries).\n\nRead: [exactly-once between model, harness and tool contract](https://redreamality.com/blog/exactly-once-model-harness-tool-contract/)\n\nThis one connects three very different stories: Anthropic replacing git with an in-house system after daily merges jumped from about 2,500 to over 30,000, a game developer turning his game into something an agent can drive, and OpenAI's Codex-only repository. The common thread is that once code is cheap, the bottleneck is whether the environment is queryable, reproducible, measurable and enforceable. My favorite line of advice in it: almost nobody needs custom version control, but almost everybody benefits from headless tests that print text and numbers.\n\nRead: [why environment legibility is the new harness work](https://redreamality.com/blog/ai-harness-environment-legibility/)\n\nMost coding agents assume a human will notice a crash and hit \"continue\". Pi Durable, shipped with Pi 1.0, targets Slack on-call bots and shared incident workspaces where sessions must survive deploys and dropped clients. The article lines it up against Temporal, Durable Objects and LangGraph checkpointers and asks a sharp question of each: when the process dies, do you lose progress, or can a write fire twice?\n\nRead: [what durable agent harnesses actually guarantee](https://redreamality.com/blog/pi-durable-agent-harness-durable-execution/)\n\nIn most setups the SKILL.md, the schema and the task instructions just become more context for the same model that later declares \"done\". SpecHarness compiles those specs into source-linked obligations and a versioned ledger, so the agent proposes and the runtime commits. The write-up separates two gaps worth naming in your own reviews: understanding a requirement is not executing it, and claiming completion is not proving the required state exists.\n\nRead: [SpecHarness and who holds the pen](https://redreamality.com/blog/specharness-spec-holds-the-pen/)\n\nMobile planning agents are expensive to develop because real-device runs are slow and hard to parallelize. Alibaba's Qwen-Planner-Agent paper describes a closed loop: a human-gated data flywheel, online RL with a competence-aware reward scheme, and runtime memory, skills and tools that get revised from failure traces. The 27B model tops MobilePA-Bench at 77.05 overall. The post is careful to note that the authors frame co-evolution as a pathway, not something already automatic.\n\nRead: [planner–harness co-evolution in Qwen-Planner-Agent](https://redreamality.com/blog/qwen-planner-agent-model-harness-coevolution/)\n\nIf you let an optimizer keep rewriting prompts, memory and control code until the score rises, it may learn the benchmark's habits rather than the task: filename patterns, the order of retrieval channels, where unit notes usually sit. The CHASE paper adds a Challenger that searches for meaning-preserving protocol changes that wipe out the gain. Task holdout stops item memorization; it doesn't stop a harness from eating the protocol.\n\nRead: [Bad Genius and counterfactual checks on harness evolution](https://redreamality.com/blog/bad-genius-counterfactual-harness-evolution/)\n\nIf you only have time for two, I'd start with #3 and #8. They're the ones most likely to change what you test before shipping an agent. Earlier lists in this series covered [agent memory and context](https://dev.to/redreamality_dev/where-agent-memory-actually-breaks-6-reads-on-read-time-curation-stale-updates-heavy-tails-and-4693) and [agent skills](https://dev.to/redreamality_dev/agent-skills-after-the-install-button-6-reads-on-loading-gain-checks-conflicts-state-machines-2ffn).", "url": "https://wpnews.pro/news/what-an-agent-harness-actually-owns-8-reads-on-loops-cost-routing-exactly-once", "canonical_source": "https://dev.to/redreamality_dev/what-an-agent-harness-actually-owns-8-reads-on-loops-cost-routing-exactly-once-durability-and-51k4", "published_at": "2026-11-21 02:25:20+00:00", "updated_at": "2026-11-21 02:41:56.229607+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "large-language-models", "ai-research", "mlops"], "entities": ["Claude Code", "Anthropic", "Accenture", "OpenAI", "Codex", "Pi Durable", "Temporal", "LangGraph"], "also_reported_by": [], "takeaway": "Cache-safe model routing that preserves the prompt cache across model switches recovered roughly 14–21% of model spend in an emulated 10,000-seat company, and exactly-once guarantees belong in the tool's API (idempotency keys, status queries) when an immediate read-back can't show what happened.", "recommendation": {"advice": "Put exactly-once semantics in the tool contract with idempotency keys and status queries whenever a read-back can't confirm a timed-out write, and keep routing cache-safe to avoid re-sending context.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/what-an-agent-harness-actually-owns-8-reads-on-loops-cost-routing-exactly-once", "markdown": "https://wpnews.pro/news/what-an-agent-harness-actually-owns-8-reads-on-loops-cost-routing-exactly-once.md", "text": "https://wpnews.pro/news/what-an-agent-harness-actually-owns-8-reads-on-loops-cost-routing-exactly-once.txt", "jsonld": "https://wpnews.pro/news/what-an-agent-harness-actually-owns-8-reads-on-loops-cost-routing-exactly-once.jsonld"}}