The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(api): a canonical GET /v1/runs/{id} keeps the documented poll shape
Tekniumf0afee3a128c
diff --git a/gateway/platforms/api_server_runs.py b/gateway/platforms/api_server_runs.pyindex 264c1560f5e..4b407bbbaea 100644--- a/gateway/platforms/api_server_runs.py+++ b/gateway/platforms/api_server_runs.py@@ -412,7 +412,11 @@ def _durable_run_status(self, request: web.Request, run_id: str) -> dict[str, Anfrom gateway.platforms.api_server_authority_runs import run_projectioncanonical = run_projection(self, run_id)if canonical is not None:- return canonical+ # The documented poll shape: the canonical projection decides status/output/usage; the+ # retained run record still names the object, the requested model and the served runtime.+ retained = self._run_statuses.get(run_id) or {}+ return {"object": "hermes.run", **{key: retained[key] for key in ("model", "runtime", "created_at")+ if key in retained}, **canonical}status = self._run_statuses.get(run_id)if status is not None:if run_id in self._run_idempotency_ids:diff --git a/tests/gateway/test_api_runs_poll_shape.py b/tests/gateway/test_api_runs_poll_shape.pynew file mode 100644index 00000000000..066c7d40dc7--- /dev/null+++ b/tests/gateway/test_api_runs_poll_shape.py@@ -0,0 +1,24 @@+"""GET /v1/runs/{id} keeps the documented poll shape when the canonical admission answers."""+import pytest+from aiohttp import web+from aiohttp.test_utils import TestClient, TestServer+++async def test_canonical_run_poll_keeps_object_model_and_created_at(api, owner, monkeypatch):+ from gateway.platforms import api_server_runs++ async def no_execution(*args, **kwargs):+ pass+ monkeypatch.setattr(api_server_runs, '_execute_run', no_execution)+ app = web.Application()+ app.router.add_post('/v1/runs', api._handle_runs)+ app.router.add_get('/v1/runs/{run_id}', api._handle_get_run)+ async with TestClient(TestServer(app)) as client:+ accepted = await client.post('/v1/runs', json={'input': 'hi', 'model': 'hermes-agent'})+ assert accepted.status == 202, await accepted.text()+ run_id = (await accepted.json())['run_id']+ polled = await (await client.get(f'/v1/runs/{run_id}')).json()+ assert polled['admission_id'] and polled['status'] == 'queued'+ assert polled['object'] == 'hermes.run' and polled['model'] == 'hermes-agent', polled+ assert isinstance(polled['created_at'], float)