Skip to main content

harnessrouter

A Python client and CLI for any server that speaks the Unified Harness Protocol.

A harness is a configured agent: a runtime, a model, instructions and limits. A task is one run of it — a real conversation against a real workspace, streamed back as it happens. This client sends work, follows it, continues the conversation, cancels it, and collects the files it produced.

It is a UHP client, not a client for one product. It works against the open-source HarnessRouter server, the hosted one, or any third implementation that passes the conformance suite. Standard library only — no dependency on an HTTP stack you may not want.

pip install harnessrouter

Run a task

import os
from harnessrouter import HarnessRouter

client = HarnessRouter("http://localhost:3000", os.environ["UHP_API_KEY"])

harness = client.harnesses()[0]
response = client.run("Summarise README.md in three bullets.", harness_id=harness["id"])

response["status"]   # 'completed'
response["output"]   # ordered items: message, reasoning, function_call, function_call_output

Follow it while it happens

Agent tasks run for minutes. Without a stream a product can only show a spinner and hope.

for event in client.stream("Add tests for the parser.", harness_id=harness["id"]):
    if event["type"] == "response.output_text.delta":
        print(event["delta"], end="", flush=True)

Or let the client assemble it for you:

task = client.collect("Add tests for the parser.", harness_id=harness["id"])
task.text          # the finished text
task.tool_calls    # what the agent ran
task.annotations   # the files it wrote
task.sequence      # (False, [12]) if the stream dropped an event

Continue, cancel, collect

nxt = client.continue_(response["id"], "Now add tests for the function you just wrote.")
# same session, same working directory, same files

client.cancel(nxt["id"])                      # a request to stop; the session stays continuable
files = client.session_files(nxt["metadata"]["session_id"])
data = client.download_file(files[0]["container_id"], files[0]["id"])

What it does for you

  • Idempotency by default. Every run carries an Idempotency-Key, so a retry cannot start a second agent against the same files.
  • Retries only what is worth retrying. session_busy and 503s back off and try again; quota_exhausted and every malformed request do not. A POST /v1/responses that may already have started is never resent on the client's own initiative.
  • Errors you can branch on. UhpError carries the server's type, code, param and detail, plus a retryable property — no parsing prose to decide what to do.
  • Long timeouts. 15 minutes by default, because a 30-second timeout cancels healthy work.

CLI

export UHP_BASE_URL=http://localhost:3000
export UHP_API_KEY=…

harnessrouter discover                       # what the server is, and what it supports
harnessrouter harnesses                      # chrn_…  Research agent  [claude-code]
harnessrouter stream "Summarise README.md" --harness chrn_…

API

Method What it does
discover() The server's version, conformance class and capabilities (no token needed)
harnesses(), harness(id) Configured harnesses in your scope
models(), harness_models(id) Model catalogues, with a computed available
run(input, ...) Run a task and wait for the result
stream(input, ...) Run a task and iterate its events
collect(input, ...) Run, stream, and return the accumulated task
continue_(response_id, input) Continue the session that produced that response
get_response(id), input_items(id), wait(id) Read a task back, or poll it to a terminal state
cancel(id), delete_response(id) Stop work; delete history. Deliberately different things
sessions(), session(id), turns(id), session_files(id) Session listing and inspection
download_file(container_id, file_id) Artifacts out

Specification

https://github.com/HarnessRouter/harnessrouter/tree/main/protocol

Apache-2.0.

Metadata

Release files for harnessrouter 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for harnessrouter 0.1.0
File Size Uploaded Provenance Actions
harnessrouter-0.1.0.tar.gz 12.5 kB Without provenance Details for harnessrouter-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for harnessrouter 0.1.0
File Interpreter ABI Platform Actions
harnessrouter-0.1.0-py3-none-any.whl Python 3 none any Details for harnessrouter-0.1.0-py3-none-any.whl

Total release size: 26.0 kB

Release files / harnessrouter-0.1.0.tar.gz

Download URL harnessrouter-0.1.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c0fee735f3a18ad5c01681dfa771a19a24b3ecc640c724b7aea3e9ff962fa61f
BLAKE2b-256 checksum
How to use checksums
b65801be95a986354927397c5e048786a9da9a96b6d64bf8586bdd324ba151b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / harnessrouter-0.1.0-py3-none-any.whl

Download URL harnessrouter-0.1.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
057be285b458c74f0619f2f9d6307ea3a7b7dcf84e108f5c4b957a44f37d70cd
BLAKE2b-256 checksum
How to use checksums
ec41ef7584dbf00e8711e0845810f8248085c6d797e7faed9802df8753140a77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for harnessrouter 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page