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(model-runtime): resolve Volcengine request model from card deploymentName (#20645)

Arvin Xu9e5a775b1c77
diff --git a/apps/server/src/modules/AgentRuntime/adapters/ServerLLMTransport.test.ts b/apps/server/src/modules/AgentRuntime/adapters/ServerLLMTransport.test.ts
index 8acb76c8d3d..7aebb536c81 100644
--- a/apps/server/src/modules/AgentRuntime/adapters/ServerLLMTransport.test.ts
+++ b/apps/server/src/modules/AgentRuntime/adapters/ServerLLMTransport.test.ts
@@ -1,16 +1,29 @@
// @vitest-environment node
+import type { LLMAttemptInput } from '@lobechat/agent-runtime';
import { ModelRuntime } from '@lobechat/model-runtime';
import { tracer as agentRuntimeTracer } from '@lobechat/observability-otel/modules/agent-runtime';
import { RequestTrigger } from '@lobechat/types';
-import { describe, expect, it, vi } from 'vitest';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { initModelRuntimeFromDB } from '@/server/modules/ModelRuntime';
+import { initModelRuntimeFromDB, resolveServerModel } from '@/server/modules/ModelRuntime';
import type { RuntimeExecutorContext } from '../context';
import { ServerLLMTransport } from './ServerLLMTransport';
+// Hoisted so every `new AiModelModel(...)` inside the transport shares one
+// controllable row lookup; per-test resets keep implementations from leaking
+// across tests the way `mockImplementation` on the constructor would.
+const findByIdAndProviderMock = vi.hoisted(() => vi.fn());
+
vi.mock('@/server/modules/ModelRuntime', () => ({
initModelRuntimeFromDB: vi.fn(),
+ resolveServerModel: vi.fn(),
+}));
+
+vi.mock('@/database/models/aiModel', () => ({
+ AiModelModel: class {
+ findByIdAndProvider = findByIdAndProviderMock;
+ },
}));
vi.mock('../llmRelay/resolveLlmExecutionSite', () => ({
@@ -54,6 +67,453 @@ describe('ServerLLMTransport.stream Β· conversation affinity', () => {
});
});
+describe('ServerLLMTransport.stream Β· deployment name', () => {
+ // Codex P1 (4255361517): clear the module-level `resolveServerModel` mock
+ // before each test instead of relying on Vitest's default `clearMocks`
+ // behavior, so the zero-call assertion below cannot inherit residual calls
+ // from the live-resolution and rejection tests above.
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it('carries the frozen card deployment name for a compression model equal to the run model', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+
+ const ctx = {
+ loadAgentState: vi.fn(async () => ({
+ modelRuntimeConfig: {
+ model: 'deepseek-v4-pro-ga',
+ modelFacts: {
+ cards: [
+ {
+ deploymentName: 'deepseek-v4-pro-ga-260813',
+ id: 'deepseek-v4-pro-ga',
+ providerId: 'volcengine',
+ },
+ ],
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ },
+ provider: 'volcengine',
+ },
+ })),
+ operationId: 'op-1',
+ stepIndex: 0,
+ topicId: 'topic-1',
+ userId: 'user-1',
+ } as unknown as RuntimeExecutorContext;
+
+ await new ServerLLMTransport(ctx).stream({
+ messages: [],
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ });
+
+ expect(chat.mock.calls[0][0].deploymentName).toBe('deepseek-v4-pro-ga-260813');
+ });
+
+ it('resolves the deployment catalog live for a compression model outside the frozen cards', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ vi.mocked(resolveServerModel).mockResolvedValue({
+ deploymentName: 'deepseek-v4-pro-ga-260813',
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ });
+
+ const ctx = {
+ loadAgentState: vi.fn(async () => ({
+ modelRuntimeConfig: {
+ cards: [],
+ model: 'other-model',
+ modelFacts: { cards: [], model: 'other-model', provider: 'volcengine' },
+ provider: 'volcengine',
+ },
+ })),
+ operationId: 'op-1',
+ stepIndex: 0,
+ topicId: 'topic-1',
+ userId: 'user-1',
+ } as unknown as RuntimeExecutorContext;
+
+ await new ServerLLMTransport(ctx).stream({
+ messages: [],
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ });
+
+ expect(resolveServerModel).toHaveBeenCalledWith('volcengine', 'deepseek-v4-pro-ga');
+ expect(chat.mock.calls[0][0].deploymentName).toBe('deepseek-v4-pro-ga-260813');
+ });
+
+ it('keeps the bare model id when the deployment catalog cannot resolve it', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ vi.mocked(resolveServerModel).mockRejectedValue(
+ new Error('The selected server model is not available'),
+ );
+
+ const ctx = {
+ loadAgentState: vi.fn(async () => undefined),
+ operationId: 'op-1',
+ stepIndex: 0,
+ topicId: 'topic-1',
+ userId: 'user-1',
+ } as unknown as RuntimeExecutorContext;
+
+ await new ServerLLMTransport(ctx).stream({
+ messages: [],
+ model: 'some-unknown-model',
+ provider: 'volcengine',
+ });
+
+ expect(chat.mock.calls[0][0].deploymentName).toBeUndefined();
+ });
+
+ it('does not touch deploymentName for providers outside the deployment catalog', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+
+ const ctx = {
+ loadAgentState: vi.fn(async () => undefined),
+ operationId: 'op-1',
+ stepIndex: 0,
+ topicId: 'topic-1',
+ userId: 'user-1',
+ } as unknown as RuntimeExecutorContext;
+
+ await new ServerLLMTransport(ctx).stream({
+ messages: [],
+ model: 'gpt-4',
+ provider: 'openai',
+ });
+
+ expect(chat.mock.calls[0][0].deploymentName).toBeUndefined();
+ });
+
+ it('strips the frozen card deployment name for a non-consuming provider (qwen)', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+
+ const ctx = {
+ loadAgentState: vi.fn(async () => ({
+ modelRuntimeConfig: {
+ model: 'qwen3-vl-flash',
+ modelFacts: {
+ cards: [
+ {
+ deploymentName: 'qwen3-vl-flash-prod',
+ id: 'qwen3-vl-flash',
+ providerId: 'qwen',
+ },
+ ],
+ model: 'qwen3-vl-flash',
+ provider: 'qwen',
+ },
+ provider: 'qwen',
+ },
+ })),
+ operationId: 'op-1',
+ stepIndex: 0,
+ topicId: 'topic-1',
+ userId: 'user-1',
+ } as unknown as RuntimeExecutorContext;
+
+ await new ServerLLMTransport(ctx).stream({
+ messages: [],
+ model: 'qwen3-vl-flash',
+ provider: 'qwen',
+ });
+
+ // The qwen adapter leaves the field in `...rest` and the OpenAI-compatible
+ // factory forwards unknown payload fields upstream β€” the internal mapping
+ // must never reach the wire for providers that don't consume it.
+ expect(chat.mock.calls[0][0].deploymentName).toBeUndefined();
+ // ...and the live deployment catalog is not even consulted.
+ expect(resolveServerModel).not.toHaveBeenCalled();
+ });
+
+ it('freezes the absence of an alias when the frozen card has no deploymentName', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ vi.mocked(resolveServerModel).mockResolvedValue({
+ deploymentName: 'bundled-azure-endpoint',
+ model: 'my-custom-model',
+ provider: 'azure',
+ });
+
+ const ctx = {
+ loadAgentState: vi.fn(async () => ({
+ modelRuntimeConfig: {
+ model: 'my-custom-model',
+ modelFacts: {
+ cards: [{ id: 'my-custom-model', providerId: 'azure' }],
+ model: 'my-custom-model',
+ provider: 'azure',
+ },
+ provider: 'azure',
+ },
+ })),
+ operationId: 'op-1',
+ stepIndex: 0,
+ topicId: 'topic-1',
+ userId: 'user-1',
+ } as unknown as RuntimeExecutorContext;
+
+ await new ServerLLMTransport(ctx).stream({
+ messages: [],
+ model: 'my-custom-model',
+ provider: 'azure',
+ });
+
+ // Codex P2 (4259967307): the snapshot is authoritative β€” a matching card
+ // without an alias freezes that absence, so the catalog (possibly changed
+ // since the snapshot) is never consulted and the payload keeps the bare id.
+ expect(resolveServerModel).not.toHaveBeenCalled();
+ expect(chat.mock.calls[0][0].deploymentName).toBeUndefined();
+ });
+
+ it('prefers the user-configured alias over the deployment catalog for a custom model', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ findByIdAndProviderMock.mockResolvedValue({
+ config: { deploymentName: 'my-custom-azure-endpoint' },
+ id: 'my-custom-model',
+ });
+ vi.mocked(resolveServerModel).mockResolvedValue({
+ deploymentName: 'bundled-azure-endpoint',
+ model: 'my-custom-model',
+ provider: 'azure',
+ });
+
+ const ctx = {
+ loadAgentState: vi.fn(async () => undefined),
+ operationId: 'op-1',
+ serverDB: {},
+ stepIndex: 0,
+ topicId: 'topic-1',
+ userId: 'user-1',
+ } as unknown as RuntimeExecutorContext;
+
+ await new ServerLLMTransport(ctx).stream({
+ messages: [],
+ model: 'my-custom-model',
+ provider: 'azure',
+ });
+
+ // The catalog is never consulted β€” the user row alone names the endpoint.
+ expect(resolveServerModel).not.toHaveBeenCalled();
+ expect(chat.mock.calls[0][0].deploymentName).toBe('my-custom-azure-endpoint');
+ });
+
+ it('falls back to the deployment catalog when the user row has no alias', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ findByIdAndProviderMock.mockResolvedValue(null);
+ vi.mocked(resolveServerModel).mockResolvedValue({
+ deploymentName: 'bundled-azure-endpoint',
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ });
+
+ const ctx = {
+ loadAgentState: vi.fn(async () => undefined),
+ operationId: 'op-1',
+ serverDB: {},
+ stepIndex: 0,
+ topicId: 'topic-1',
+ userId: 'user-1',
+ } as unknown as RuntimeExecutorContext;
+
+ await new ServerLLMTransport(ctx).stream({
+ messages: [],
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ });
+
+ expect(resolveServerModel).toHaveBeenCalledWith('volcengine', 'deepseek-v4-pro-ga');
+ expect(chat.mock.calls[0][0].deploymentName).toBe('bundled-azure-endpoint');
+ });
+});
+
+describe('ServerLLMTransport.runAttempt Β· deployment name without frozen model facts', () => {
+ // Codex P1 (4257694112): operations without a `modelFacts` snapshot β€”
+ // agent-signal memory actions, persisted operations predating `modelFacts` β€”
+ // must still resolve the deployment alias live, or deployment-catalog
+ // providers keep receiving a logical id they 404 on.
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ const createAttemptCtx = () =>
+ ({
+ operationId: 'op-1',
+ serverDB: {},
+ stepIndex: 0,
+ streamManager: {
+ publishStreamChunk: vi.fn().mockResolvedValue('chunk-id'),
+ publishStreamEvent: vi.fn().mockResolvedValue('event-id'),
+ },
+ toolExecutionService: {},
+ userId: 'user-1',
+ }) as unknown as RuntimeExecutorContext;
+
+ const createAttemptInput = (state: Record<string, unknown>): LLMAttemptInput =>
+ ({
+ assistantMessageId: 'msg-1',
+ attempt: 1,
+ context: {
+ messages: [{ content: 'Question', role: 'user' }],
+ modelParameters: {},
+ replayAssistantReasoning: false,
+ resolvedTools: {
+ enabledToolIds: [],
+ executorMap: {},
+ manifestMap: {},
+ promptManifestMap: {},
+ sourceMap: {},
+ tools: [],
+ },
+ } as unknown as LLMAttemptInput['context'],
+ events: [],
+ maxAttempts: 6,
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ state,
+ }) as unknown as LLMAttemptInput;
+
+ it('resolves the deployment catalog live when the operation has no modelFacts', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ vi.mocked(resolveServerModel).mockResolvedValue({
+ deploymentName: 'deepseek-v4-pro-ga-260813',
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ });
+
+ const transport = new ServerLLMTransport(createAttemptCtx());
+ await transport.runAttempt(createAttemptInput({}));
+
+ expect(resolveServerModel).toHaveBeenCalledWith('volcengine', 'deepseek-v4-pro-ga');
+ expect(chat.mock.calls[0][0].deploymentName).toBe('deepseek-v4-pro-ga-260813');
+ });
+
+ it('shares one live resolution across attempts instead of paying one per attempt', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ vi.mocked(resolveServerModel).mockResolvedValue({
+ deploymentName: 'deepseek-v4-pro-ga-260813',
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ });
+
+ const transport = new ServerLLMTransport(createAttemptCtx());
+ await transport.runAttempt(createAttemptInput({}));
+ await transport.runAttempt(createAttemptInput({}));
+
+ expect(resolveServerModel).toHaveBeenCalledTimes(1);
+ expect(chat).toHaveBeenCalledTimes(2);
+ });
+
+ it('keeps the bare model id when the live catalog cannot resolve the model', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ vi.mocked(resolveServerModel).mockRejectedValue(
+ new Error('The selected server model is not available'),
+ );
+
+ const transport = new ServerLLMTransport(createAttemptCtx());
+ await transport.runAttempt(createAttemptInput({}));
+
+ expect(chat.mock.calls[0][0].deploymentName).toBeUndefined();
+ });
+
+ it('resolves the user-configured alias live when the operation has no modelFacts', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ findByIdAndProviderMock.mockResolvedValue({
+ config: { deploymentName: 'my-custom-azure-endpoint' },
+ id: 'my-custom-model',
+ });
+
+ const input = createAttemptInput({}) as any;
+ input.model = 'my-custom-model';
+ input.provider = 'azure';
+
+ const transport = new ServerLLMTransport(createAttemptCtx());
+ await transport.runAttempt(input);
+
+ expect(chat.mock.calls[0][0].deploymentName).toBe('my-custom-azure-endpoint');
+ });
+
+ it('freezes the absence of an alias on the attempt path too', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+ vi.mocked(resolveServerModel).mockResolvedValue({
+ deploymentName: 'deepseek-v4-pro-ga-260813',
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ });
+
+ const transport = new ServerLLMTransport(createAttemptCtx());
+ await transport.runAttempt(
+ createAttemptInput({
+ modelRuntimeConfig: {
+ model: 'deepseek-v4-pro-ga',
+ modelFacts: {
+ cards: [{ id: 'deepseek-v4-pro-ga', providerId: 'volcengine' }],
+ model: 'deepseek-v4-pro-ga',
+ provider: 'volcengine',
+ },
+ provider: 'volcengine',
+ },
+ }),
+ );
+
+ // Codex P2 (4259967307): same contract as `stream()` β€” a matching frozen
+ // card without an alias freezes the absence, the live catalog is not
+ // consulted, and the attempt payload keeps the bare model id.
+ expect(resolveServerModel).not.toHaveBeenCalled();
+ expect(chat.mock.calls[0][0].deploymentName).toBeUndefined();
+ });
+
+ it('strips the frozen card deployment name for a non-consuming provider (qwen)', async () => {
+ const chat = vi.fn().mockImplementation(async () => new Response(''));
+ vi.mocked(initModelRuntimeFromDB).mockImplementation(async () => new ModelRuntime({ chat }));
+
+ const input = createAttemptInput({
+ modelRuntimeConfig: {
+ model: 'qwen3-vl-flash',
+ modelFacts: {
+ cards: [
+ {
+ deploymentName: 'qwen3-vl-flash-prod',
+ id: 'qwen3-vl-flash',
+ providerId: 'qwen',
+ },
+ ],
+ model: 'qwen3-vl-flash',
+ provider: 'qwen',
+ },
+ provider: 'qwen',
+ },
+ }) as any;
+ input.model = 'qwen3-vl-flash';
+ input.provider = 'qwen';
+
+ const transport = new ServerLLMTransport(createAttemptCtx());
+ await transport.runAttempt(input);
+
+ // Codex P2 (4258586588): the frozen alias sits behind the same provider
+ // gate as the live resolution β€” the qwen adapter forwards unknown payload
+ // fields upstream, so the internal mapping must never reach the wire on
+ // the attempt path either.
+ expect(chat.mock.calls[0][0].deploymentName).toBeUndefined();
+ expect(resolveServerModel).not.toHaveBeenCalled();
+ });
+});
+
describe('ServerLLMTransport.createTrace Β· streaming mode', () => {
it('records the streaming mode the built context resolved, not the operation default', () => {
const startSpan = vi.spyOn(agentRuntimeTracer, 'startSpan');
diff --git a/apps/server/src/modules/AgentRuntime/adapters/ServerLLMTransport.ts b/apps/server/src/modules/AgentRuntime/adapters/ServerLLMTransport.ts
index a4f58fbfc9a..de0c252341f 100644
--- a/apps/server/src/modules/AgentRuntime/adapters/ServerLLMTransport.ts
+++ b/apps/server/src/modules/AgentRuntime/adapters/ServerLLMTransport.ts
@@ -40,8 +40,10 @@ import {
tracer as agentRuntimeTracer,
} from '@lobechat/observability-otel/modules/agent-runtime';
import { RequestTrigger, toAgentShareVisitorIds } from '@lobechat/types';
+import { type AiModelConfig, ModelProvider } from 'model-bank';
-import { initModelRuntimeFromDB } from '@/server/modules/ModelRuntime';
+import { AiModelModel } from '@/database/models/aiModel';
+import { initModelRuntimeFromDB, resolveServerModel } from '@/server/modules/ModelRuntime';
import type { RuntimeExecutorContext } from '../context';
import { log, sleep } from '../executorHelpers';
@@ -73,6 +75,19 @@ const SERVER_LLM_RETRY_POLICY = {
noRetryProviders: [BRANDING_PROVIDER],
};
+/**
+ * Providers that address the request model by the card's
+ * `config.deploymentName` (their adapters read the field and build the final
+ * request model from it). Gating the injected field to this set keeps the
+ * internal mapping from leaking upstream through adapters that don't consume
+ * it (OpenAI-compatible factories forward unknown payload fields).
+ */
+const DEPLOYMENT_NAME_PROVIDERS = new Set<string>([
+ ModelProvider.Azure,
+ ModelProvider.Spark,
+ ModelProvider.Volcengine,
+]);
+
const NETWORK_EMPTY_COMPLETION_MAX_RETRIES = 3;
const NETWORK_EMPTY_COMPLETION_MAX_ATTEMPTS = NETWORK_EMPTY_COMPLETION_MAX_RETRIES + 1;
@@ -276,6 +291,14 @@ export class ServerLLMTransport implements LLMTransport {
ReturnType<ServerLLMTransport['createModelRuntime']>
>();
+ /**
+ * Deployment names the live catalog resolved for a run's model, per
+ * provider:model. The run's attempts share one resolution (retries included)
+ * instead of paying a catalog read per attempt; a resolution failure is not
+ * cached β€” a later attempt may succeed after a transient catalog error.
+ */
+ private readonly resolvedDeploymentNames = new Map<string, Promise<string | undefined>>();
+
/**
* Output of the latest relayed attempt that failed after producing some,
* per assistant message. A re-dispatch that never gets claimed (the tab that
@@ -340,32 +363,54 @@ export class ServerLLMTransport implements LLMTransport {
payload: LLMStreamPayload,
handlers?: Parameters<LLMTransport['stream']>[1],
): Promise<LLMStreamResult> {
- const runtime = await this.createStreamRuntime(payload.provider);
+ const { runtime, state } = await this.createStreamRuntime(payload.provider);
+ // `stream()` only serves context compression. Deployment-catalog providers
+ // (Azure, Volcengine Ark, Spark) address the request model by the card's
+ // `config.deploymentName` β€” the same mapping `runAttemptWithRuntime`
+ // applies from the run's frozen cards. The snapshot is authoritative once
+ // it applies: a frozen card without a `deploymentName` freezes that
+ // absence, so steps in the same run never disagree about the endpoint
+ // (`readFrozenModelFacts` already merged the user alias into the card at
+ // freeze time). Only a snapshot with no matching card resolves the
+ // deployment catalog live, and an unresolvable one keeps the bare id.
+ const frozenCard = state?.modelRuntimeConfig?.modelFacts?.cards.find(
+ (card) =>
+ card.providerId === payload.provider &&
+ (card.id === payload.model || card.deploymentName === payload.model),
+ );
+ const deploymentName = !DEPLOYMENT_NAME_PROVIDERS.has(payload.provider)
+ ? undefined
+ : frozenCard
+ ? frozenCard.deploymentName
+ : await this.resolveStreamDeploymentName(payload.provider, payload.model);
const { provider: _provider, ...runtimePayload } = payload;
let content = '';
let usage: LLMStreamResult['usage'];
let streamError: unknown;
- const response = await runtime.chat(runtimePayload as any, {
- callback: {
- onCompletion: async (data: any) => {
- if (data.usage) usage = data.usage;
- },
- onError: async (errorData: unknown) => {
- streamError = errorData;
- handlers?.onError?.(errorData);
- },
- onText: async (text: string) => {
- content += text;
- handlers?.onText?.(text);
+ const response = await runtime.chat(
+ { ...runtimePayload, ...(deploymentName && { deploymentName }) } as any,
+ {
+ callback: {
+ onCompletion: async (data: any) => {
+ if (data.usage) usage = data.usage;
+ },
+ onError: async (errorData: unknown) => {
+ streamError = errorData;
+ handlers?.onError?.(errorData);
+ },
+ onText: async (text: string) => {
+ content += text;
+ handlers?.onText?.(text);
+ },
},
+ // `stream()` only serves context compression. Without a trigger, RouterRuntime
+ // rejects the call in development (skipping compression) and bills it as
+ // trigger=null in production.
+ metadata: { topicId: this.ctx.topicId, trigger: RequestTrigger.ContextCompression },
+ user: this.ctx.userId,
},
- // `stream()` only serves context compression. Without a trigger, RouterRuntime
- // rejects the call in development (skipping compression) and bills it as
- // trigger=null in production.
- metadata: { topicId: this.ctx.topicId, trigger: RequestTrigger.ContextCompression },
- user: this.ctx.userId,
- });
+ );
await consumeStreamUntilDone(response);
@@ -392,13 +437,94 @@ export class ServerLLMTransport implements LLMTransport {
}
if (site.site === 'client') {
this.relayStreamCount += 1;
- return this.createRelayRuntime(provider, site, {
- attempt: 1,
- callId: `${buildLlmRelayCallId(this.ctx.operationId, this.ctx.stepIndex, this.relayGeneration, 1)}:stream${this.relayStreamCount}`,
- });
+ return {
+ runtime: this.createRelayRuntime(provider, site, {
+ attempt: 1,
+ callId: `${buildLlmRelayCallId(this.ctx.operationId, this.ctx.stepIndex, this.relayGeneration, 1)}:stream${this.relayStreamCount}`,
+ }),
+ state,
+ };
+ }
+
+ return { runtime: await this.createModelRuntime(provider), state };
+ }
+
+ /**
+ * Live deployment-name resolution for a compression model outside the run's
+ * frozen cards. Best effort: compression is an optimization, so an unknown
+ * model keeps the bare id instead of failing the run.
+ */
+ private async resolveStreamDeploymentName(provider: string, model: string) {
+ // The user's own model row first β€” a user-configured deployment alias
+ // (`ai_models.config.deploymentName`) must win over the bundled card, and
+ // a custom model has no bundled card at all. The deployment-owned catalog
+ // behind `resolveServerModel` never sees this row, so without the read a
+ // custom alias is replaced by the bundled alias or dropped, and the
+ // request 404s on the user's endpoint.
+ if (this.ctx.serverDB && this.ctx.userId) {
+ try {
+ const row = await new AiModelModel(
+ this.ctx.serverDB,
+ this.ctx.userId,
+ this.ctx.workspaceId,
+ ).findByIdAndProvider(model, provider);
+ const userAlias = (row?.config as AiModelConfig | null)?.deploymentName;
+ if (userAlias) return userAlias;
+ } catch (error) {
+ // A user-row read failure must not kill the catalog fallback below,
+ // but the fallback can yield a bundled alias (or fail) and 404
+ // downstream, so the failed lookup must stay diagnosable.
+ log(
+ '[%s] deploymentName user-row lookup failed for %s:%s; falling back to the global catalog: %s',
+ `${this.ctx.operationId}:${this.ctx.stepIndex}`,
+ provider,
+ model,
+ getErrorMessage(error),
+ );
+ }
+ }
+ try {
+ const resolved = await resolveServerModel(provider, model);
+ return resolved.deploymentName;
+ } catch (error) {
+ log(
+ '[%s] deploymentName catalog resolution failed for %s:%s; keeping the bare model id: %s',
+ `${this.ctx.operationId}:${this.ctx.stepIndex}`,
+ provider,
+ model,
+ getErrorMessage(error),
+ );
+ return undefined;
}
+ }
- return this.createModelRuntime(provider);
+ /**
+ * Live deployment-name resolution for a run attempt whose operation has no
+ * frozen `modelFacts` snapshot (agent-signal memory actions, persisted
+ * operations predating `modelFacts`). Same best-effort contract as
+ * `resolveStreamDeploymentName`: an unresolvable model keeps the bare id.
+ * The run's attempts share one resolution per provider:model (retries
+ * included) instead of paying a catalog read per attempt.
+ */
+ private resolveAttemptDeploymentName(provider: string, model: string) {
+ const key = `${provider}:${model}`;
+ let promise = this.resolvedDeploymentNames.get(key);
+ if (!promise) {
+ promise = this.resolveStreamDeploymentName(provider, model).finally(() => {
+ // Keep failures out of the cache so a transient catalog error doesn't
+ // pin the bare id for the rest of the run.
+ if (promise) {
+ promise.then(
+ (resolved) => {
+ if (!resolved) this.resolvedDeploymentNames.delete(key);
+ },
+ () => this.resolvedDeploymentNames.delete(key),
+ );
+ }
+ });
+ this.resolvedDeploymentNames.set(key, promise);
+ }
+ return promise;
}
private createRelayRuntime(
@@ -506,6 +632,29 @@ export class ServerLLMTransport implements LLMTransport {
if (!resolved) throw new Error('Resolved tools are required for a server LLM attempt');
const tools = resolved.tools.length > 0 ? resolved.tools : undefined;
+ // Providers that address models by a deployment/catalog name (Azure,
+ // Volcengine Ark, Spark) resolve the request model from the card's
+ // `config.deploymentName`. The run froze the matching card at operation
+ // creation, so the mapping needs no bank or DB read per attempt. The
+ // snapshot is authoritative once it applies: a frozen card without a
+ // `deploymentName` freezes that absence, so attempts in the same run
+ // never disagree about the endpoint. Live resolution serves only
+ // operations whose snapshot has no matching card (agent-signal memory
+ // actions, persisted operations predating `modelFacts`) β€” the same
+ // mapping `stream()` applies for compression models. Frozen and live
+ // aliases sit behind the same provider gate: adapters that don't consume
+ // the field (OpenAI-compatible factories forward unknown payload fields)
+ // must never see the internal mapping on the wire.
+ const frozenCard = input.state.modelRuntimeConfig?.modelFacts?.cards.find(
+ (card) =>
+ card.providerId === input.provider &&
+ (card.id === input.model || card.deploymentName === input.model),
+ );
+ const deploymentName = !DEPLOYMENT_NAME_PROVIDERS.has(input.provider)
+ ? undefined
+ : frozenCard
+ ? frozenCard.deploymentName
+ : await this.resolveAttemptDeploymentName(input.provider, input.model);
const chatPayload = {
messages: input.context.messages as ChatStreamPayload['messages'],
model: input.model,
@@ -515,6 +664,7 @@ export class ServerLLMTransport implements LLMTransport {
...(typeof input.context.preserveThinking === 'boolean' && {
preserveThinking: input.context.preserveThinking,
}),
+ ...(deploymentName && { deploymentName }),
};
const operationLogId = `${this.ctx.operationId}:${this.ctx.stepIndex}`;
const attempt = createServerCallLlmAttempt({
diff --git a/apps/server/src/modules/AgentRuntime/adapters/serverCallLlmContextHints.test.ts b/apps/server/src/modules/AgentRuntime/adapters/serverCallLlmContextHints.test.ts
index 4e71609d7f8..317bbc2a2f3 100644
--- a/apps/server/src/modules/AgentRuntime/adapters/serverCallLlmContextHints.test.ts
+++ b/apps/server/src/modules/AgentRuntime/adapters/serverCallLlmContextHints.test.ts
@@ -773,6 +773,41 @@ describe('resolveServerCallLlmContextHints - frozen operation facts', () => {
);
});
+ it('freezes the user-configured deployment alias over the bundled card', async () => {
+ // Codex P1 (4256356269): the settings flow persists a user alias in
+ // ai_models.config.deploymentName; the server sourcing path must carry it
+ // into the frozen facts, or the transport injects the bundled alias and
+ // calls 404 wherever only the user's endpoint exists.
+ loadModelsMock.mockResolvedValue([
+ {
+ abilities: {},
+ config: { deploymentName: 'deepseek-v4-pro-ga-260813' },
+ displayName: 'DeepSeek V4 Pro 0813',
+ id: 'deepseek-v4-pro-ga',
+ providerId: 'volcengine',
+ },
+ ]);
+ findByIdAndProviderMock.mockResolvedValue({
+ config: { deploymentName: 'prod-endpoint' },
+ displayName: 'DeepSeek V4 Pro 0813',
+ });
+
+ const ctx = createCtx();
+ const modelFacts = await readFrozenModelFacts(
+ { agent: {}, model: 'deepseek-v4-pro-ga', provider: 'volcengine', topicId: ctx.topicId },
+ createServerModelParamsProviders({
+ builtinModels: await loadModelsMock(),
+ serverDB: ctx.serverDB,
+ userId: ctx.userId,
+ }),
+ );
+
+ expect(modelFacts.cards.find((card) => card.providerId === 'volcengine')?.deploymentName).toBe(
+ 'prod-endpoint',
+ );
+ expect(modelFacts.userModelRow?.deploymentName).toBe('prod-endpoint');
+ });
+
it('resolves live for an attempt on another model', async () => {
await resolveServerCallLlmContextHints({
ctx: frozenCtx(),
diff --git a/apps/server/src/modules/AgentRuntime/adapters/serverCallLlmContextHints.ts b/apps/server/src/modules/AgentRuntime/adapters/serverCallLlmContextHints.ts
index 1e1c6b39c9a..45a5aed198c 100644
--- a/apps/server/src/modules/AgentRuntime/adapters/serverCallLlmContextHints.ts
+++ b/apps/server/src/modules/AgentRuntime/adapters/serverCallLlmContextHints.ts
@@ -11,7 +11,7 @@ import {
resolveModelParams,
} from '@lobechat/mecha';
import type { UIChatMessage } from '@lobechat/types';
-import type { LobeDefaultAiModelListItem } from 'model-bank';
+import type { AiModelConfig, LobeDefaultAiModelListItem } from 'model-bank';
import { loadModels } from '@/business/client/model-bank/loadModels';
import type { AiModelModel } from '@/database/models/aiModel';
@@ -74,6 +74,10 @@ export const resolveModelExtendParamsForUser = async ({
if (!row) return null;
return {
abilities: row.abilities,
+ // Carried so the frozen facts merge the user's deployment alias
+ // over the bundled card; without it the transport injects the
+ // catalog default instead of the user's endpoint.
+ deploymentName: (row.config as AiModelConfig | null)?.deploymentName ?? null,
displayName: row.displayName,
extendParams: row.settings?.extendParams ?? undefined,
};
diff --git a/apps/server/src/modules/Mecha/ModelParams/providers.ts b/apps/server/src/modules/Mecha/ModelParams/providers.ts
index a0bf3255856..c47ebe313c8 100644
--- a/apps/server/src/modules/Mecha/ModelParams/providers.ts
+++ b/apps/server/src/modules/Mecha/ModelParams/providers.ts
@@ -1,6 +1,6 @@
import type { LobeChatDatabase } from '@lobechat/database';
import type { ModelCardFacts, ModelParamsProviders } from '@lobechat/mecha';
-import type { LobeDefaultAiModelListItem } from 'model-bank';
+import type { AiModelConfig, LobeDefaultAiModelListItem } from 'model-bank';
import { AiModelModel } from '@/database/models/aiModel';
import { TopicModel } from '@/database/models/topic';
@@ -69,6 +69,10 @@ export const createServerModelParamsProviders = ({
if (!row) return null;
return {
abilities: row.abilities,
+ // Deployment-catalog providers resolve the request model by this alias
+ // (merged over the bundled card when the facts freeze); without it the
+ // transport injects the catalog default instead of the user's endpoint.
+ deploymentName: (row.config as AiModelConfig | null)?.deploymentName ?? null,
displayName: row.displayName,
extendParams: row.settings?.extendParams ?? undefined,
};
diff --git a/apps/server/src/services/aiAgent/pipeline/toolDiscovery.ts b/apps/server/src/services/aiAgent/pipeline/toolDiscovery.ts
index 1c1967c58f0..b330e86f923 100644
--- a/apps/server/src/services/aiAgent/pipeline/toolDiscovery.ts
+++ b/apps/server/src/services/aiAgent/pipeline/toolDiscovery.ts
@@ -41,7 +41,7 @@ import {
} from '@lobechat/types';
import { TRPCError } from '@trpc/server';
import debug from 'debug';
-import type { ModelAbilities } from 'model-bank';
+import type { AiModelConfig, ModelAbilities } from 'model-bank';
import { loadModels } from '@/business/client/model-bank/loadModels';
import { AiModelModel } from '@/database/models/aiModel';
@@ -695,6 +695,11 @@ export const discoverTools = async (
activeModelMetadata
? {
abilities: activeModelMetadata.abilities,
+ // Deployment-catalog providers resolve the request model by the
+ // user-configured alias when present (merged over the bundled
+ // card when the facts freeze).
+ deploymentName:
+ (activeModelMetadata.config as AiModelConfig | null)?.deploymentName ?? null,
displayName: activeModelMetadata.displayName,
extendParams: activeModelMetadata.settings?.extendParams ?? undefined,
}
diff --git a/packages/mecha/src/modelParams/resolveModelParams.test.ts b/packages/mecha/src/modelParams/resolveModelParams.test.ts
index d1197a8b743..07a5de22b53 100644
--- a/packages/mecha/src/modelParams/resolveModelParams.test.ts
+++ b/packages/mecha/src/modelParams/resolveModelParams.test.ts
@@ -410,4 +410,62 @@ describe('frozen model facts', () => {
expect(other.capabilities.isCanUseFC('plain', 'openai')).toBe(true);
expect(other.capabilities.isCanUseVision('plain', 'openai')).toBe(false);
});
+
+ it('merges the user deployment alias over the bundled card when freezing', async () => {
+ // Codex P1 (4256356269): a user-configured alias must win over the bundled
+ // card, otherwise deployment-catalog providers inject the catalog default
+ // and 404 wherever only the user's endpoint exists.
+ const live = liveProviders();
+ live.getUserModelRow.mockResolvedValue({ deploymentName: 'prod-endpoint' });
+
+ const facts = await readFrozenModelFacts(
+ request({ model: 'deepseek-v4-pro', provider: 'deepseek' }),
+ live,
+ );
+ const frozenCard = facts.cards.find((card) => card.providerId === 'deepseek');
+ expect(frozenCard?.deploymentName).toBe('prod-endpoint');
+ // The bundled card is preserved apart from the alias.
+ expect(frozenCard).toMatchObject({ displayName: 'DeepSeek V4 Pro', id: 'deepseek-v4-pro' });
+ // And the transport's lookup answers from the snapshot as stored.
+ expect(
+ facts.cards.find(
+ (card) =>
+ card.providerId === 'deepseek' &&
+ (card.id === 'deepseek-v4-pro' || card.deploymentName === 'deepseek-v4-pro'),
+ )?.deploymentName,
+ ).toBe('prod-endpoint');
+ });
+
+ it('freezes a minimal deployment card for a custom model the bank has no card for', async () => {
+ const live = liveProviders();
+ live.getUserModelRow.mockResolvedValue({ deploymentName: 'prod-endpoint' });
+
+ // No bundled card under volcengine: the user row alone still names the
+ // deployment the transport must inject.
+ const facts = await readFrozenModelFacts(
+ request({ model: 'deepseek-v4-pro', provider: 'volcengine' }),
+ live,
+ );
+ expect(facts.cards[0]).toEqual({
+ deploymentName: 'prod-endpoint',
+ id: 'deepseek-v4-pro',
+ providerId: 'volcengine',
+ });
+ // The canonical card of the same id elsewhere is frozen untouched.
+ expect(facts.cards.slice(1)).not.toContainEqual(
+ expect.objectContaining({ providerId: 'volcengine' }),
+ );
+ });
+
+ it('keeps the bundled deployment name when the user row has none', async () => {
+ const live = liveProviders();
+ live.getUserModelRow.mockResolvedValue({ displayName: 'My model' });
+
+ const facts = await readFrozenModelFacts(
+ request({ model: 'deepseek-v4-pro', provider: 'deepseek' }),
+ live,
+ );
+ const frozenCard = facts.cards.find((card) => card.providerId === 'deepseek');
+ expect(frozenCard?.deploymentName).toBeUndefined();
+ });
});
diff --git a/packages/mecha/src/modelParams/resolveModelParams.ts b/packages/mecha/src/modelParams/resolveModelParams.ts
index f3067bda215..635b3915af5 100644
--- a/packages/mecha/src/modelParams/resolveModelParams.ts
+++ b/packages/mecha/src/modelParams/resolveModelParams.ts
@@ -147,11 +147,26 @@ export const readFrozenModelFacts = async (
? await resolveReasoningConfig(request, providers)
: undefined;
+ // Deployment-catalog providers (Azure, Volcengine Ark, Spark) address the
+ // request model by the card's `config.deploymentName`, and the transport
+ // resolves it from the frozen provider card. A user-configured alias
+ // (`ai_models.config.deploymentName`) replaces the bundled one β€” otherwise
+ // calls 404 wherever only the user's endpoint exists.
+ const deploymentName = userModelRow?.deploymentName || modelCard?.deploymentName || undefined;
+ const mergedModelCard: ModelCardFacts | undefined = modelCard
+ ? { ...modelCard, ...(deploymentName ? { deploymentName } : {}) }
+ : userModelRow?.deploymentName
+ ? // A custom model has no bundled card; the user row alone still names
+ // its deployment, so freeze a minimal card for the transport.
+ { deploymentName: userModelRow.deploymentName, id: model, providerId: provider }
+ : undefined;
+
return {
- // Only the two cards the rules can match β€” the provider's own and the
- // canonical one of the same id elsewhere. The whole bank would not fit the
- // state, and nothing asks about another model (see the frozen providers).
- cards: [modelCard, canonicalModelCard].filter(
+ // Only the two cards the rules can match β€” the provider's own (with the
+ // user's deployment alias merged over the bundled value) and the canonical
+ // one of the same id elsewhere. The whole bank would not fit the state,
+ // and nothing asks about another model (see the frozen providers).
+ cards: [mergedModelCard, canonicalModelCard].filter(
(card, index, all): card is ModelCardFacts => !!card && all.indexOf(card) === index,
),
// Only the three flags the rules read: a host may hand over a fuller
diff --git a/packages/model-runtime/src/providers/volcengine/index.test.ts b/packages/model-runtime/src/providers/volcengine/index.test.ts
index f3778935249..6f715a78d0b 100644
--- a/packages/model-runtime/src/providers/volcengine/index.test.ts
+++ b/packages/model-runtime/src/providers/volcengine/index.test.ts
@@ -148,6 +148,99 @@ describe('LobeVolcengineAI - custom features', () => {
},
);
+ describe('deploymentName resolution', () => {
+ it('sends the builtin card deployment name instead of the logical id on the chat path', async () => {
+ // The builtin card: id `deepseek-v4-pro-ga`, Ark name
+ // `deepseek-v4-pro-ga-260813`. Sending the bare id 404s with
+ // InvalidEndpointOrModel.NotFound (vent 2026-10-09).
+ await instance.chat({
+ messages: [{ content: 'Hello', role: 'user' }],
+ model: 'deepseek-v4-pro-ga',
+ deploymentName: 'deepseek-v4-pro-ga-260813',
+ });
+
+ const calledPayload = (instance['client'].chat.completions.create as any).mock.calls[0][0];
+ expect(calledPayload.model).toBe('deepseek-v4-pro-ga-260813');
+ });
+
+ it('falls back to the payload model when no deploymentName is given', async () => {
+ await instance.chat({
+ messages: [{ content: 'Hello', role: 'user' }],
+ model: 'deepseek-v4-pro-ga',
+ });
+
+ const calledPayload = (instance['client'].chat.completions.create as any).mock.calls[0][0];
+ expect(calledPayload.model).toBe('deepseek-v4-pro-ga');
+ });
+
+ it('keeps the reasoning-effort mapping on the resolved (deployment) model name', async () => {
+ await instance.chat({
+ messages: [{ content: 'Hello', role: 'user' }],
+ model: 'deepseek-v4-pro-ga',
+ deploymentName: 'deepseek-v4-pro-ga-260813',
+ thinking: { type: 'enabled' },
+ });
+
+ const calledPayload = (instance['client'].chat.completions.create as any).mock.calls[0][0];
+ expect(calledPayload.model).toBe('deepseek-v4-pro-ga-260813');
+ expect(calledPayload.reasoning_effort).toBe('high');
+ });
+
+ // deploymentName can be a custom alias (e.g. `prod-endpoint`) that hides
+ // the deepseek-v4 / glm-5-2 family. Family detection must run on the
+ // logical model, or the reasoning-effort mapping silently disappears
+ // (Codex P2 on PR #20645).
+ it('maps reasoning params for a deepseek-v4 card even when deploymentName is a custom alias (chat path)', async () => {
+ await instance.chat({
+ messages: [{ content: 'Hello', role: 'user' }],
+ model: 'deepseek-v4-pro-ga',
+ deploymentName: 'prod-endpoint',
+ thinking: { type: 'enabled' },
+ });
+
+ const calledPayload = (instance['client'].chat.completions.create as any).mock.calls[0][0];
+ expect(calledPayload.model).toBe('prod-endpoint');
+ expect(calledPayload.reasoning_effort).toBe('high');
+ });
+
+ it('maps reasoning params for a deepseek-v4 card even when deploymentName is a custom alias (responses path)', async () => {
+ vi.spyOn(instance['client'].responses, 'create').mockResolvedValue(
+ new ReadableStream() as any,
+ );
+
+ await instance.chat({
+ messages: [{ content: 'Hello', role: 'user' }],
+ model: 'deepseek-v4-pro-ga',
+ deploymentName: 'prod-endpoint',
+ reasoning_effort: 'max',
+ enabledSearch: true,
+ thinking: { type: 'enabled' },
+ });
+
+ const calledPayload = (instance['client'].responses.create as any).mock.calls[0][0];
+ expect(calledPayload.model).toBe('prod-endpoint');
+ // Responses path converts effort `max` to `high` for the deepseek-v4 family.
+ expect(calledPayload.reasoning.effort).toBe('high');
+ });
+
+ it('sends the deployment name on the responses path', async () => {
+ vi.spyOn(instance['client'].responses, 'create').mockResolvedValue(
+ new ReadableStream() as any,
+ );
+
+ // enabledSearch switches the provider onto the Responses API.
+ await instance.chat({
+ messages: [{ content: 'Hello', role: 'user' }],
+ model: 'deepseek-v4-pro-ga',
+ deploymentName: 'deepseek-v4-pro-ga-260813',
+ enabledSearch: true,
+ });
+
+ const calledPayload = (instance['client'].responses.create as any).mock.calls[0][0];
+ expect(calledPayload.model).toBe('deepseek-v4-pro-ga-260813');
+ });
+ });
+
it('still honours reasoning_effort when the thinking type was dropped', async () => {
await instance.chat({
messages: [{ content: 'Hello', role: 'user' }],
diff --git a/packages/model-runtime/src/providers/volcengine/index.ts b/packages/model-runtime/src/providers/volcengine/index.ts
index 87f1224affe..0b07e9a9522 100644
--- a/packages/model-runtime/src/providers/volcengine/index.ts
+++ b/packages/model-runtime/src/providers/volcengine/index.ts
@@ -68,25 +68,31 @@ export const LobeVolcengineAI = createOpenAICompatibleRuntime({
baseURL: 'https://ark.cn-beijing.volces.com/api/v3',
chatCompletion: {
handlePayload: (payload) => {
- const { enabledSearch, thinking, reasoning_effort, ...rest } = payload;
+ // Ark addresses models by their catalog (deployment) name, not the
+ // logical id the builtin cards ship with (`deepseek-v4-pro-ga` vs
+ // `deepseek-v4-pro-ga-260813`): sending the bare id 404s with
+ // InvalidEndpointOrModel.NotFound. Same pattern as spark/azureOpenai.
+ const { deploymentName, enabledSearch, model, thinking, reasoning_effort, ...rest } = payload;
+ const requestModel = deploymentName ?? model;
if (enabledSearch) {
return {
...rest,
+ model: requestModel,
apiMode: 'responses',
enabledSearch,
} as ChatStreamPayload;
}
- const params = resolveVolcengineReasoningParams(
- payload.model,
- thinking,
- reasoning_effort,
- false,
- );
+ // Family detection runs on the logical `model`, not `requestModel`:
+ // deploymentName can be a custom alias (e.g. `prod-endpoint`) that hides
+ // the deepseek-v4 / glm-5-2 family and would skip the reasoning-effort
+ // mapping. requestModel stays reserved for the outgoing payload.
+ const params = resolveVolcengineReasoningParams(model, thinking, reasoning_effort, false);
return {
...rest,
+ model: requestModel,
...(params.thinking?.type && { thinking: { type: params.thinking.type } }),
...(params.reasoning_effort && { reasoning_effort: params.reasoning_effort }),
} as any;
@@ -102,13 +108,10 @@ export const LobeVolcengineAI = createOpenAICompatibleRuntime({
provider: ModelProvider.Volcengine,
responses: {
handlePayload: (payload) => {
- const { enabledSearch, tools, thinking, reasoning_effort, ...rest } = payload;
- const params = resolveVolcengineReasoningParams(
- payload.model,
- thinking,
- reasoning_effort,
- true,
- );
+ const { deploymentName, enabledSearch, model, tools, thinking, reasoning_effort, ...rest } =
+ payload;
+ const requestModel = deploymentName ?? model;
+ const params = resolveVolcengineReasoningParams(model, thinking, reasoning_effort, true);
const volcengineTools = enabledSearch
? [
@@ -124,6 +127,7 @@ export const LobeVolcengineAI = createOpenAICompatibleRuntime({
return {
...rest,
+ model: requestModel,
tools: volcengineTools,
...(params.thinking?.type && { thinking: { type: params.thinking.type } }),
...(params.reasoning_effort && { reasoning_effort: params.reasoning_effort }),
diff --git a/packages/types/src/agentExecution/modelFacts.ts b/packages/types/src/agentExecution/modelFacts.ts
index a91aa1ecd1e..e8d5da24cde 100644
--- a/packages/types/src/agentExecution/modelFacts.ts
+++ b/packages/types/src/agentExecution/modelFacts.ts
@@ -16,6 +16,14 @@ export interface ModelCardFacts {
export interface UserModelRowFacts {
/** Stored as untyped JSON; a non-empty object replaces the card's abilities. */
abilities?: unknown;
+ /**
+ * User-configured deployment alias (`ai_models.config.deploymentName`).
+ * Deployment-catalog providers (Azure, Volcengine Ark, Spark) address the
+ * request model by it, so the frozen provider card merges this over the
+ * bundled value and the transport injects the user's endpoint, not the
+ * catalog default.
+ */
+ deploymentName?: string | null;
displayName?: string | null;
/** `[]` is an explicit opt-out from the card's params; absent falls back to the cards. */
extendParams?: string[] | null;