Skip to content

Commit 3e471bd

Browse files
authored
test: remove obsolete provider runtime wrappers (#124182)
1 parent 7862a5d commit 3e471bd

6 files changed

Lines changed: 3 additions & 195 deletions

‎src/agents/models-config.runtime-source-snapshot.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ vi.mock("./model-auth-env-vars.js", () => ({
2626
}));
2727

2828
vi.mock("../plugins/provider-runtime.js", () => ({
29-
applyProviderConfigDefaultsWithPlugin: (config: OpenClawConfig) => config,
3029
applyProviderNativeStreamingUsageCompatWithPlugin: () => undefined,
3130
normalizeProviderConfigWithPlugin: () => undefined,
3231
resolveProviderConfigApiKeyWithPlugin: () => undefined,

‎src/gateway/gateway-models.profiles.live.test.ts‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import { isTruthyEnvValue } from "../infra/env.js";
7373
import type { ModelRegistry } from "../llm/model-registry.js";
7474
import { redactSecrets } from "../logging/redact.js";
7575
import { normalizeGooglePreviewModelId } from "../plugin-sdk/provider-model-shared.js";
76-
import { resolveRuntimeThinkingProfile } from "../plugins/provider-runtime.js";
76+
import { resolveEffectiveThinkingProfile } from "../plugins/provider-thinking.js";
7777
import { LEGACY_IMPLICIT_AGENT_ID as DEFAULT_AGENT_ID } from "../routing/session-key.js";
7878
import { stripAssistantInternalScaffolding } from "../shared/text/assistant-visible-text.js";
7979
import { findFinalTagMatches, stripFinalTags } from "../shared/text/final-tags.js";
@@ -1711,7 +1711,6 @@ describe("resolveGatewayLiveModelThinkingLevel", () => {
17111711
(id) => {
17121712
expect(
17131713
resolveGatewayLiveModelThinkingLevel({
1714-
cfg: {},
17151714
model: {
17161715
...createGatewayLiveTestModel("openai", id),
17171716
reasoning: true,
@@ -1726,7 +1725,6 @@ describe("resolveGatewayLiveModelThinkingLevel", () => {
17261725
it("preserves exact max for max-capable GPT-5.6 metadata", () => {
17271726
expect(
17281727
resolveGatewayLiveModelThinkingLevel({
1729-
cfg: {},
17301728
model: {
17311729
...createGatewayLiveTestModel("openai", "gpt-5.6-sol"),
17321730
reasoning: true,
@@ -1740,14 +1738,12 @@ describe("resolveGatewayLiveModelThinkingLevel", () => {
17401738
it("fails exact-proof levels instead of silently clamping them", () => {
17411739
expect(() =>
17421740
resolveGatewayLiveModelThinkingLevel({
1743-
cfg: {},
17441741
model: createGatewayLiveTestModel("openai", "gpt-5.5"),
17451742
requestedLevel: "max",
17461743
}),
17471744
).toThrow(/does not advertise max|clamps max/u);
17481745
expect(() =>
17491746
resolveGatewayLiveModelThinkingLevel({
1750-
cfg: {},
17511747
model: createGatewayLiveTestModel("openai", "gpt-5.5"),
17521748
requestedLevel: "ultra",
17531749
}),
@@ -1757,7 +1753,6 @@ describe("resolveGatewayLiveModelThinkingLevel", () => {
17571753
it("clamps requested thinking to levels supported by model metadata", () => {
17581754
expect(
17591755
resolveGatewayLiveModelThinkingLevel({
1760-
cfg: {},
17611756
model: {
17621757
...createGatewayLiveTestModel("example", "reasoning-model"),
17631758
reasoning: true,
@@ -1778,7 +1773,6 @@ describe("resolveGatewayLiveModelThinkingLevel", () => {
17781773
it("does not let provider profiles override model-level thinking support", () => {
17791774
expect(
17801775
resolveGatewayLiveModelThinkingLevel({
1781-
cfg: {},
17821776
model: createGatewayLiveTestModel("openai", "gpt-5.5"),
17831777
requestedLevel: "high",
17841778
}),
@@ -1790,7 +1784,6 @@ describe("resolveGatewayLiveModelThinkingLevel", () => {
17901784
(provider) => {
17911785
expect(
17921786
resolveGatewayLiveModelThinkingLevel({
1793-
cfg: {},
17941787
model: {
17951788
...createGatewayLiveTestModel(provider, "grok-4.5"),
17961789
reasoning: true,
@@ -1814,7 +1807,6 @@ describe("resolveGatewayLiveModelThinkingLevel", () => {
18141807
(provider) => {
18151808
expect(
18161809
resolveGatewayLiveModelThinkingLevel({
1817-
cfg: {},
18181810
model: {
18191811
...createGatewayLiveTestModel(provider, "grok-build-0.1"),
18201812
reasoning: true,
@@ -4269,7 +4261,6 @@ function resolveExplicitLiveModelCandidates(params: {
42694261
}
42704262

42714263
function resolveGatewayLiveModelThinkingLevel(params: {
4272-
cfg: OpenClawConfig;
42734264
model: Model;
42744265
requestedLevel: string;
42754266
}): string {
@@ -4278,9 +4269,8 @@ function resolveGatewayLiveModelThinkingLevel(params: {
42784269
if (!isGatewayLiveThinkingLevel(normalized)) {
42794270
return requestedLevel;
42804271
}
4281-
const profile = resolveRuntimeThinkingProfile({
4272+
const profile = resolveEffectiveThinkingProfile({
42824273
provider: model.provider,
4283-
config: params.cfg,
42844274
context: {
42854275
provider: model.provider,
42864276
modelId: model.id,
@@ -4744,7 +4734,6 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
47444734
const skippedBeforeModel = skippedCount;
47454735
const wireObservationStart = ultraWireCapture?.observations.length ?? 0;
47464736
const thinkingLevel = resolveGatewayLiveModelThinkingLevel({
4747-
cfg: params.cfg,
47484737
model,
47494738
requestedLevel: params.thinkingLevel,
47504739
});

‎src/infra/provider-usage.auth.normalizes-keys.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ const providerRuntimeMocks = vi.hoisted(() => ({
137137
buildProviderAuthDoctorHintWithPlugin: vi.fn(() => undefined),
138138
buildProviderMissingAuthMessageWithPlugin: vi.fn(() => undefined),
139139
buildProviderUnknownModelHintWithPlugin: vi.fn(() => undefined),
140-
createProviderEmbeddingProvider: vi.fn(() => undefined),
141140
formatProviderAuthProfileApiKeyWithPlugin: vi.fn(() => undefined),
142141
normalizeProviderResolvedModelWithPlugin: vi.fn(() => undefined),
143142
prepareProviderDynamicModel: vi.fn(async () => {}),

‎src/plugins/provider-hook-runtime.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import type {
3434
ProviderWrapStreamFnContext,
3535
} from "./types.js";
3636

37-
let providerRuntimePluginCache: ConfigScopedRuntimeCache<ProviderPlugin | null> = new WeakMap();
37+
const providerRuntimePluginCache: ConfigScopedRuntimeCache<ProviderPlugin | null> = new WeakMap();
3838
const defaultProviderRuntimePluginCache = new PluginLruCache<ProviderPlugin | null>(128);
3939

4040
type ProviderRuntimePluginLookupParams = {
@@ -83,11 +83,6 @@ export function getModelProviderRuntimePluginHandle(
8383
: undefined;
8484
}
8585

86-
export function clearProviderRuntimePluginCacheForTest(): void {
87-
providerRuntimePluginCache = new WeakMap();
88-
defaultProviderRuntimePluginCache.clear();
89-
}
90-
9186
function resolveProviderRuntimePluginCacheKey(
9287
params: ProviderRuntimePluginLookupParams,
9388
registryState = getPluginRegistryState(),

‎src/plugins/provider-runtime.test.ts‎

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ let buildProviderAuthDoctorHintWithPlugin: typeof import("./provider-runtime.js"
5959
let buildProviderMissingAuthMessageWithPlugin: typeof import("./provider-runtime.js").buildProviderMissingAuthMessageWithPlugin;
6060
let buildProviderUnknownModelHintWithPlugin: typeof import("./provider-runtime.js").buildProviderUnknownModelHintWithPlugin;
6161
let applyProviderNativeStreamingUsageCompatWithPlugin: typeof import("./provider-runtime.js").applyProviderNativeStreamingUsageCompatWithPlugin;
62-
let applyProviderConfigDefaultsWithPlugin: typeof import("./provider-runtime.js").applyProviderConfigDefaultsWithPlugin;
6362
let formatProviderAuthProfileApiKeyWithPlugin: typeof import("./provider-runtime.js").formatProviderAuthProfileApiKeyWithPlugin;
6463
let loginProviderOAuthWithPlugin: typeof import("./provider-runtime.js").loginProviderOAuthWithPlugin;
6564
let classifyProviderFailoverSignalWithPlugin: typeof import("./provider-runtime.js").classifyProviderFailoverSignalWithPlugin;
@@ -75,11 +74,8 @@ let resolveProviderFollowupFallbackRoute: typeof import("./provider-runtime.js")
7574
let resolveProviderStreamFn: typeof import("./provider-runtime.js").resolveProviderStreamFn;
7675
let resolveProviderTransportTurnStateWithPlugin: typeof import("./provider-runtime.js").resolveProviderTransportTurnStateWithPlugin;
7776
let resolveProviderCacheTtlEligibility: typeof import("./provider-runtime.js").resolveProviderCacheTtlEligibility;
78-
let createProviderEmbeddingProvider: typeof import("./provider-runtime.js").createProviderEmbeddingProvider;
79-
let resolveRuntimeThinkingProfile: typeof import("./provider-runtime.js").resolveRuntimeThinkingProfile;
8077
let resolveProviderModernModelRef: typeof import("./provider-runtime.js").resolveProviderModernModelRef;
8178
let resolveProviderReasoningOutputModeWithPlugin: typeof import("./provider-runtime.js").resolveProviderReasoningOutputModeWithPlugin;
82-
let resolveProviderReplayPolicyWithPlugin: typeof import("./provider-runtime.js").resolveProviderReplayPolicyWithPlugin;
8379
let resolveProviderSystemPromptContribution: typeof import("./provider-runtime.js").resolveProviderSystemPromptContribution;
8480
let resolveExternalAuthProfilesWithPlugins: typeof import("./provider-runtime.js").resolveExternalAuthProfilesWithPlugins;
8581
let resolveProviderSyntheticAuthWithPlugin: typeof import("./provider-runtime.js").resolveProviderSyntheticAuthWithPlugin;
@@ -96,7 +92,6 @@ let prepareProviderRuntimeAuth: typeof import("./provider-runtime.js").preparePr
9692
let refreshProviderOAuthCredentialWithPlugin: typeof import("./provider-runtime.js").refreshProviderOAuthCredentialWithPlugin;
9793
let resolveProviderOAuthCredentialWithPlugin: typeof import("./provider-runtime.js").resolveProviderOAuthCredentialWithPlugin;
9894
let resolveProviderRuntimePlugin: typeof import("./provider-runtime.js").resolveProviderRuntimePlugin;
99-
let providerRuntimeTesting: typeof import("./provider-runtime.js").testing;
10095
let runProviderDynamicModel: typeof import("./provider-runtime.js").runProviderDynamicModel;
10196
let validateProviderReplayTurnsWithPlugin: typeof import("./provider-runtime.js").validateProviderReplayTurnsWithPlugin;
10297
let wrapProviderSimpleCompletionStreamFn: typeof import("./provider-runtime.js").wrapProviderSimpleCompletionStreamFn;
@@ -310,7 +305,6 @@ describe("provider-runtime", () => {
310305
buildProviderMissingAuthMessageWithPlugin,
311306
buildProviderUnknownModelHintWithPlugin,
312307
applyProviderNativeStreamingUsageCompatWithPlugin,
313-
applyProviderConfigDefaultsWithPlugin,
314308
applyProviderResolvedTransportWithPlugin,
315309
classifyProviderFailoverSignalWithPlugin,
316310
formatProviderAuthProfileApiKeyWithPlugin,
@@ -326,11 +320,8 @@ describe("provider-runtime", () => {
326320
resolveProviderStreamFn,
327321
resolveProviderTransportTurnStateWithPlugin,
328322
resolveProviderCacheTtlEligibility,
329-
createProviderEmbeddingProvider,
330-
resolveRuntimeThinkingProfile,
331323
resolveProviderModernModelRef,
332324
resolveProviderReasoningOutputModeWithPlugin,
333-
resolveProviderReplayPolicyWithPlugin,
334325
resolveProviderSystemPromptContribution,
335326
resolveExternalAuthProfilesWithPlugins,
336327
resolveProviderSyntheticAuthWithPlugin,
@@ -347,7 +338,6 @@ describe("provider-runtime", () => {
347338
refreshProviderOAuthCredentialWithPlugin,
348339
resolveProviderOAuthCredentialWithPlugin,
349340
resolveProviderRuntimePlugin,
350-
testing: providerRuntimeTesting,
351341
runProviderDynamicModel,
352342
validateProviderReplayTurnsWithPlugin,
353343
wrapProviderSimpleCompletionStreamFn,
@@ -362,7 +352,6 @@ describe("provider-runtime", () => {
362352

363353
beforeEach(() => {
364354
resetPluginRuntimeStateForTest();
365-
providerRuntimeTesting.clearProviderRuntimePluginCacheForTest();
366355
resolvePluginProvidersMock.mockReset();
367356
resolvePluginProvidersMock.mockReturnValue([]);
368357
isPluginProvidersLoadInFlightMock.mockReset();
@@ -1678,67 +1667,6 @@ describe("provider-runtime", () => {
16781667
});
16791668
});
16801669

1681-
it("resolves thinking profiles from bundled policy surface before runtime plugins", () => {
1682-
const resolveThinkingProfile = vi.fn(() => ({
1683-
levels: [{ id: "off" as const }],
1684-
defaultLevel: "off" as const,
1685-
}));
1686-
resolveBundledProviderPolicySurfaceMock.mockReturnValue({
1687-
resolveThinkingProfile,
1688-
});
1689-
1690-
expect(
1691-
resolveRuntimeThinkingProfile({
1692-
provider: "xai",
1693-
context: {
1694-
provider: "xai",
1695-
modelId: "grok-4.3",
1696-
reasoning: true,
1697-
},
1698-
}),
1699-
).toEqual({ levels: [{ id: "off" }], defaultLevel: "off" });
1700-
1701-
expect(resolveThinkingProfile).toHaveBeenCalledTimes(1);
1702-
expect(resolvePluginProvidersMock).not.toHaveBeenCalled();
1703-
});
1704-
1705-
it("resolves provider config defaults through owner plugins", () => {
1706-
resolvePluginProvidersMock.mockReturnValue([
1707-
{
1708-
id: "anthropic",
1709-
label: "Anthropic",
1710-
auth: [],
1711-
applyConfigDefaults: ({ config }) => ({
1712-
...config,
1713-
agents: {
1714-
defaults: {
1715-
heartbeat: { every: "1h" },
1716-
},
1717-
},
1718-
}),
1719-
},
1720-
]);
1721-
1722-
expect(
1723-
applyProviderConfigDefaultsWithPlugin({
1724-
provider: "anthropic",
1725-
context: {
1726-
provider: "anthropic",
1727-
env: {},
1728-
config: {},
1729-
},
1730-
}),
1731-
).toEqual({
1732-
agents: {
1733-
defaults: {
1734-
heartbeat: {
1735-
every: "1h",
1736-
},
1737-
},
1738-
},
1739-
});
1740-
});
1741-
17421670
it("resolves failover classification through hook-only aliases", () => {
17431671
resolvePluginProvidersMock.mockReturnValue([
17441672
{
@@ -2115,18 +2043,6 @@ describe("provider-runtime", () => {
21152043
resolveExternalAuthProfileProviderPluginIdsMock.mockReturnValue(["demo"]);
21162044
const prepareDynamicModel = vi.fn(async () => undefined);
21172045
const createStreamFn = vi.fn(() => vi.fn());
2118-
const createEmbeddingProvider = vi.fn(async () => ({
2119-
id: "demo",
2120-
model: "demo-embed",
2121-
embedQuery: async () => [1, 0, 0],
2122-
embedBatch: async () => [[1, 0, 0]],
2123-
client: { token: "embed-token" },
2124-
}));
2125-
const buildReplayPolicy = vi.fn(() => ({
2126-
sanitizeMode: "full" as const,
2127-
toolCallIdMode: "strict9" as const,
2128-
allowSyntheticToolResults: true,
2129-
}));
21302046
const sanitizeReplayHistory = vi.fn(
21312047
async ({
21322048
messages,
@@ -2195,7 +2111,6 @@ describe("provider-runtime", () => {
21952111
...providerConfig,
21962112
compat: { supportsUsageInStreaming: true },
21972113
}),
2198-
buildReplayPolicy,
21992114
sanitizeReplayHistory,
22002115
validateReplayTurns,
22012116
normalizeToolSchemas,
@@ -2210,7 +2125,6 @@ describe("provider-runtime", () => {
22102125
expect(model).toEqual(MODEL);
22112126
return streamFn;
22122127
},
2213-
createEmbeddingProvider,
22142128
resolveSyntheticAuth,
22152129
resolveExternalAuthProfiles: ({ store }): ProviderExternalAuthProfile[] =>
22162130
store.profiles["demo:managed"]
@@ -2338,19 +2252,6 @@ describe("provider-runtime", () => {
23382252
}),
23392253
});
23402254

2341-
expect(
2342-
resolveProviderReplayPolicyWithPlugin({
2343-
provider: DEMO_PROVIDER_ID,
2344-
context: createDemoResolvedModelContext({
2345-
modelApi: MODEL.api,
2346-
}),
2347-
}),
2348-
).toEqual({
2349-
sanitizeMode: "full",
2350-
toolCallIdMode: "strict9",
2351-
allowSyntheticToolResults: true,
2352-
});
2353-
23542255
expect(
23552256
resolveProviderReasoningOutputModeWithPlugin({
23562257
provider: DEMO_PROVIDER_ID,
@@ -2380,21 +2281,6 @@ describe("provider-runtime", () => {
23802281
).toBeTypeOf("function");
23812282

23822283
await expectResolvedMatches([
2383-
{
2384-
actual: () =>
2385-
createProviderEmbeddingProvider({
2386-
provider: DEMO_PROVIDER_ID,
2387-
context: createDemoProviderContext({
2388-
config: {} as never,
2389-
model: "demo-embed",
2390-
}),
2391-
}),
2392-
expected: {
2393-
id: "demo",
2394-
model: "demo-embed",
2395-
client: { token: "embed-token" },
2396-
},
2397-
},
23982284
{
23992285
actual: () =>
24002286
prepareProviderRuntimeAuth({
@@ -2647,7 +2533,6 @@ describe("provider-runtime", () => {
26472533
await expectAugmentedCodexCatalog(augmentModelCatalogWithProviderPlugins);
26482534

26492535
expectCalledOnce(
2650-
buildReplayPolicy,
26512536
prepareDynamicModel,
26522537
sanitizeReplayHistory,
26532538
validateReplayTurns,

0 commit comments

Comments
 (0)