Skip to content

Harness PY ​

OpenHands-Style Event-Stream Agent Platform · 30-Day Tutorial ​

Project Status: D030 / 30 · v0.1.0 · MIT
Technology Stack: Python 3.11+ · uv · FastAPI · WebSocket · OpenAI-compatible SSE
Study Label: OpenHands-clone; public codename harness-py.

Harness PY studies the Event/Action/Observation event stream in OpenHands' classic Python architecture, connecting the local Runtime, CodeAct Loop, Controller, CLI, REST, and WebSocket to the same persistent event contract.

← Back to Series Overview · View Source Code · Upstream OpenHands

MVP Features ​

Event Model and Persistence ​

  • Strongly typed Event, Action, and Observation models with JSON encoding and decoding.
  • JSONL persistence, Offset Replay, and partial-tail recovery.
  • Asynchronous EventStream, Replay/Live Subscription, and bounded queues.
  • REST, WebSocket, CLI, and replay share the same event contract.

Runtime and Tools ​

  • Local Shell Runtime and Editor Runtime.
  • Explicit Runtime Registry and dependency injection.
  • Fail-closed Confirmation for dangerous commands.
  • Provider, Runtime, and storage can all be replaced with offline test implementations.

CodeAct and Controller ​

  • CodeAct output parsing and a bounded Step Loop.
  • AgentController lifecycle states.
  • OpenAI-compatible SSE Client and Pre-stream Retry Policy.
  • Deterministic System Prompt Builder.
  • Markdown Microagent trigger injection and conservative rule matching.

Services and Entry Points ​

  • Headless Application and CLI run.
  • FastAPI REST Routes and WebSocket Event Stream.
  • Static Event Viewer for inspecting event sequences.
  • Wheel builds and clean venv installation acceptance.

Why the Python Architecture Version Is Pinned ​

The research pin is OpenHands 0.62.0, the final release of the classic Python architecture. Later upstream releases have moved to other technical architectures. Because this tutorial focuses on Event-first design, it is pinned to a specific version to keep the course consistent.

30-Day Learning Focus ​

StageMain Topics
Event FundamentalsEvent/Action/Observation, JSON Codec, and JSONL
EventStreamAsynchronous streams, Offset Replay, Live Subscription, and recovery
RuntimeShell, Editor, dangerous-command confirmation, and explicit registration
AgentCodeAct Parser, bounded Loop, Controller, and Provider
Service LayerFastAPI, WebSocket, Headless CLI, and Event Viewer
ReleaseMicroagent, Prompt, type checking, coverage, builds, and installation

Explicitly Outside the MVP Scope ​

OAuth, SQL persistence, LSP, desktop UI, a plugin marketplace, Docker Runtime, multi-tenant isolation, and a complete model catalog are future work. WebSocket reconnection uses an Offset mechanism rather than a full managed-client protocol.

Clean Room and Licensing ​

The project records research notes, third-party attributions, and a Clean-room Log. It independently implements the classic event-stream behavior without copying upstream code; the project's own implementation is released under MIT.

Keep building. Stay curious.