H3 Harness SDK for Python
Python SDK for building H3-compliant agent harnesses.
Install
pip install h3-harness-sdk
Install fallback (source / git)
If a release isn't published to PyPI yet (or you want the latest unreleased changes), install directly from the repository:
# From git
pip install git+https://github.com/get-h3/sdk-python.git
# Editable source install (development)
git clone https://github.com/get-h3/sdk-python.git
cd sdk-python
pip install -e .
Quickstart
from h3_harness import (
BaseHarness,
Decision,
DecisionType,
End,
TextResponse,
create_router,
)
from fastapi import FastAPI
class MyHarness(BaseHarness):
async def on_process(self, req):
# Echo conversation history from context (battery: history preserved).
history = list(req.context.history)
# Streaming: "do not finish" in message -> unfinished text.
streaming = "do not finish" in req.message.content
finished = not streaming
return Decision(
decision=DecisionType.TEXT,
text=TextResponse(
content=f"Echo: {req.message.content}",
finished=finished,
),
history=history,
)
async def on_result(self, req):
return Decision(decision=DecisionType.END, end=End(reason="task_complete"))
app = FastAPI()
app.include_router(create_router(MyHarness()))
Testbed
from h3_harness.testbed import MockHermes
from h3_harness.examples.echo import EchoHarness
mock = MockHermes(EchoHarness())
decision = await mock.send_message("Hello!")
assert decision.text.content == "Echo: Hello!"
Examples
- echo.py — Echo harness that mirrors user messages
- minimal.py — Minimal harness with health endpoint, uvicorn runner
- langchain_agent.py — LangChain integration: LLM call with text response
Passing the battery (h3-test compliance)
The gate for any H3 harness is the test battery (test_battery.py from
get-h3/shim — 43 tests across 6 categories).
Run it against any running harness endpoint:
# The shim is not yet published to PyPI — install from source (get-h3/shim)
pip install git+https://github.com/get-h3/shim
h3-test --endpoint http://localhost:9191 # exit 0 = compliant
The Quickstart harness above implements all three conventions and is fully battery-compliant (43/43). If you modify it, keep the conventions intact — a naive harness that drops them scores 41/43. The three conventions the battery checks (beyond "return a Decision") are:
- Echo
context.historyin every Decision. The battery sends a session with prior history and asserts it flows back through the response (test_2_8_process_preserves_history). Pass it through explicitly:history = list(req.context.history) return Decision(..., history=history)
- Never issue
llm_callwhencontext.modelsis empty. The battery sendscontext.models: []and FAILS any harness that returns anllm_calldecision (test_5_8_no_models_available— "hallucinated model"). Only returnLLM_CALLwhen the request actually lists models. - Return
text.finished=falsefor "do not finish" prompts. The battery sends "Just start a thought, do not finish it yet." and asserts the response hastext.finished == False(test_2_4_process_text_finished_false). Detect streaming/unfinished intent and setfinishedaccordingly.
The canonical battery-ready template is echo.py — it implements all three conventions and scores 43/43. Use it as the starting point for your own harness.
Development
make install # create venv + install deps
make build # build wheel (and sdist) into dist/
make test # run tests
make lint # ruff check
make fmt # ruff format
Reference
- Spec: get-h3/h3 — specs/04-SDK-Libraries.md
- Protocol: get-h3/protocol
- API reference: docs/api/index.md
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file h3_harness_sdk-0.1.1.tar.gz.
File metadata
- Download URL: h3_harness_sdk-0.1.1.tar.gz
- Upload date:
- Size: 143.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7960f0d9deb53e93013e1a68f64015bfc5ace8037211f45b7ece412bd169598
|
|
| MD5 |
3c5ea5c7caa4b3deeb5d98c280bcc469
|
|
| BLAKE2b-256 |
85e96febf8f1f6d94504028be1817589578655c787d46489461e55a4a9bab3bc
|
File details
Details for the file h3_harness_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: h3_harness_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d036e0b4d33dc815f86f1e4fd7ce30b6e58f6a18c2a7432096171c4ea8decd5e
|
|
| MD5 |
c02a383fbd9e485dc1c872e1368eac0f
|
|
| BLAKE2b-256 |
32b6207373eed0423b025d59ae55d698ba732e2f64bd432a470ebf738a68b4cb
|