Skip to content

Commit 4c669d6

Browse files
Fix Trinity main-session compatibility mismatch
1 parent 7ed372c commit 4c669d6

3 files changed

Lines changed: 39 additions & 16 deletions

File tree

extensions/arcee/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ describe("arcee provider plugin", () => {
150150
} as never),
151151
).toMatchObject({
152152
id: "arcee/trinity-large-thinking",
153+
compat: {
154+
supportsReasoningEffort: false,
155+
supportsTools: false,
156+
},
153157
});
154158

155159
expect(
@@ -196,6 +200,10 @@ describe("arcee provider plugin", () => {
196200
).toMatchObject({
197201
id: "arcee/trinity-large-thinking",
198202
baseUrl: "https://openrouter.ai/api/v1",
203+
compat: {
204+
supportsReasoningEffort: false,
205+
supportsTools: false,
206+
},
199207
});
200208

201209
expect(

extensions/arcee/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from "./provider-catalog.js";
2020
import {
2121
ARCEE_TRINITY_LARGE_THINKING_COMPAT,
22+
applyArceeTrinityLargeThinkingCompat,
2223
normalizeArceeProviderConfig,
2324
shouldContributeArceeTrinityLargeThinkingCompat,
2425
} from "./provider-policy.js";
@@ -100,7 +101,7 @@ function normalizeArceeResolvedModel<T extends { baseUrl?: string; id: string }>
100101
return undefined;
101102
}
102103
return {
103-
...model,
104+
...applyArceeTrinityLargeThinkingCompat(model),
104105
id: normalizedId,
105106
baseUrl: normalizedBaseUrl,
106107
};

extensions/arcee/provider-policy.ts

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,32 @@ export function shouldContributeArceeTrinityLargeThinkingCompat(params: {
7575
return normalizeBaseUrl(params.model.baseUrl) === normalizeBaseUrl(ARCEE_BASE_URL);
7676
}
7777

78+
export function applyArceeTrinityLargeThinkingCompat<T extends { id: string; compat?: unknown }>(
79+
model: T,
80+
): T {
81+
if (!isArceeTrinityLargeThinkingModelId(model.id)) {
82+
return model;
83+
}
84+
const compat =
85+
model.compat && typeof model.compat === "object"
86+
? (model.compat as Record<string, unknown>)
87+
: undefined;
88+
if (
89+
compat?.supportsReasoningEffort ===
90+
ARCEE_TRINITY_LARGE_THINKING_COMPAT.supportsReasoningEffort &&
91+
compat?.supportsTools === ARCEE_TRINITY_LARGE_THINKING_COMPAT.supportsTools
92+
) {
93+
return model;
94+
}
95+
return {
96+
...model,
97+
compat: {
98+
...compat,
99+
...ARCEE_TRINITY_LARGE_THINKING_COMPAT,
100+
} as T extends { compat?: infer TCompat } ? TCompat : never,
101+
} as T;
102+
}
103+
78104
export function normalizeArceeProviderConfig(
79105
providerConfig: ModelProviderConfig,
80106
): ModelProviderConfig {
@@ -91,24 +117,12 @@ export function normalizeArceeProviderConfig(
91117
const hasModels = Array.isArray(providerConfig.models);
92118
const models = hasModels
93119
? providerConfig.models.map((model) => {
94-
if (!isArceeTrinityLargeThinkingModelId(model.id)) {
95-
return model;
96-
}
97-
if (
98-
model.compat?.supportsReasoningEffort ===
99-
ARCEE_TRINITY_LARGE_THINKING_COMPAT.supportsReasoningEffort &&
100-
model.compat?.supportsTools === ARCEE_TRINITY_LARGE_THINKING_COMPAT.supportsTools
101-
) {
120+
const normalizedModel = applyArceeTrinityLargeThinkingCompat(model);
121+
if (normalizedModel === model) {
102122
return model;
103123
}
104124
changed = true;
105-
return {
106-
...model,
107-
compat: {
108-
...model.compat,
109-
...ARCEE_TRINITY_LARGE_THINKING_COMPAT,
110-
},
111-
};
125+
return normalizedModel;
112126
})
113127
: providerConfig.models;
114128

0 commit comments

Comments
 (0)