fix: show completed fallback models in session diagnostics (#141396)

fix: show completed fallback models in session diagnostics (#141396)

## What Problem This Solves

Fixes an issue where chat model controls could omit the model that answered after the selected primary failed. The selected model stayed correct, but the existing active-model fields were empty even after a visible, successful fallback.

## Why This Change Was Made

Fallback accounting deliberately preserves the session's selection fields. Session diagnostics now read the answering model from the latest canonical transcript message for the completed session and exact run, then apply the existing fallback-notice and alias checks. The read uses the existing one-message, 256 KiB materialization bound and requires a visible terminal assistant message.

## User Impact

Users can distinguish the selected primary from the fallback that answered. The next turn still starts from the selected primary, and successful primary recovery clears the active fallback. Selection, thinking defaults, model metadata, authentication, and persistent-store semantics are unchanged.

## Evidence

- Current-main regression reproduced the missing active fields through real accounting, transcript persistence, and lightweight session-row projection, starting without a stored runtime model pair.
- Four focused tests pass: fresh and previous-primary fallback sequences plus existing active/stale projection controls. The sequences cover changed selection, other runs/sessions, running state, hidden output, and primary recovery while an old notice remains.
- An authenticated source-mode Gateway with a synthetic loopback provider made exactly three model requests: primary 404, fallback 200, primary recovery 200. Public settled receipts, history, and session lists agreed on the answering model. Selection, thinking defaults, and model metadata stayed unchanged; recovery cleared both active fields.
- Scoped formatting, lint, and diff checks pass. Typechecking and required CI run on the PR head.

Production changes are +41/-1 lines. The additional reader preserves exact run and visibility checks without changing stored selection state. A focused regression file keeps the accounting fixture and failure/recovery sequence together. Diagnostics remain unavailable when the bounded latest-message read cannot establish the answering model.

Co-authored-by: Ayaan Zaidi 
添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论