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.
This commit is contained in:
@@ -748,7 +748,9 @@ class SessionSessionsMixin:
|
||||
"""Most recently used main-loop model route as one coherent per-call tuple
|
||||
(``session_model_usage`` keeps model+provider together; ``sessions`` mixes route changes).
|
||||
Recency, not lifetime call count: on a long session a route retired weeks ago can hold the
|
||||
highest ``api_call_count`` forever, and /status and /usage would keep calling it current."""
|
||||
highest ``api_call_count`` forever, and /status and /usage would keep calling it current.
|
||||
``rowid DESC`` breaks same-timestamp ties toward the route that first appeared later; without
|
||||
it SQLite's temp-sort order is unspecified and the retired route can win."""
|
||||
self.flush_token_counts()
|
||||
row = self._read_one(
|
||||
"""SELECT model, billing_provider, billing_base_url, billing_mode,
|
||||
@@ -758,7 +760,7 @@ class SessionSessionsMixin:
|
||||
AND task = ''
|
||||
AND model <> 'unknown'
|
||||
AND billing_provider <> ''
|
||||
ORDER BY last_seen DESC
|
||||
ORDER BY last_seen DESC, rowid DESC
|
||||
LIMIT 1""",
|
||||
(session_id,),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user