Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(const): pair the sub-agent fallback model with the swapped default provider (#20705)

AmAzing-fc0bf60fca2e
diff --git a/packages/const/src/settings/llm.test.ts b/packages/const/src/settings/llm.test.ts
new file mode 100644
index 00000000000..4a5433cda25
--- /dev/null
+++ b/packages/const/src/settings/llm.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, it, vi } from 'vitest';
+
+import { resolveSubAgentModel } from './llm';
+
+// A build that swaps `@lobechat/business-const` (the cloud one) serves a different
+// provider whose catalog does not carry the self-hosted default model id.
+vi.mock('@lobechat/business-const', () => ({
+ DEFAULT_MINI_MODEL: 'swapped-mini-model',
+ DEFAULT_MODEL: 'swapped-default-model',
+ DEFAULT_PROVIDER: 'swapped-provider',
+}));
+
+describe('resolveSubAgentModel', () => {
+ it('falls back to the default model of the same business-const build as the provider', () => {
+ expect(resolveSubAgentModel(undefined)).toEqual({
+ model: 'swapped-default-model',
+ provider: 'swapped-provider',
+ });
+ });
+});
diff --git a/packages/const/src/settings/llm.ts b/packages/const/src/settings/llm.ts
index f566c966962..04fa2c298b8 100644
--- a/packages/const/src/settings/llm.ts
+++ b/packages/const/src/settings/llm.ts
@@ -1,22 +1,10 @@
-import { DEFAULT_PROVIDER } from '@lobechat/business-const';
+import { DEFAULT_MODEL, DEFAULT_PROVIDER } from '@lobechat/business-const';
import type { LobeAgentAgencyConfig, LobeAgentChatConfig } from '@lobechat/types';
export { DEFAULT_MINI_MODEL, DEFAULT_MODEL } from '@lobechat/business-const';
export const DEFAULT_EMBEDDING_MODEL = 'text-embedding-3-small';
-/**
- * Last-resort model for sub-agents spawned via `lobe-agent.callSubAgent`, used
- * only when neither an explicit `agencyConfig.subagent` override nor the
- * parent's effective model is available at the spawn site.
- *
- * Paired with `DEFAULT_PROVIDER` rather than a dedicated sub-agent provider, so
- * a build that swaps `@lobechat/business-const` (the cloud one routes through
- * its own official provider) moves the sub-agent along with the main model
- * instead of leaving it pointed at a provider that build doesn't serve.
- */
-export const DEFAULT_SUB_AGENT_MODEL = 'deepseek-v4-flash';
-
/**
* Resolve the model a sub-agent runs on, in precedence order:
*
@@ -24,7 +12,10 @@ export const DEFAULT_SUB_AGENT_MODEL = 'deepseek-v4-flash';
* 2. The parent run's effective model — same provider, same model. Multi-provider
* setups otherwise strand sub-agents on a provider the user has moved away
* from (Claude Code / Codex sub-agents inherit the parent model the same way).
- * 3. The global default, when the spawn site has no parent model at hand.
+ * 3. The global default, when the spawn site has no parent model at hand. Both
+ * halves come from `@lobechat/business-const`, so a build that swaps it (the
+ * cloud one routes through its own official provider) never pairs its
+ * provider with a model id only the self-hosted catalog carries.
*
* Model and provider resolve as a pair: mixing one source's model id with
* another source's provider would produce a `provider/model` combination the
@@ -40,7 +31,7 @@ export const resolveSubAgentModel = (
if (parentModel?.model)
return { model: parentModel.model, provider: parentModel.provider || DEFAULT_PROVIDER };
- return { model: DEFAULT_SUB_AGENT_MODEL, provider: DEFAULT_PROVIDER };
+ return { model: DEFAULT_MODEL, provider: DEFAULT_PROVIDER };
};
/**
diff --git a/src/store/chat/slices/agentRun/actions/__tests__/subAgentModel.test.ts b/src/store/chat/slices/agentRun/actions/__tests__/subAgentModel.test.ts
index f660a901753..642b88717ad 100644
--- a/src/store/chat/slices/agentRun/actions/__tests__/subAgentModel.test.ts
+++ b/src/store/chat/slices/agentRun/actions/__tests__/subAgentModel.test.ts
@@ -1,6 +1,5 @@
-import { DEFAULT_PROVIDER } from '@lobechat/business-const';
+import { DEFAULT_MODEL, DEFAULT_PROVIDER } from '@lobechat/business-const';
import {
- DEFAULT_SUB_AGENT_MODEL,
getSubAgentChatConfigOverride,
resolveSubAgentChatConfig,
resolveSubAgentModel,
@@ -52,11 +51,11 @@ describe('sub-agent model resolution', () => {
it('runs a spawned sub-agent on the model the spawn site resolved', () => {
const { agentConfig } = createAgentState({
isSubAgent: true,
- modelOverride: { model: DEFAULT_SUB_AGENT_MODEL, provider: 'deepseek' },
+ modelOverride: { model: DEFAULT_MODEL, provider: 'deepseek' },
});
expect(agentConfig.agentConfig).toMatchObject({
- model: DEFAULT_SUB_AGENT_MODEL,
+ model: DEFAULT_MODEL,
provider: 'deepseek',
});
});
@@ -94,7 +93,7 @@ describe('resolveSubAgentModel', () => {
it('falls back to the global default when no override and no parent model exist', () => {
expect(resolveSubAgentModel(undefined)).toEqual({
- model: DEFAULT_SUB_AGENT_MODEL,
+ model: DEFAULT_MODEL,
provider: DEFAULT_PROVIDER,
});
});