TAU-HOME.COM
LOADING

If Coding Agents Feel Like a Black Box, Try Building Your Own Harness

A hands-on tip from KC (@ScarletKc): build even a crude coding-agent harness yourself to demystify the agent loop, context packing, compression, and when to ask

tau · November 21, 2026

#AICoding #AgentLoop #Harness #ClaudeCode #Codex

If Coding Agents Feel Like a Black Box, Try Building Your Own Harness

A developer desk with a minimal diagram of a coding-agent loop connecting a prompt, tool calls, and context on a monitor

Image source: Contocrat Fan · CC BY 4.0 · https://creativecommons.org/licenses/by/4.0 · https://commons.wikimedia.org/wiki/File:Contocracy_icon.png

The original author is KC (@ScarletKc) on X, who shared the process of hand-building a coding-agent harness on October 11, 2026. The point: anyone who writes code with AI every day should try building one, however crude.

Translation of the original post

Lately I've been hand-building a harness, and the more I build, the more I feel that the way I used to use Claude Code and Codex was using a black box. How the agent loop turns, how tool results get stuffed back into context, how to compress context when it's nearly full, when to stop and ask a human — no matter how much documentation I read, these stayed half-understood. After digging through the source of many open-source projects and rewriting one from scratch myself, much of what used to feel like magic suddenly became explainable. The payoff is absurdly large. I think everyone who writes code with AI daily should build one of their own, even a very crude one.

Four questions that building one answers

The core of the tip is not grand theory but four practical questions every harness operator runs into daily.

  • How does the agent loop actually run
  • In what form do tool results go back into context
  • How do you compress context when it is nearly full
  • When should you stop and ask a human

According to the original post, reading documentation alone leaves these half-understood, but reading open-source implementations and writing one from scratch makes previously mysterious agent behaviors start to make sense.

Practical caveats from the replies

Replies in the same thread add realistic footnotes to the proposal.

  • @chenkumi says building a loop once from the API is worthwhile, but after that it is faster to modify a mature framework than to keep tinkering. Otherwise you can burn through tokens on low-level plumbing without ever shipping features. The original author replied that low-level SDK options are scarce, so modifying an official implementation looks like the practical path.
  • @xintongai adds that writing the loop yourself reveals the experience gap is mostly in "how context gets trimmed and how tool output gets fed in" rather than in the model itself. The original author's reaction is honest: building from zero is "too complicated and too much trouble, not something an ordinary person can do."
  • @oklauuuuu names another benefit of owning a harness: "not being locked into one model, being able to switch to another vendor anytime." But long tasks and aesthetic quality still lag behind big-vendor products, and whether that is a model limitation or something else is unclear. The original author answered: "it's the model's difference."
  • The volume of edge cases comes up repeatedly. The original author replied that there are "too many edge issues... fixing them is exhausting," and exchanged the same sympathy with another replier (@klarkxy).

How to use this tip

The suggested practice is simple. Don't aim for a finished product; just wire up one minimal loop by hand. Send a prompt, receive the model's next action (a tool call or an answer), attach the tool result back to the context, and pass it to the next call. Once you connect that cycle yourself, much of the "strange behavior" in the coding agents you use daily starts reading as context-trimming and tool-output-handling issues.

But keep the replies' warnings alongside it. Building one loop to learn and maintaining a production harness from scratch are different jobs. If you want the latter, the thread's rough consensus is to start from a mature open-source implementation or an official SDK.

Original source

Impact-Site-Verification: 9b3ebd10-6c45-44cf-a014-5b8c19b7b285