Oleksandr Kuzmenko, EditorPublished 7 min readAI-assisted · editor-reviewed
TL;DR
- An agent harness can fit in 176 KB of native C/C++ code without bloated runtimes.
- Process suspension allows agents to yield memory to resource-heavy compilers like Turbo C.
- Prompt caching reduces API network round trips to ~500 bytes per turn.
Key facts
- Hardware Target
- IBM PC XT 5160 (8088 at 4.77 MHz, 640K RAM, CGA)
- Harness Executable Size
- 176 KB (HARNESS.EXE), 29 KB (CLAWDOS.EXE)
- Codebase Size
- 13,000 lines of C and C++ (Open Watcom)
- Available RAM during Turbo C Build
- ~450 KB (after harness state swap)
- Network Payload Per Round Trip
- ~500 bytes (with Anthropic prompt caching)
- Number of Native Tools
- 18 tools
Source: Key facts — Number of Native Tools
Source: Key facts. Number of Native Tools: 18 tools. Each figure is copied from the story.
- Number of Native Tools18 tools
Agent Architecture Under 640 KB of Memory
ClawDOS demonstrates agent loop engineering stripped to bare essentials. Implemented in 13,000 lines of C and C++ compiled with Open Watcom for the 8086 instruction set, the launcher CLAWDOS.EXE (29 KB) invokes HARNESS.EXE (176 KB). The harness talks directly to the Anthropic Messages API using Server-Sent Events (SSE) and JSON, storing all conversation turns as files on disk.
Because an 8088 processor cannot compute modern TLS handshakes, network bytes travel through a local bridge machine running tunnel/tunnel.py, socat, or stunnel to forward packets to api.anthropic.com:443. The tunnel can also hold the Anthropic API key so secrets never touch the vintage machine's storage.
The Memory-Eviction Compilation Pattern
To solve the severe DOS memory barrier, ClawDOS uses process suspension:
- When running small utilities, programs execute side-by-side with 200 KB free.
- For major builds with
Turbo C 2.0, Bruce's C, or assemblers (TINYASM,WASM), ClawDOS saves session state to disk and unloads itself. - Turbo C executes with ~450 KB free memory.
- The harness reloads automatically, gathers compile status and terminal output, and resumes the model conversation.
Screen Verification and Prompt Caching Efficiency
ClawDOS equips Claude with 18 tools spanning disk navigation, in-place text replacement, memory inspection (memory_read, memory_write), and PC speaker audio generation. For graphical rendering, a timer interrupt copies CGA video memory, encodes it into a PNG directly on the 8088, and uploads it to Claude for visual evaluation.
By caching system prompts and tool definitions with Anthropic's prompt caching, subsequent turns require sending only ~500 bytes of newly generated data, making multi-turn autonomous coding viable over low-bandwidth serial or packet-driver networks.
Try it in 2 minutes
python3 scripts/setup-tools.py
echo ANTHROPIC_API_KEY=sk-ant-... > .env
python3 scripts/build.py
python3 tunnel/tunnel.py
python3 scripts/run86box.pyWhen to use
- When studying minimalist agent harness architecture and low-memory state serialization patterns.
- When designing CLI or edge AI agents that must operate over constrained network bandwidth using prompt caching.
- When experimenting with retrocomputing tool execution and CGA graphic output generation via LLMs.
When NOT to use
- For standard modern software development where Claude Code or Cursor runs directly on modern operating systems.
- When direct end-to-end TLS encryption is required without intermediate proxy tunnels.
What to do today
- Clone ClawDOS and run setup-tools.py to spin up the 86Box emulation harness.
- Inspect HARNESS.EXE architecture to understand how it serializes context to C:\MEMORY before stepping out for builds.
- Apply prompt caching headers to your own custom agent tool loops to reduce bandwidth.
Step names are taken from What to do today.
Step names are taken from What to do today. Clone ClawDOS and run setup-tools.py to spin up the 86Box emulation harness.. Inspect HARNESS.EXE architecture to understand how it serializes context to C:\MEMORY before stepping out for builds.. Apply prompt caching headers to your own custom agent tool loops to reduce bandwidth.
- Clone ClawDOS and run setup-tools.py to spin up the 86Box emulation harness.
- Inspect HARNESS.EXE architecture to understand how it serializes context to C:\MEMORY before stepping out for builds.
- Apply prompt caching headers to your own custom agent tool loops to reduce bandwidth.
What the community says
Does this prove that Claude Code doesn't have to be shipped as 200MB binaries?
My harness actually has 3 distinct components: the LLM gateway, the agent session manager, and the tool server, and they can be run on different machines.
