Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

gateway: background responses answer in UHP's status vocabulary, in_progress and never running (#512)

aswathasf5b1110ffecd
diff --git a/gateway/app.py b/gateway/app.py
index 1e427d8a..aba83a1c 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -2919,7 +2919,11 @@ async def _adopt_orphan_turn(sid: str, org: str, v: dict) -> bool:
# deliverable (a Stop that lands after the file is saved, an OOM at finalize) — skipping
# collection threw those files away from the record while they sat in the workspace.
produced = await _collect_produced(sid, set())
- for oev in translator.complete(rec["status"], produced):
+ # Translate for the wire, the same way the persist just below does: `rec["status"]` holds
+ # the trace's name for the outcome (`done`, `max_turns`, `timeout`), and `complete()` both
+ # puts it in the response object and looks the event name up by it, so an untranslated
+ # status reached subscribers as `status: "max_turns"` under a `response.completed` (#480).
+ for oev in translator.complete(_RESP_STATUS_MAP.get(rec["status"], "failed"), produced):
_emit(oev)
except Exception: # noqa: BLE001
pass
@@ -8055,6 +8059,32 @@ def _strip_internal(d: dict) -> dict:
return {k: v for k, v in d.items() if not k.startswith("_")}
+# The gateway's internal lifecycle names for the one non-terminal state, and UHP's name for it.
+# `lifecycle.md` §3 has five statuses; `running` is not one of them, so a stored record read
+# through any UHP response object used to answer a status the protocol does not define, while
+# streaming already emitted `in_progress` from the same turn. The map is total over every name the
+# gateway uses, not just the ones written today: `_RESP_TERMINAL` and `_RESP_STATUS_MAP`'s keys
+# name `done`, `max_turns`, `timeout` and `error`, and a record written by an older build can
+# still carry one. Those translate here rather than at the write, so no exit needs to remember to.
+_UHP_STATUS = {"running": "in_progress", "starting": "in_progress", "queued": "in_progress",
+ "in_progress": "in_progress", "completed": "completed", "failed": "failed",
+ "incomplete": "incomplete", "cancelled": "cancelled",
+ "done": "completed", "max_turns": "incomplete", "timeout": "incomplete",
+ "error": "failed"}
+
+
+def _public_response(rec: dict) -> dict:
+ """The response object as it leaves the gateway: internal fields dropped, status in UHP's
+ vocabulary. A dedicated formatter rather than a rule inside `_strip_internal`, whose one job
+ is dropping `_`-prefixed keys; the status rule is a protocol rule, so the two stay readable
+ apart. The STORED value is untouched: the console's turn list and the reconcile sweeps read
+ `running` from the record itself and must keep seeing it."""
+ d = _strip_internal(rec)
+ if "status" in d:
+ d["status"] = _UHP_STATUS.get(str(d["status"]), d["status"])
+ return d
+
+
# Harness-internal seed/config files the runner writes into the workspace to drive the agent
# (e.g. AGENTS.md surfaces installed skills for codex; CLAUDE.md is the claude equivalent). They are
# never user-facing artifacts, so they must never appear in a turn's output file list.
@@ -9324,6 +9354,24 @@ def _ignored_request_fields(body: "CreateResponseBody") -> list[str]:
_IDEM_TERMINAL = {"completed", "failed", "incomplete", "cancelled", "error"}
+# The event name a terminal status gets on the wire. streaming.md §2.1 names all three; the
+# replay path used to fold everything that was not `completed` into `response.failed`, so a turn
+# that stopped at a limit was announced as an error rather than as the partial result it was.
+_IDEM_EVENT = {"completed": "response.completed", "incomplete": "response.incomplete",
+ "cancelled": "response.failed", "failed": "response.failed"}
+
+
+def _synth_response(resp_id: str, status: str, error: dict | None = None) -> dict:
+ """A response object for an event with no record behind it. `Event.response` is a `$ref` to
+ `Response`, whose `required` is id, object, created_at, status, output and model, so a literal
+ carrying three of the six fails schema validation even when every field it does carry is right.
+ The id and the status are the two the caller knows; the rest are filled so the frame holds."""
+ body = {"id": resp_id, "object": "response", "created_at": int(time.time()),
+ "status": status, "output": [], "model": ""}
+ if error:
+ body["error"] = error
+ return body
+
async def _idem_replay(resp_id: str, stream: bool):
"""A duplicate request (same Idempotency-Key) returns the FIRST request's result instead of
@@ -9340,17 +9388,30 @@ async def _idem_replay(resp_id: str, stream: bool):
if not stream:
rec = await _await_terminal()
- return JSONResponse(rec or {"id": resp_id, "status": "unknown",
- "error": {"message": "idempotent replay: original response not found"}})
+ if not rec:
+ # A missing original is the same answer the GET gives for an unknown id. The old
+ # `{"status": "unknown"}` body named a status UHP does not define (#480).
+ raise uhp_error(404, "response_not_found",
+ "idempotent replay: original response not found", "response_id")
+ return JSONResponse(_public_response(rec))
async def gen():
created = {"type": "response.created", "sequence_number": 0,
- "response": {"id": resp_id, "object": "response", "status": "in_progress"}}
+ "response": _synth_response(resp_id, "in_progress")}
yield f"data: {json.dumps(created)}\n\n"
rec = await _await_terminal()
- st = str((rec or {}).get("status") or "failed")
- ev = "response.completed" if st == "completed" else "response.failed"
- yield f"data: {json.dumps({'type': ev, 'sequence_number': 1, 'response': rec or {'id': resp_id, 'status': st}})}\n\n"
+ if not rec:
+ # The stream already opened, so this cannot become a 404 the way the non-stream
+ # branch's does. It ends on the one event a client can act on, carrying the same
+ # code the GET would have answered (#480).
+ body = _synth_response(resp_id, "failed",
+ {"type": "invalid_request_error", "code": "response_not_found",
+ "message": "idempotent replay: original response not found",
+ "param": "response_id"})
+ yield f"data: {json.dumps({'type': 'response.failed', 'sequence_number': 1, 'response': body})}\n\n"
+ return
+ st = str(rec.get("status") or "failed")
+ yield f"data: {json.dumps({'type': _IDEM_EVENT.get(st, 'response.failed'), 'sequence_number': 1, 'response': _public_response(rec)})}\n\n"
return StreamingResponse(gen(), media_type="text/event-stream",
headers={"Cache-Control": "no-cache", "X-Accel-Buffering": "no"})
@@ -9692,7 +9753,9 @@ async def create_response(body: CreateResponseBody, request: Request):
task.add_done_callback(_inflight.discard)
# Return a SNAPSHOT (copy the output list) so the immediate JSON can't alias the list the
# detached task appends to. Already persisted 'running'; poll GET /v1/responses/{id}.
- _snap = tr._response_obj("running")
+ # The answer is built straight, not from the stored record, so it carries UHP's name for
+ # the state (`in_progress`) rather than the gateway's internal one (#480).
+ _snap = tr._response_obj("in_progress")
_snap["output"] = list(_snap.get("output") or [])
return _snap
@@ -9989,7 +10052,7 @@ async def get_response(response_id: str, request: Request):
# Durable settler for async/background polling: never leave a poller stuck at 'running' if the
# owning turn actually finished/died (reconciled from the session vertex + trace).
rec = await _reconcile_response(response_id, rec)
- return _strip_internal(rec)
+ return _public_response(rec)
@app.get("/v1/sessions/{sid}/turns")
@@ -10472,7 +10535,7 @@ async def cancel_response(response_id: str, request: Request):
except Exception: # noqa: BLE001
pass
rec = await _resp_get(response_id) or rec
- return _strip_internal(rec)
+ return _public_response(rec)
# ── files: upload (in) + container content (out) ────────────────────────────────────────
diff --git a/gateway/tests/test_public_response_status.py b/gateway/tests/test_public_response_status.py
new file mode 100644
index 00000000..7fdb5af3
--- /dev/null
+++ b/gateway/tests/test_public_response_status.py
@@ -0,0 +1,348 @@
+"""A response object that leaves the gateway says what UHP says, not what the gateway calls it
+internally (#480).
+
+`lifecycle.md` §3 names five statuses. The gateway stored a background record as `running` and
+answered `GET /v1/responses/{id}` and the background POST with that name, so a client written to
+the spec waited for `in_progress` forever or treated the turn as an error, while streaming had
+already emitted `in_progress` for the very same turn. The stored value stays `running`: the
+console's turn list and the reconcile sweeps read it there, and they are not UHP response objects.
+"""
+import ast
+import asyncio
+import json
+import os
+import pathlib
+import sys
+import time
+
+import pytest
+from fastapi.testclient import TestClient # noqa: E402
+
+sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
+os.environ.setdefault("HR_BACKING", "local")
+import app as gw # noqa: E402
+
+
+ORG = "org_e"
+UHP_STATUSES = {"in_progress", "completed", "failed", "incomplete", "cancelled"}
+
+# Every status a stored response record can carry, split by how it gets there. WRITTEN is what the
+# gateway's own write paths persist. READ_ONLY is what the read guards tolerate but nothing
+# writes into a record today: they are mapped anyway, because a total map is what stops a future
+# alias from leaking, and because a legacy record written by an older build can still carry one.
+WRITTEN = {
+ "running": "persist('running'), the in-flight write before the turn starts",
+ "completed": "persist() with the turn's terminal status; _RESP_STATUS_MAP['done'|'completed']",
+ "incomplete": "persist() with the turn's terminal status; _RESP_STATUS_MAP['max_turns'|'timeout']",
+ "cancelled": "cancel_response and stop_session settle the record",
+ "failed": "persist('failed') on lease refusal, hydrate failure, an unhandled exception",
+}
+READ_ONLY = {
+ "starting": "a turn's trace record opens with it; never stored on a response record",
+ "queued": "named by the cancel path's live check; nothing writes it",
+ "done": "_RESP_STATUS_MAP's key for completed, translated before storage",
+ "max_turns": "_RESP_STATUS_MAP's key for incomplete, translated before storage",
+ "timeout": "_RESP_STATUS_MAP's key for incomplete, translated before storage",
+ "error": "_RESP_STATUS_MAP's key for failed, translated before storage",
+}
+INTERNAL_STATUSES = {**WRITTEN, **READ_ONLY}
+
+
+def api(monkeypatch):
+ async def principal(request):
+ return {"org": ORG, "member": "me@local"}
+ monkeypatch.setattr(gw, "_principal", principal)
+ monkeypatch.setattr(gw, "_response_in_reach", lambda p, rec: asyncio.sleep(0, True))
+ monkeypatch.setattr(gw, "_harness_in_reach", lambda p: asyncio.sleep(0, True))
+ return TestClient(gw.app)
+
+
+def _store(rid: str, status: str) -> dict:
+ """Write a response record straight through `_resp_put`, the way the turn's own writes do."""
+ rec = {"id": rid, "object": "response", "created_at": int(time.time()), "status": status,
+ "output": [], "_session_id": "hsess1", "_org": ORG, "_member": "me@local",
+ "_input": [{"role": "user", "content": "hi"}], "_backend": "dsh"}
+ asyncio.run(gw._resp_put(rid, rec, ORG, "hsess1", None, status, rec["created_at"], True))
+ return rec
+
+
+# ── the mapping itself ─────────────────────────────────────────────────────────────────
+
+def test_the_map_covers_every_internal_status_the_gateway_writes():
+ """A new internal name cannot leak later: every status any write path can produce has to land
+ in one of the five UHP statuses, and the five must pass through unchanged."""
+ for status in INTERNAL_STATUSES:
+ assert gw._UHP_STATUS.get(status) in UHP_STATUSES, (
+ f"{status!r} ({INTERNAL_STATUSES[status]}) maps to "
+ f"{gw._UHP_STATUS.get(status)!r}, which is not a UHP status")
+ for status in UHP_STATUSES:
+ assert gw._UHP_STATUS.get(status) == status
+
+
+def _write_path_status_literals() -> set:
+ """Every status literal the write and emit paths in app.py can pass.
+
+ `_RESP_STATUS_MAP` and `_RESP_TERMINAL` are both alias tables, so walking them finds the names
+ that go *through* a translation and misses the ones written straight into a record — `running`
+ among them, the name this issue is about. Reading the literals out of the source is what closes
+ that gap: rename `await persist("running")` to any other name and this finds it.
+ """
+ tree = ast.parse(pathlib.Path(gw.__file__).read_text(encoding="utf-8"))
+ # A call whose function name matches, and whose argument at this index is a bare string
+ # literal, is a status literal. `_resp_put` takes the status at index 4, `persist` at 0.
+ want = {"persist": 0, "_resp_put": 4, "_response_obj": 0, "complete": 0}
+ found = set()
+ for node in ast.walk(tree):
+ if not isinstance(node, ast.Call) or not isinstance(node.func, ast.Name):
+ continue
+ idx = want.get(node.func.id)
+ if idx is None or len(node.args) <= idx:
+ continue
+ arg = node.args[idx]
+ if isinstance(arg, ast.Constant) and isinstance(arg.value, str):
+ found.add((node.func.id, arg.value))
+ return found
+
+
+def test_every_status_literal_the_write_path_uses_is_named_in_the_table():
+ for func, value in sorted(_write_path_status_literals()):
+ assert value in INTERNAL_STATUSES, (
+ f"{func}(...) is given the status literal {value!r}, which is not named in "
+ f"WRITTEN/READ_ONLY; an unmapped status reaches the client verbatim")
+
+
+def test_the_every_value_the_gateway_can_store_is_named_in_the_table():
+ """The tables above are the claim; this is the check. `_RESP_STATUS_MAP` is the one place
+ that translates a trace or vertex status into a stored one, so both its keys and its values
+ are enumerable, and every one of them must be mapped."""
+ for name, mapped in gw._RESP_STATUS_MAP.items():
+ assert mapped in UHP_STATUSES, f"_RESP_STATUS_MAP['{name}'] = {mapped!r} is not a UHP status"
+ assert name in INTERNAL_STATUSES, (
+ f"_RESP_STATUS_MAP maps {name!r}, which the enumeration test does not name")
+ for name in gw._RESP_TERMINAL:
+ assert name in INTERNAL_STATUSES, (
+ f"_RESP_TERMINAL treats {name!r} as a stored terminal status, which the enumeration "
+ "test does not name; if a record can carry it, it needs a mapping")
+
+
+def test_the_formatter_drops_internal_fields_and_translates_the_status():
+ rec = {"id": "resp_1", "status": "running", "output": [], "_org": ORG, "_input": [{"x": 1}]}
+ out = gw._public_response(rec)
+ assert out["status"] == "in_progress"
+ assert out == {"id": "resp_1", "status": "in_progress", "output": []}
+
+
+def test_the_formatter_leaves_the_stored_record_alone():
+ """The console and the sweeps read `running` from the record itself. The formatter copies."""
+ rec = {"id": "resp_1", "status": "running", "_session_id": "hsess1"}
+ gw._public_response(rec)
+ assert rec["status"] == "running" and rec["_session_id"] == "hsess1"
+
+
+def test_a_status_with_no_mapping_is_passed_through_not_silently_rewritten():
+ """Better a visible wrong value the enumeration test catches than a quiet invention."""
+ assert gw._public_response({"id": "r", "status": "wat"})["status"] == "wat"
+
+
+# ── one test per exit ──────────────────────────────────────────────────────────────────
+
+def test_get_mid_turn_says_in_progress(api):
+ _store("resp_get_running", "running")
+ j = api.get("/v1/responses/resp_get_running").json()
+ assert j["status"] == "in_progress"
+
+
+def test_get_on_a_terminal_record_reports_that_terminal_status(api):
+ _store("resp_get_done", "completed")
+ assert api.get("/v1/responses/resp_get_done").json()["status"] == "completed"
+
+
+def _seed_live_turn(rid: str, monkeypatch) -> None:
+ """Make the record the live turn of a live session, so cancel takes the fast path.
+
+ Without this, cancel cannot prove the response owns the live turn — the same-replica hint is
+ only consulted when there is no control plane — so it settles the record as `cancelled`
+ itself. The fixture would then assert `cancelled` and pass with the status mapping removed,
+ never having reached the answer under test. Ownership is the durable `runner_turn_id` the
+ cancel latch returns matching the one on the live session vertex.
+ """
+ async def _vget(sid):
+ return {"status": "running", "turn_status": "running", "runner_turn_id": "rt1"}
+
+ async def _mark(org, response_id, status, ttl):
+ return {"runner_turn_id": "rt1"}
+
+ async def _stop(org, sid, v, **kw):
+ return None
+ monkeypatch.setattr(gw, "_vertex_get", _vget)
+ monkeypatch.setattr(gw, "_stop_session", _stop)
+ monkeypatch.setattr(gw.control_store, "resp_mark_terminal", _mark)
+ gw._session_trace["hsess1"] = {"last_response_id": rid}
+
+
+def clean_session_trace():
+ before = dict(gw._session_trace)
+ yield
+ gw._session_trace.clear()
+ gw._session_trace.update(before)
+
+
+def test_cancel_in_flight_answers_in_progress_until_the_cancel_settles(api, monkeypatch,
+ clean_session_trace):
+ """An accepted cancel on a turn that is still running leaves the record running: the answer is
+ a response object on that path too, and it has to say `in_progress`, not the internal name."""
+ _store("resp_cancel", "running")
+ _seed_live_turn("resp_cancel", monkeypatch)
+ j = api.post("/v1/responses/resp_cancel/cancel").json()
+ assert j["status"] == "in_progress"
+
+
+def test_cancel_never_leaks_internal_fields(api, monkeypatch, clean_session_trace):
+ _store("resp_cancel_fields", "running")
+ _seed_live_turn("resp_cancel_fields", monkeypatch)
+ j = api.post("/v1/responses/resp_cancel_fields/cancel").json()
+ assert not [k for k in j if k.startswith("_")]
+ assert "_input" not in j
+
+
+def test_the_background_post_answer_says_in_progress(api, monkeypatch):
+ """The POST answer is built by the translator, not read back from the record, so the status it
+ passes is the one that has to be right. This drives the real endpoint."""
+ monkeypatch.setattr(gw, "_base_catalog_get", lambda h: {"id": h, "base": "dsh"}, raising=False)
+
+ async def _chain(org, backend, model):
+ return [{"backend": backend}]
+ monkeypatch.setattr(gw, "_resolve_chain", _chain)
+
+ async def _exec(tr, **kw):
+ return "completed", [], {}
+ monkeypatch.setattr(gw, "_resp_execute", _exec)
+
+ r = api.post("/v1/responses", json={"input": "hi", "harness_id": "h1", "background": True})
+ assert r.status_code == 200, r.text
+ assert r.json()["status"] == "in_progress"
+
+
+def test_the_translator_names_the_state_in_progress_too():
+ """The stream already emitted `in_progress` while the poll said `running` — the same turn, two
+ names. This is the half that was already right, pinned so it stays right."""
+ tr = gw._RespTranslator("resp_tr", "m", None, True, 0.0)
+ assert tr.start()[1]["response"]["status"] == "in_progress"
+ assert tr._response_obj("in_progress")["status"] == "in_progress"
+
+
+def test_idempotent_replay_returns_the_first_record_not_a_raw_one():
+ """`_idem_replay` used to answer the stored record verbatim, internal fields included, and to
+ invent a `status: "unknown"` body for a missing original."""
+ rec = {"id": "resp_idem", "object": "response", "status": "running", "output": [],
+ "_org": ORG, "_input": [{"role": "user", "content": "secret"}]}
+
+ async def _get(rid):
+ return rec if rid == "resp_idem" else None
+
+ orig_get, orig_sleep = gw._resp_get, asyncio.sleep
+
+ async def _no_sleep(_):
+ return None
+ gw._resp_get, asyncio.sleep = _get, _no_sleep
+ try:
+ r = asyncio.run(gw._idem_replay("resp_idem", False))
+ finally:
+ gw._resp_get, asyncio.sleep = orig_get, orig_sleep
+
+ body = json.loads(r.body)
+ assert body["status"] == "in_progress"
+ assert not [k for k in body if k.startswith("_")] and "_input" not in body
+
+
+def test_idempotent_replay_of_a_missing_original_is_the_same_404_the_get_answers():
+ async def _get(rid):
+ return None
+
+ async def _no_sleep(_):
+ return None
+ orig_get, orig_sleep = gw._resp_get, asyncio.sleep
+ gw._resp_get, asyncio.sleep = _get, _no_sleep
+ try:
+ with pytest.raises(Exception) as ei:
+ asyncio.run(gw._idem_replay("resp_nope", False))
+ finally:
+ gw._resp_get, asyncio.sleep = orig_get, orig_sleep
+
+ detail = ei.value.detail
+ assert isinstance(detail, dict) and detail["code"] == "response_not_found"
+ assert ei.value.status_code == 404
+
+
+def test_the_idempotent_stream_ends_on_an_event_when_the_original_is_gone():
+ """The stream has already opened, so it cannot become a 404. It ends on the one event a
+ client can act on, carrying the same code."""
+ async def _get(rid):
+ return None
+
+ async def _no_sleep(_):
+ return None
+ orig_get, orig_sleep = gw._resp_get, asyncio.sleep
+ gw._resp_get, asyncio.sleep = _get, _no_sleep
+ try:
+ resp = asyncio.run(gw._idem_replay("resp_nope", True))
+ frames = asyncio.run(_frames(resp))
+ finally:
+ gw._resp_get, asyncio.sleep = orig_get, orig_sleep
+
+ assert frames[-1]["type"] == "response.failed"
+ assert frames[-1]["response"]["error"]["code"] == "response_not_found"
+ assert frames[-1]["response"]["status"] == "failed"
+
+
+async def _frames(resp) -> list:
+ out: list = []
+ async for chunk in resp.body_iterator:
+ text = chunk.decode() if isinstance(chunk, bytes) else chunk
+ for line in text.splitlines():
+ if line.startswith("data: "):
+ out.append(json.loads(line[6:]))
+ return out
+
+
+# ── the invariant the issue is really about ───────────────────────────────────────────
+
+def test_every_exit_answers_through_the_formatter():
+ """Pins the exits this file drives: GET and cancel route through the formatter, and nothing
+ hands a record back through `_strip_internal` alone.
+
+ It is not a general net. A new exit that returned the record some other way (`return rec`,
+ an inline dict, `return await _resp_get(...)`) would not match either string and this test
+ would stay green — the per-exit tests above are what actually cover each answer.
+ """
+ src = pathlib.Path(gw.__file__).read_text(encoding="utf-8")
+ assert src.count("return _strip_internal(rec)") == 0, (
+ "a response object is still answered without the status mapping; route it through "
+ "_public_response")
+ assert src.count("return _public_response(rec)") >= 2 # GET /v1/responses/{id}, cancel
+ assert '_snap = tr._response_obj("in_progress")' in src # background POST answer
+
+
+def test_the_orphan_adopter_emits_a_uhp_status_not_the_trace_name():
+ """`_adopt_orphan_turn` publishes its terminal event straight off `rec["status"]`, which holds
+ the trace's name for the outcome (`done`, `max_turns`, `timeout`). `complete()` publishes
+ whatever it is handed — deliberately, the persist path translates too — so the call site is
+ the thing that has to translate, and that is what this pins."""
+ src = pathlib.Path(gw.__file__).read_text(encoding="utf-8")
+ assert 'translator.complete(_RESP_STATUS_MAP.get(rec["status"], "failed"), produced)' in src, (
+ "the orphan adopter must translate the trace's status name before publishing it; "
+ "untranslated it reached subscribers as status 'max_turns' under a response.completed "
+ "event (#480)")
+
+
+def test_a_synthesized_event_body_carries_every_required_response_field():
+ """`Event.response` is a `$ref` to `Response`, whose `required` is id, object, created_at,
+ status, output and model. A literal carrying three of the six fails schema validation even
+ when everything it does carry is right."""
+ required = {"id", "object", "created_at", "status", "output", "model"}
+ body = gw._synth_response("resp_synth", "in_progress")
+ assert required <= set(body), f"synthesized body is missing {required - set(body)}"
+ assert gw._synth_response("resp_synth", "failed", {"code": "x"})["error"] == {"code": "x"}
+ assert "error" not in body
\ No newline at end of file
diff --git a/protocol/CHANGELOG.md b/protocol/CHANGELOG.md
index dd6235a8..67e7ae28 100644
--- a/protocol/CHANGELOG.md
+++ b/protocol/CHANGELOG.md
@@ -2,6 +2,18 @@
All notable changes to the Unified Harness Protocol.
+## Conformance suite 2026.10.19.post1 (2026-10-19)
+
+No change to the protocol, the schema or any verdict a conformant server gets.
+
+T-11 reads a background task back while it is still running and requires the lifecycle table's name
+for the state, `in_progress`. No check looked at a task before it reached a terminal status, so a
+server could answer every background POST and every poll with a name of its own and stay green.
+HarnessRouter answered `running`, which the table does not define, while its own stream emitted
+`in_progress` for the same turn: a client written to the specification waited for `in_progress`,
+or treated the unknown status as an error. The check skips rather than fails when the task finishes
+before it can be read mid-turn, since there is then nothing left to observe.
+
## 2026-10-19, addition: when each turn began and ended
Additive. Each item of a session's `turns` ([Sessions §3](versions/2026-10-19/sessions.md#3-inspecting-a-session))
diff --git a/protocol/conformance/README.md b/protocol/conformance/README.md
index 2dd62645..13583f08 100644
--- a/protocol/conformance/README.md
+++ b/protocol/conformance/README.md
@@ -52,13 +52,13 @@ anything that only inspects a schema.
## What it checks
-76 checks across three classes.
+100 checks across three classes.
| Class | Checks | Covers |
|---|---|---|
-| **Core** | 40 | Discovery, version negotiation, authentication, the error envelope, harnesses, models, task execution (streaming and not), the event stream, sessions, cancellation, reserved request fields |
-| **Extended** | +8 | Session listing and inspection, file input, artifacts, download headers, path-traversal probes |
-| **Full** | +26 | Harness create / update / delete, refusal of an unsupported base, skill-folder round trip, MCP and disabled-tool persistence, session sharing, plugins (package round trip, derivation, refusals, export, and a tool call through a plugin's server) |
+| **Core** | 41 | Discovery, version negotiation, authentication, the error envelope, harnesses, models, task execution (streaming and not), the event stream, sessions, cancellation, reserved request fields |
+| **Extended** | +9 | Session listing and inspection, file input, artifacts, download headers, path-traversal probes |
+| **Full** | +50 | Harness create / update / delete, refusal of an unsupported base, skill-folder round trip, MCP and disabled-tool persistence, session sharing, plugins (package round trip, derivation, refusals, export, and a tool call through a plugin's server) |
Every check names the section of the specification it enforces, so a failure points at the sentence
it violates rather than at a test name.
@@ -74,6 +74,11 @@ A few of them are worth calling out, because they catch things a schema check ne
- **C-03** — a running task really stops. It starts long work, cancels it, and waits for a terminal
state. A cancel endpoint that returns `200` and leaves the agent running passes every other kind
of test.
+- **T-11** — a background task polled mid-turn reports `in_progress`. The lifecycle table names
+ five statuses, and a server that answers with its own internal name for the state (`running`)
+ leaves a strict client with nothing to wait for: it waits for `in_progress`, or treats the
+ unknown status as an error. HarnessRouter answered a background POST and every poll until the
+ turn ended with `running` while its own stream emitted `in_progress` for the same turn.
- **X-07** — artifacts download with `X-Content-Type-Options: nosniff`. Artifacts are
attacker-influenceable content; served without it, an artifact is stored XSS against the client's
own origin.
diff --git a/protocol/conformance/uhp_conformance/__init__.py b/protocol/conformance/uhp_conformance/__init__.py
index 5bac285b..ff4360a6 100644
--- a/protocol/conformance/uhp_conformance/__init__.py
+++ b/protocol/conformance/uhp_conformance/__init__.py
@@ -3,7 +3,7 @@
# and a report prints it as `suite_version`, so a report always names the code that produced it.
# It used to be written twice, and from 2026.10.4 to 2026.10.4.post8 only the packaging copy moved:
# every report of those nine revisions called itself 2026.9.12.post4.
-__version__ = "2026.10.19"
+__version__ = "2026.10.19.post1"
UHP_VERSION = "2026-10-19"
# The MCP server the plugin checks point a plugin at. It must resolve and answer: a host is
# allowed to refuse a server it cannot reach at configuration time and record that in `skipped`,
diff --git a/protocol/conformance/uhp_conformance/checks.py b/protocol/conformance/uhp_conformance/checks.py
index b64c0795..4ac1e3f1 100644
--- a/protocol/conformance/uhp_conformance/checks.py
+++ b/protocol/conformance/uhp_conformance/checks.py
@@ -20,6 +20,11 @@ from .registry import Skip, check
SPEC = "protocol/versions/2026-10-19"
+# The five statuses the lifecycle table defines, and the four that end a task. Named once so a
+# check states the rule it enforces rather than spelling out a literal set of its own.
+LIFECYCLE_STATUSES = {"in_progress", "completed", "failed", "incomplete", "cancelled"}
+TERMINAL_STATUSES = LIFECYCLE_STATUSES - {"in_progress"}
+
# ── shared fixtures ────────────────────────────────────────────────────────────────────
# Small, deterministic work: the point is to exercise the protocol, not the model.
@@ -351,6 +356,53 @@ def t07(ctx):
assert rid.startswith("resp_"), f"response id {rid!r} is not `resp_`-prefixed"
+@check("T-11", "A background task read while it runs reports in_progress", "core",
+ f"{SPEC}/lifecycle.md#3-task-lifecycle")
+def t11(ctx):
+ """The lifecycle table names five statuses, and `in_progress` is the only non-terminal one. A
+ server that answers a poll with its own internal name for the state (`running`) leaves a
+ strict client with nothing to wait for: it waits for `in_progress`, or treats the unknown
+ status as an error. Measured 2026-10-19 on 0.35.0-rc.2, HarnessRouter answered a background
+ POST and every poll until the turn ended with `running`, while its own stream emitted
+ `in_progress` for the same turn."""
+ h = _harness(ctx)
+ body = {"input": "Count slowly from 1 to 100, one number per line.",
+ "metadata": {"harness_id": h["id"]}, "stream": False, "background": True}
+ if ctx.model:
+ body["model"] = ctx.model
+ started = ctx.client.post("/v1/responses", body=body)
+ rid = (started.json or {}).get("id")
+ if started.status != 200 or not rid:
+ raise Skip(f"could not start a background task (HTTP {started.status})")
+
+ try:
+ accepted = str((started.json or {}).get("status") or "")
+ assert accepted == "in_progress", (
+ f"POST /v1/responses with background:true answered {accepted!r}; a background task is "
+ f"accepted and running, which the lifecycle table names `in_progress`")
+
+ # Read it back while the turn is still going. The status set is total, so one poll settles it:
+ # `in_progress` is the observation, and anything else is either a terminal status or a name
+ # the table does not define. A task that finished first has nothing left to observe, and a
+ # skip is never a pass.
+ got = ctx.client.get(f"/v1/responses/{rid}")
+ assert got.status == 200, f"GET /v1/responses/{{id}} returned HTTP {got.status}"
+ status = str((got.json or {}).get("status") or "")
+ assert status in LIFECYCLE_STATUSES, (
+ f"GET /v1/responses/{{id}} answered {status!r}, which is not one of the five statuses the "
+ f"lifecycle table defines ({', '.join(sorted(LIFECYCLE_STATUSES))})")
+ if status in TERMINAL_STATUSES:
+ raise Skip(f"the task reached {status!r} before the check could read it mid-turn")
+ return f"read back as {status}"
+ finally:
+ # The task was started only to be watched: stop it, so the check leaves nothing running
+ # (and spending) after it. A server that cannot cancel changes no verdict here.
+ try:
+ ctx.client.post(f"/v1/responses/{rid}/cancel")
+ except Exception: # noqa: BLE001
+ pass
+
+
# ══════════════════════════════════════════════════════════════════════════════════════
# Core — streaming
# ══════════════════════════════════════════════════════════════════════════════════════