Files
hermes-agent/tests/gateway/test_api_runs_poll_shape.py
Teknium f0afee3a12 fix(api): a canonical GET /v1/runs/{id} keeps the documented poll shape
_durable_run_status returned run_projection's dict before the retained run record, so under the
authority the poll body lost object, model, runtime and created_at (main's run store returns
them; website/docs/user-guide/features/api-server.md documents them). The canonical projection
still decides status/output/usage/controls; the retained record now contributes object
("hermes.run"), the requested model, created_at and the served runtime once _finish set it.

Test: tests/gateway/test_api_runs_poll_shape.py::test_canonical_run_poll_keeps_object_model_and_created_at

Review: andrexibiza 5480715949-P3
(cherry picked from commit 7993075eeeb74a7c7837ac301aa123eaaf96b5cb)
2026-10-10 22:19:45 -07:00

25 lines
1.1 KiB
Python

"""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
@pytest.mark.asyncio
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)