Files
openclaw/src/agents/models-config.providers.modelstudio.test.ts
peizhe.chen 42837a04bf fix(models): preserve stream usage compat opt-ins (#45733)
Preserves explicit `supportsUsageInStreaming` overrides from built-in provider
catalogs and user config instead of unconditionally forcing `false` on non-native
openai-completions endpoints.

Adds `applyNativeStreamingUsageCompat()` to set `supportsUsageInStreaming: true`
on ModelStudio (DashScope) and Moonshot models at config build time so their
native streaming usage works out of the box.

Closes #46142

Co-authored-by: pezy <peizhe.chen@vbot.cn>
2026-03-15 20:21:11 +01:00

37 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
applyNativeStreamingUsageCompat,
buildModelStudioProvider,
} from "./models-config.providers.js";
describe("Model Studio implicit provider", () => {
it("should opt native Model Studio baseUrls into streaming usage", () => {
const providers = applyNativeStreamingUsageCompat({
modelstudio: buildModelStudioProvider(),
});
expect(providers?.modelstudio).toBeDefined();
expect(providers?.modelstudio?.baseUrl).toBe("https://coding-intl.dashscope.aliyuncs.com/v1");
expect(
providers?.modelstudio?.models?.every(
(model) => model.compat?.supportsUsageInStreaming === true,
),
).toBe(true);
});
it("should keep streaming usage opt-in disabled for custom Model Studio-compatible baseUrls", () => {
const providers = applyNativeStreamingUsageCompat({
modelstudio: {
...buildModelStudioProvider(),
baseUrl: "https://proxy.example.com/v1",
},
});
expect(providers?.modelstudio).toBeDefined();
expect(providers?.modelstudio?.baseUrl).toBe("https://proxy.example.com/v1");
expect(
providers?.modelstudio?.models?.some(
(model) => model.compat?.supportsUsageInStreaming === true,
),
).toBe(false);
});
});