Building OpenHarness: Every Part of the Agent Harness, Yours Prakhar Gurunani released OpenHarness, an MIT-licensed web app that lets users configure all 14 components of an AI agent harness, test it with their own model key, and download it as a single binary for macOS, Linux or Windows that serves an OpenAI-compatible API. OpenHarness comprises about 5,700 lines of Go with no third-party dependencies, 3,200 lines of hand-written HTML/CSS/JS with no build step, and 1,800 lines of Python test fixtures, and it compiles a JSON HarnessSpec into a native executable in about a second. The project follows DeepSeek's August open-sourcing of its plugin-based agent harness, whose community whitepaper counts 26 seams, 52 built-in tools and 44 session event types; Gurunani mapped those seams down to the 14 components that make sense for an agent behind an HTTP API. Building OpenHarness: Every Part of the Agent Harness, Yours What if you could compile your own agent harness? In the last post https://prakhargurunani.com/blog/building-an-agentic-coding-server-in-go/ I built harness-api : one opinionated coding agent behind an OpenAI-compatible endpoint. Every decision in it was mine: the tools, the context strategy, the guards, the loop. That’s fine for a coding agent. But each time someone asked for a variation “can it remember things across chats?”, “can it call our internal API?”, “can it check its own answer first?” , the answer was the same: fork it and change the Go . In August, DeepSeek open-sourced its agent harness https://github.com/deepseek-ai/deepseek-harness built on a single idea: everything is a plugin . The model adapter, the tool registry, the session log, the agent loop itself: all of them are replaceable from configuration. Reading it raised the obvious next question. If every part of a harness can be swapped, why does assembling one still require writing code? So I built OpenHarness https://openharness.prakhargurunani.com : a web app where you walk through every component of a harness, change whatever you want, chat with the result, and download it as one binary for macOS, Linux or Windows that serves an OpenAI-compatible API. Optionally, you also get a Dockerfile to run it in a container. It’s about 5,700 lines of Go with no third-party dependencies, 3,200 lines of hand-written HTML/CSS/JS with no build step, and 1,800 lines of Python test fixtures. The interesting parts were: - deciding what a “component” actually is - turning a JSON document into a native executable in about a second - letting strangers run agents on my server without handing them my server Getting started - App: openharness.prakhargurunani.com https://openharness.prakhargurunani.com - Source: github.com/FirePing32/OpenHarness https://github.com/FirePing32/OpenHarness , MIT licensed Pick a preset Minimal, Research assistant, Coding agent, Support agent , walk through the 14 component steps, test it on the Test step with your own model key, then pick your OS on Build & download . Run what you get: chmod +x ./research-agent-darwin-arm64 export DEEPSEEK API KEY=sk-... ./research-agent-darwin-arm64 And talk to it with the SDK you already have: python from openai import OpenAI client = OpenAI base url="http://127.0.0.1:8080/v1", api key="unused" resp = client.chat.completions.create model="research-agent", messages= {"role": "user", "content": "What changed in Go 1.26?"} , print resp.choices 0 .message.content The client sends one request. Inside, the agent may plan, call a dozen tools, delegate to a sub-agent and check its own answer before replying. The shape of the system There are two programs and one document. The builder is a Go server with an embedded UI. It edits, tests and compiles a HarnessSpec . The agent binary runs that spec. Both use the same runtime package, so the agent you chat with in the browser is the one you download. What is a harness, exactly? LangChain’s definition is the cleanest I’ve found: the harness is every piece of code, configuration and execution logic that isn’t the model itself . That is true, but it isn’t a list you can build a UI from. DeepSeek Harness gives a better starting point. It’s built on a small kernel called Cordis, where plugins contribute services, typed events and reversible effects to a shared context. Each capability is a seam with three roles: an interface ctx.llm , one or more providers llm-deepseek , and consumers. The community whitepaper counts 26 seams, 52 built-in tools and 44 session event types. Not all of those make sense for an agent that lives behind an HTTP API. A web UI seam, an LSP client or a terminal multiplexer don’t. After mapping every seam, I ended up with 14 components , each of which became one step in the builder: | Component | DeepSeek seam | What you can change | |---|---|---| | Identity & API | ctx.webServer | name, port, model id, bearer auth, CORS | | Model adapter | ctx.llm | provider, sampling, retries, fallback chain | | System prompt | ctx.systemPrompt | sections, date, tool summary, client policy | | Tools | ctx.tools , ctx.mcpManager | built-ins, HTTP tools, MCP servers, truncation | | Skills | ctx.skills | progressive or eager loading | | Memory | ctx.storage | static notes, persistent store, per-user scope | | Sessions | ctx.sessions | stateless, or server-side JSONL history | | Context | ctx.compaction | sliding window or summarise, tool-result pruning | | Agent loop | ctx.agentLoop | ReAct / plan-then-execute / single shot, budgets, self-check | | Sub-agents | ctx.subagents | specialists with their own prompt, model and tools | | Permissions | ctx.approval | allow/deny per tool, webhook approval, workspace jail | | Guardrails | waterfall listeners | block / redact / warn rules, PII redaction | | Hooks | agent/pre-step , tools/ | webhooks that observe, inject or veto | | Observability | ctx.sessionTelemetry | log level, JSONL traces, usage | Each step in the builder shows its DeepSeek equivalent and a one-line “why it matters”. The UI doubles as documentation for the research. The spec is the product DeepSeek composes plugins through layered patch files: profile, then bundles, then a home patch, then --patch overlays. That’s powerful, and it’s the wrong shape for a form. OpenHarness collapses it into one declarative JSON document . Every field in the UI is a path into it, model.temperature or loop.selfCheck.maxRevisions , and nothing else exists. Three rules kept it honest: Defaults are layered under whatever you send. spec.Parse decodes your JSON on top of spec.Default , so {"name": "x", "loop": {"maxSteps": 3}} is a complete, valid agent. Imports, presets and the --spec flag all go through the same path. Validation returns every problem, not the first. Validate returns a list like loop.maxSteps: must be = 1 , model.baseUrl: required and so on. The UI maps each prefix back to its step, so the sidebar shows an error badge on the right component and the Build step links straight to it. One set of Go types everywhere. The builder server, the preview, the compiled binary and the validation all use spec.Spec . The UI is the only consumer that isn’t Go, and it works from the same JSON and the same catalog endpoint. The runtime The runtime is the part that actually runs agents, and the same code serves the browser preview and the downloaded binary. One loop, three strategies The default is a ReAct loop: call the model, run any tools it asks for, feed the results back, repeat. Plan-then-execute adds a planning call with no tools. Single shot removes the loop entirely and turns the harness into a smart proxy. Self-check wraps any of them with a review pass that either replies APPROVED or returns a corrected answer, up to maxRevisions times. One detail took two tries. The plan goes in as a system message, and at first I appended it after the user’s request. That left every model call ending on the harness’s own note instead of on what the user asked. It now goes just before the latest user message , so the request stays last. Every loop has three budgets: steps, total tool calls and wall-clock time. When one runs out, the agent either makes a final no-tools call “reply with your best answer and say what’s unfinished” or returns an error, whichever you chose. Tools are a pipeline, not a function call Every tool call goes through the same stages, in order: 1. look up the tool 2. check permissions tool name, then group such as mcp:github , then the default 3. run pre tool hooks, which can veto the call 4. execute it with a timeout 5. truncate the result, keeping head and tail with a marker in between 6. run post tool hooks Built-in tools, HTTP tools, MCP tools, skills, memory and sub-agents all look the same to the loop. The only differences are where Run comes from and which permission group they’re in. The tools a client sends in its OpenAI request tools: ... pass through . If the model calls one, the turn ends with finish reason: tool calls and the client runs it, exactly like the OpenAI API. That’s what lets LangChain’s bind tools work against a harness that also has its own server-side tools. Streaming has two channels OpenAI chunks carry content . The harness also streams agent activity : plans, tool calls and results, compaction, self-check verdicts. It sends these as reasoning content , the field reasoning models already use, so clients that don’t know about it simply ignore it. Streaming the answer token by token is only safe when nothing will change it afterwards. With self-check on, or any output guardrail that can redact or block, the answer is buffered and sent once it’s final. Otherwise a draft would leak before the review rewrote it, or a phone number would stream out before the redaction matched. Sessions on a stateless API The OpenAI API is stateless: clients resend the whole transcript every time. That’s the default here too. In server mode the harness keeps an append-only JSONL log per session from an X-Session-Id header or the user field , so clients can send just the new message, and internal tool calls survive between turns. The hard part is that clients don’t tell you which kind they are. The rule that works: compare the incoming user messages against the stored ones. If the stored history is a prefix, the client sent the full transcript and only the tail is new. Otherwise everything is new. The QA fixtures more below found the hole in that rule. A client that sends only the latest message and says “continue” twice looked like a re-sent transcript, and the second “continue” was silently dropped. The fix: a lone user message with no assistant messages is always new. Context: prune before you summarise Two mechanisms, applied before every model call: - Pruning: tool results older than the last N are cut to a few thousand characters. That’s cheap and often enough on its own. - Compaction , when the estimated size crosses a ratio of the budget, has two modes: - sliding window: drop the oldest messages behind a note; - summarise: make one extra model call to condense them. The cut never lands between an assistant’s tool call and its results. If the summary call fails, it falls back to the sliding window instead of failing the turn. Two providers, one message type Internally there’s one Message type that round-trips the OpenAI wire format, including multimodal content arrays. The Anthropic adapter converts at the edge: - system messages are hoisted into system ; - tool calls become tool use blocks, and tool results become user tool result blocks; - consecutive same-role turns are merged; - a conversation that starts with the assistant gets a placeholder user turn. Fallbacks can cross providers. If the DeepSeek primary keeps returning 500s after its retries, a Claude fallback answers, and the client never knows. Compiling a spec into a binary My first idea was code generation: render a main.go per agent. It’s the wrong abstraction. The runtime is fixed; only the data changes. So the spec rides into a prebuilt runtime as a link-time string : go build -trimpath \ -ldflags "-s -w -X main.embeddedSpec=