fix: refresh stale model ids on upgrade + surface rejected API keys#217
Merged
Conversation
Fresh installs seed current model aliases, but upgraded DBs kept agent rows pointing at claude-sonnet-4-20250514 / claude-opus-4-20250514 from old seeds, and the shared MODEL_MAP still hardcoded the same dated ids. V59 rewrites only those exact known-stale ids to the current aliases (a valid model the user picked on purpose is never touched) and the shared shorthand maps now resolve to claude-sonnet-4-6 / claude-opus-4-8.
A disabled or invalid ANTHROPIC_API_KEY inherited from the shell made the operator loop throw, and the catch quietly fell back to the tool-less CLI answer — ARIA lost every tool with no explanation. The fallback now detects auth rejections (401/403/authentication_error), names which credential failed (stored key vs shell env, mirroring the loop's stored-first precedence), and prepends an actionable notice to the degraded reply. Key values never appear in messages or logs.
CLAUDE_MODEL_IDS in packages/shared is now the canonical id set; MODEL_MAP, resolveModelName, the desktop provider maps (ClaudeRouter/ClaudeProvider), ClaudeAgentService defaults, and the Agent Launcher / Agent Station pickers all derive from it, so a model bump is a one-line change. Station picker drops the superseded claude-sonnet-4-5 option.
V60 companion to the V59 agent refresh: agent_station_configs rows only ever hold values the station picker offered, so claude-opus-4-20250514 and claude-sonnet-4-5 there are DAEMON-originated and safe to remap to the current aliases. Non-Claude rows (gpt-*) pass through untouched. Migration targets now reference CLAUDE_MODEL_IDS so they cannot drift from the canonical set.
Follow-up to the rejected-key notice: instead of prepending the warning to the reply text, emit a dedicated 'notice' transcript event rendered as an amber-lined banner (5px dot language) above the turn, persist it in message metadata so it survives history reloads, and log only the key SOURCE (stored vs shell env) — key values never reach logs or the transcript.
MigrationRunner drives the FULL runMigrations chain against node:sqlite (real SQL engine, no Electron-ABI binding needed): fresh installs seed only sanctioned model IDs, a simulated pre-V59 install gets its agent and station rows remapped, re-running is a no-op, and every refresh-map target is proven to be a canonical CLAUDE_MODEL_IDS value. AriaAuthNotice exercises sendMessage end to end with the real claudeAuth classifier: warn banner names the failing key source, reply text stays clean, metadata survives reloads, GLM turns and network errors never blame the Anthropic key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two reliability fixes found during the first-run work, plus a shared-constant cleanup.
New pure module electron/services/providers/claudeAuth.ts (source resolution + auth-error classifier). Suite 1027 to 1063 (+36, none skipped), including real-SQL full-chain migration tests. Typecheck, build, lint:styles green.