Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(bots): flag a companion whose model provider was deleted as needs-attention

Zhao Dengfengbc92df595a7b
diff --git a/apps/desktop/src/shared/__tests__/botFailureReason.test.ts b/apps/desktop/src/shared/__tests__/botFailureReason.test.ts
index 9cb75d4290..69b93048b7 100644
--- a/apps/desktop/src/shared/__tests__/botFailureReason.test.ts
+++ b/apps/desktop/src/shared/__tests__/botFailureReason.test.ts
@@ -35,6 +35,17 @@ describe('Hermes Bot failure reasons', () => {
['maximum context length is 128000 tokens', 'context_overflow'],
['No LLM provider configured', 'missing_config'],
['No access token found for profile', 'missing_config'],
+ // Real errors when the Bot's custom provider was deleted (Pi start / send route guard).
+ [
+ "Error: pi: BYOM provider 'magpie-8a1e5ed8' cannot serve model 'auto/glm-5p3-flash' (provider absent, or it no longer offers this model); refusing to fall back to the Cindy gateway (would send prompts to the wrong endpoint).",
+ 'missing_config',
+ ],
+ [
+ '[INVALID_PARAMS] provider "magpie-8e1b0a66" is unavailable; select an available provider before sending',
+ 'missing_config',
+ ],
+ // A transient native lookup failure is not a configuration problem.
+ ["pi: BYOM provider 'p1' cannot serve model 'm1' (native provider resolution failed); refusing", 'unknown'],
["model 'gpt-9' not found", 'model_unavailable'],
['agent is blocked awaiting approval', 'agent_blocked'],
] as const)('classifies %s', (text, expected) => {
diff --git a/apps/desktop/src/shared/botFailureReason.ts b/apps/desktop/src/shared/botFailureReason.ts
index dec422b2df..422629adbb 100644
--- a/apps/desktop/src/shared/botFailureReason.ts
+++ b/apps/desktop/src/shared/botFailureReason.ts
@@ -68,6 +68,12 @@ export function classifyBotFailureReason(value: unknown): BotFailureReason {
) return 'provider_server_error';
if (/context length|context_overflow|maximum context/i.test(text)) return 'context_overflow';
if (/no llm provider configured|missing config|no access token/i.test(text)) return 'missing_config';
+ // The Bot still points at a provider that was deleted or no longer offers its model
+ // (e.g. a preset connection re-added under a new id). Nothing recovers this until
+ // the owner picks the model again, so it must surface as needs-attention.
+ if (
+ /cannot serve model .*\(provider absent|provider "[^"]*" is unavailable; select an available provider/i.test(text)
+ ) return 'missing_config';
if (/model .*(?:not found|does not exist)|model_not_found/i.test(text)) return 'model_unavailable';
if (/agent (?:is )?blocked|awaiting approval|waiting for approval/i.test(text)) return 'agent_blocked';
return 'unknown';