· EN

A Visual Guide to OpenHarness: Recreating Claude Code's Agent Architecture in 3% of the Code

OpenHarness is an open-source project from the HKUDS group at the University of Hong Kong. Its core mission is to recreate Claude Code’s Agent Harness architecture in pure Python.

What is an Agent Harness?

The model is the agent. The code is the harness.

The model provides intelligence; the harness provides the “hands, eyes, memory, and safety boundaries.” It is, in essence, all the infrastructure needed to turn an LLM into a usable agent.

Architectural overview

Interactive · Architecture Diagram
OpenHarness (oh) — Agent Harness Overview
3% of the code, 80% of Claude Code's core capabilities
Harness = Tools + Knowledge + Observation + Action + PermissionsAgent Loop (core loop)Query → LLM Stream → Tool Call → Permission Check→ Hook → Execute → Result → LooploopTools (43+)File, Shell, Web, MCPSkills (on-demand knowledge)40+ .md skill filesPluginsCompatible with claude-codePermissionsDefault / Auto / PlanHooks (lifecycle)Pre/Post ToolUseCommands (54)/help /commit /plan …MCP ProtocolExternal tool integrationMemoryCross-session persistenceCoordinatorMulti-agent collaborationConfigMulti-level settings migrationReact TUIInk-based terminal UICapability LayerSafety / Control LayerCollaboration / Extension LayerInfrastructure Layer

The core loop is refreshingly simple: Query → LLM streaming response → detect tool_use → permission check → hook → execute → return result → continue the loop, until the model decides to stop.

This architecture decomposes an agent’s capabilities into four layers — a capability layer providing tools and skills, a safety layer controlling permissions and lifecycle, a collaboration layer handling external integrations and multi-agent coordination, and an infrastructure layer responsible for configuration and UI.

Lines-of-code comparison

Interactive · Code Comparison
Code Size Comparison: 44x Lighter
Claude Code
512,664 lines · 1,884 files · TypeScript
OpenHarness
11,733 lines · 163 files · Python
98%
Tool Coverage
44x
Code Reduction
114
Unit Tests Passing
54
CLI Commands
The model is the agent. The code is the harness.
by HKUDS · MIT License · Python ≥3.11

These numbers are striking. OpenHarness uses only 11,733 lines of Python (Claude Code has 512,664 lines of TypeScript) and still covers 43 out of 44 tools. That’s enormously valuable for anyone trying to understand “how an AI agent actually runs under the hood” — it strips away the enterprise telemetry, OAuth, hundreds of React components, and other overhead, leaving only the harness skeleton.

Ten major subsystems, explained

Interactive · Subsystem Explorer
10 Subsystems · 4-Layer Architecture
Click a layer and subsystem for details
Capability Layer3 subsystems
Tools (43+)File, Shell, Web, MCP
Skills (On-Demand Knowledge)40+ .md skill files
PluginsCompatible with claude-code
Safety / Control Layer3 subsystems
Collaboration / Extension Layer3 subsystems
Infrastructure Layer2 subsystems

Why it’s worth your attention

  1. High learning value: if you want to understand Claude Code’s internal architecture, reading OpenHarness’s 11K lines of Python is far more efficient than reading 500K lines of TypeScript.
  2. Architectural clarity: it clearly shows which subsystems an Agent Harness needs and how they collaborate.
  3. Extensible: MIT License, Python ≥3.11 — a solid starting point for building your own agent systems.

The core takeaway: the model is the agent, the code is the harness. The LLM itself already has reasoning ability; the harness’s job is to plug it into tools, memory, permissions, and collaboration — so it can actually do things.

Comments

0 comments