Files
hermes-agent/tests/hermes_state/test_recent_model_route.py
T
teknium1 bdb14f5f81 fix: status falls back to the live agent before the first host frame; recent route ties break deterministically
Under turn isolation `session.status` passed agent=None and only the metadata
mirror's model/provider, so until the compute host sent its first frame the
mirror was empty and the TUI rendered "Model: (unknown) (unknown)" where main
showed the in-process agent's route. Fall back to the live agent's model and
provider like `server._session_info` already does.

`get_recent_session_model_route` ordered by `last_seen DESC` alone; two rows
stamped in the same flush tie and SQLite's temp-sort order is unspecified, so
the retired route could be reported as current. Order by `rowid DESC` as the
secondary key so the route that appeared later wins.
2026-09-13 14:45:41 -07:00

18 lines
716 B
Python

"""get_recent_session_model_route picks the newest route deterministically on equal last_seen."""
from hermes_state import SessionDB
def test_recent_route_tie_on_last_seen_prefers_later_row(tmp_path):
db = SessionDB(tmp_path / "state.db")
db.create_session(session_id="s1", source="tui", model="alpha")
with db._lock:
for model in ("alpha", "zeta"):
db._conn.execute(
"INSERT INTO session_model_usage (session_id, model, billing_provider, task,"
" api_call_count, last_seen) VALUES ('s1', ?, 'p', '', 1, 100.0)",
(model,),
)
db._conn.commit()
assert db.get_recent_session_model_route("s1")["model"] == "zeta"