Commit Graph

11 Commits

Author SHA1 Message Date
Peter Steinberger
679a393f6d refactor: dedupe metadata readers 2026-04-07 07:36:11 +01:00
Peter Steinberger
1fb44f0aad fix: separate selected session model resolution 2026-04-06 16:07:50 +01:00
Peter Steinberger
4dbc66b1ed fix: remove bundled channel startup reentry 2026-04-04 15:39:12 +01:00
kiranvk2011
b36a3a3295 fix: add .catch() to fire-and-forget stale-flag clear to prevent unhandled rejection 2026-04-04 19:45:53 +09:00
kiranvk2011
e8f6ceedd4 fix: clear stale liveModelSwitchPending flag when model already matches
When the liveModelSwitchPending flag is set but the current model already
matches the persisted selection (e.g. the switch was applied as an override
and the current attempt is already using the new model), the flag is now
consumed eagerly via a fire-and-forget clearLiveModelSwitchPending() call.

Without this, the stale flag could persist across fallback iterations and
later cause a spurious LiveSessionModelSwitchError when the model rotates
to a fallback candidate that differs from the persisted selection.

Also expands JSDoc on shouldSwitchToLiveModel to document the stale-flag
clearing and deferral semantics.
2026-04-04 19:45:53 +09:00
kiranvk2011
251e086eac fix: use explicit flag for live model switch detection in fallback chain
Replace the ambiguous comparison-based approach (hasDifferentLiveSessionModelSelection
+ in-memory map EMBEDDED_RUN_MODEL_SWITCH_REQUESTS) with a persisted
`liveModelSwitchPending` flag on SessionEntry.

The root cause: the in-memory map was never populated in production because
requestLiveSessionModelSwitch() was removed in commit 622b91d04e and replaced
with refreshQueuedFollowupSession(). This left the comparison-based detection
as the only path, which could not distinguish user-initiated model switches
(via /model command) from system-initiated fallback rotations.

The fix:
- Add `liveModelSwitchPending?: boolean` to SessionEntry (persisted)
- Set the flag to true ONLY when /model command applies a model override
- New `shouldSwitchToLiveModel()` checks the flag + model mismatch together
- New `clearLiveModelSwitchPending()` resets the flag after consumption
- Replace throw-site logic in run.ts to use the new flag-based functions
- Remove orphaned resolveCurrentLiveSelection helper

Only the /model command sets this flag, so system-initiated fallback rotations
are never mistaken for user-initiated model switches. This restores the
live-switch-during-active-run feature that was accidentally broken.

Fixes #57857, #57760, #58137
2026-04-04 19:45:53 +09:00
Peter Steinberger
fe72474153 fix: persist fallback overrides safely 2026-04-04 09:00:16 +09:00
Shakker
fc8ab82aab refactor: trim cron session startup imports 2026-04-03 16:03:10 +01:00
Peter Steinberger
32ebaa3757 refactor: share session model resolution helpers 2026-04-03 19:37:56 +09:00
Vincent Koc
bd89e07baa fix(agents): stop transient live-switch mismatches 2026-03-30 07:12:52 +09:00
Peter Steinberger
7dd196ed74 fix: apply live model switches during active retries 2026-03-27 12:01:55 +00:00