Skip to main content
The @openharness/react package provides hooks that wire into AI SDK 5’s useChat and track OpenHarness-specific state like subagent activity, compaction, and turn lifecycle.

Setup

Wrap your app (or chat component) with OpenHarnessProvider:

useOpenHarness

Creates a chat session connected to your API endpoint. Returns the same interface as AI SDK 5’s useChat (messages, sendMessage, status, stop, etc.), typed with OHUIMessage:

Resuming Streams

Pass a stable id and resume: true to reconnect to an active server-side stream when the component mounts:
By default, reconnect attempts use GET ${endpoint}/${id}/stream. The server must own the active run and return the active stream or 204 when no stream is running.
AI SDK stream resumption is not compatible with treating browser request abort as cancellation. If a user needs to stop a background run, expose a separate server-side cancel action.

useSubagentStatus

Derives reactive state from data-oh:subagent.* events:
  • activeSubagents — currently running subagents
  • recentSubagents — all subagents seen in this session
  • hasActiveSubagents — boolean shorthand

useSessionStatus

Tracks turn index, compaction state, and retry info from data-oh:* events:

useTodos

Tracks the latest todo list from data-oh:todo.updated events emitted by the core todo tools:

Full Example