AI Agents Are Just a Brain and a Harness — Here's the Harness
Most developers use AI coding tools as black boxes. Building the harness by hand exposes exactly where the model's autonomy ends and the engineering begins — file I/O, tool dispatch, error recovery — which is the part that determines whether an agent is safe and useful in production.
The core of any AI coding agent — Cursor, Claude Code, or a custom tool — is a large model paired with a harness. The model supplies reasoning; the harness supplies file access, command execution, safety limits, and retry logic. Without the harness, the model can only chat. This series builds that harness from scratch in TypeScript, starting with the simplest possible pipeline: a Node.js CLI that reads a prompt, calls an OpenAI-compatible API, and prints the response.
The first installment sets up the project, configures TypeScript, and writes three single-responsibility modules: config loading, a chat client wrapper around the OpenAI SDK, and a CLI entry point that parses `-prompt` from `process.argv`. The result is a working command-line assistant that answers one question at a time.
It is not yet an agent — it cannot read files, run commands, or loop on failures. Those capabilities come next, when the harness gains a toolbox the model can invoke. The article frames the entire series as a deliberate demystification: agents are not magic, just a disciplined engineering loop around an API call.
Demystifying agents as a model-plus-harness formula lowers the barrier to building custom coding tools; the harness is just structured I/O and control flow around an API call.
OpenAI's API format has become a de facto standard that domestic Chinese models follow, which means a single client abstraction works across providers — a practical detail often glossed over in agent discussions.
Starting with a single-turn CLI before adding tools is a deliberate pedagogical choice: it forces the builder to understand the request-response loop before introducing the complexity of tool-calling and multi-step reasoning.