Skip to content

Commit fc706f6

Browse files
lidge-junSmartnewb
andcommitted
fix(devin): apply explicit SWE-2 effort before model suffix
Carry #4420 from 6a456fb onto 7ca00ff. Cognition spells SWE-2 effort as the model id rather than a separate field, and resolveWireModelUid returned early whenever the id already carried an effort suffix. Asking for swe-2-high at medium therefore stayed swe-2-high and the caller was silently ignored. Resolve an explicit SWE-2 effort to the native medium/high/max UID before that shortcut runs. none, off, minimal and low select Medium, since SWE-2 has no lane below it and rounding down to nothing would quietly disable its reasoning; xhigh, ultra and max select Max. Omitted or unknown effort preserves the variant, and other model families keep their existing suffix precedence. Two deliberate differences from the source PR. The effort map is a named table instead of an inline branch, because EFFORT_SUFFIXES does not carry ultra, off or minimal and the two would drift apart silently. And matching is case-insensitive, so a caller sending HIGH reaches the same lane as high. The resolver is exposed to tests through resolveWireModelUidForTests rather than by exporting its bare name, mirroring sanitizeToolDescriptionForCognitionForTests: it is an async helper that reaches the catalog and does not belong in the adapter public API. Ownership is recorded in structure/adapters/registry.md and the user-facing adapters page. The source PR also pasted the same sentence into six unrelated structure files; those hunks are omitted, and the structure gate checks path mentions rather than behavioral prose, so the omission is safe. This is the post-ACP landing of closed #4416 and does not restore ACP. Local product tests, typecheck, build and install: NOT RUN. Hosted exact-head CI on this PR is the merge proof. Co-authored-by: Smartnewb <[email protected]>
1 parent 2c2223b commit fc706f6

4 files changed

Lines changed: 95 additions & 1 deletion

File tree

‎docs-site/src/content/docs/reference/adapters.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,13 @@ Login opens Auth0 browser sign-in, then exchanges the Firebase ID token via
451451
- Experimental unofficial bridge; not shown in the dashboard preset by default. See the
452452
[provider guide](/guides/providers/) for login instructions.
453453

454+
For SWE-2, an explicit reasoning effort overrides an effort suffix in the model
455+
id. For example, `swe-2-high` with `medium` selects the native `swe-2-medium` UID;
456+
`xhigh`, `ultra`, and `max` select `swe-2-max`. Values below Medium select Medium
457+
and do not disable SWE-2 reasoning. Without an explicit effort, a suffixed model
458+
id is preserved. This applies to both Devin account providers through their
459+
shared adapter; other model families keep their existing suffix precedence.
460+
454461
## `devin-cli`
455462

456463
**Targets:** Cognition's `exa.api_server_pb.ApiServerService/GetChatMessage`, the same Connect

‎src/adapters/devin.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,39 @@ function hasEffortSuffix(modelId: string): boolean {
8484
return parts.length > 1 && EFFORT_SUFFIXES.has(parts[parts.length - 1]!);
8585
}
8686

87+
/**
88+
* SWE-2 ships exactly three native lanes. Cognition spells them as the model id,
89+
* not as a separate effort field, so an explicit caller effort has to be resolved
90+
* to the UID before the suffix shortcut below accepts whatever the picker sent.
91+
*
92+
* Kept as a named table rather than an inline branch because EFFORT_SUFFIXES does
93+
* not carry `ultra`, `off`, or `minimal`, so the two would drift apart silently.
94+
* Values below Medium select Medium: SWE-2 has no lane under it, and rounding down
95+
* to nothing would quietly disable its reasoning.
96+
*/
97+
const SWE2_EFFORT: Record<string, "medium" | "high" | "max"> = {
98+
none: "medium",
99+
off: "medium",
100+
minimal: "medium",
101+
low: "medium",
102+
medium: "medium",
103+
high: "high",
104+
xhigh: "max",
105+
ultra: "max",
106+
max: "max",
107+
};
108+
109+
/**
110+
* Resolve an explicit effort onto a SWE-2 lane, or undefined when this is not a
111+
* SWE-2 id or the caller named no usable effort. Undefined leaves every existing
112+
* path untouched, which is what keeps other model families on suffix precedence.
113+
*/
114+
function resolveSwe2Variant(modelId: string, reasoningEffort?: string): string | undefined {
115+
if (!/^swe-2(?:-(?:medium|high|max))?$/.test(modelId)) return undefined;
116+
const mapped = reasoningEffort ? SWE2_EFFORT[reasoningEffort.toLowerCase()] : undefined;
117+
return mapped ? `swe-2-${mapped}` : undefined;
118+
}
119+
87120
/**
88121
* Resolve the wire model UID using the live catalog as the source of truth.
89122
* Cognition's catalog lists most models with an effort suffix
@@ -103,6 +136,11 @@ async function resolveWireModelUid(
103136
reasoningEffort?: string,
104137
): Promise<string> {
105138
const modelId = normalizeDevinModelId(rawModelId);
139+
// Explicit effort wins over a suffix the picker already baked into the id, so
140+
// `swe-2-high` asked for at `medium` becomes `swe-2-medium` instead of ignoring
141+
// the caller. Runs before the shortcut below, which would otherwise return early.
142+
const swe2 = resolveSwe2Variant(modelId, reasoningEffort);
143+
if (swe2) return swe2;
106144
if (hasEffortSuffix(modelId)) return modelId;
107145
const catalog = await getCachedCatalog(apiKey, host);
108146
if (catalog) {
@@ -120,6 +158,13 @@ async function resolveWireModelUid(
120158
return `${modelId}-${effort}`;
121159
}
122160

161+
/**
162+
* Test seam. The resolver stays module-private because it reaches the catalog;
163+
* exporting it under its bare name would make an async network-touching helper
164+
* part of the adapter public API. Mirrors sanitizeToolDescriptionForCognitionForTests.
165+
*/
166+
export const resolveWireModelUidForTests = resolveWireModelUid;
167+
123168
export class DevinMissingCredentialError extends Error {
124169
constructor() {
125170
super("Devin live transport requires a Devin API key. Run ocx login devin to sign in with your Cognition/Devin account.");

‎structure/adapters/registry.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,10 @@ Live sideband admission and its bounded upstream handshake follow the [runtime c
9797

9898

9999
Translated Chat request construction uses the [inline-image budget](../transports/streaming-health.md#translated-chat-inline-image-budget); the shared normalizer counts retained bytes even when a wire-specific drop callback keeps the image attached.
100+
101+
## SWE-2 model effort selection
102+
103+
`src/adapters/devin.ts` resolves an explicit SWE-2 reasoning effort to the native
104+
medium/high/max UID before accepting a suffix already present in the model id.
105+
Both Devin provider rows share this resolver. Omitted effort preserves an explicit
106+
variant; unrelated model families retain their existing suffix precedence.

‎tests/providers/devin-adapter.test.ts‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, test } from "bun:test";
2-
import { createDevinAdapter, mapOcxMessagesToDevin, mapOcxToolsToDevin } from "../../src/adapters/devin";
2+
import { createDevinAdapter, mapOcxMessagesToDevin, mapOcxToolsToDevin, resolveWireModelUidForTests } from "../../src/adapters/devin";
33
import { sanitizeToolDescriptionForCognitionForTests } from "../../src/adapters/devin/cloud-direct/chat";
44
import { DEVIN_MODEL_CONTEXT_WINDOWS, DEVIN_STATIC_MODELS, collapseDevinModelUid } from "../../src/adapters/devin/live-models";
55
import { parseCatalogBuffer } from "../../src/adapters/devin/cloud-direct/catalog";
@@ -201,3 +201,38 @@ describe("devin adapter", () => {
201201
}
202202
});
203203
});
204+
205+
describe("SWE-2 wire effort selection", () => {
206+
// Cognition spells SWE-2 effort as the model id, so an explicit effort has to
207+
// beat a suffix the picker already chose. Before this, swe-2-high asked for at
208+
// medium stayed high and the caller was silently ignored.
209+
test.each(["medium", "high", "max"])("an explicit %s effort overrides every SWE-2 variant", async (effort) => {
210+
for (const model of ["swe-2", "swe-2-medium", "swe-2-high", "swe-2-max", "swe-2.high"]) {
211+
expect(await resolveWireModelUidForTests(model, "unused", "unused", effort)).toBe(`swe-2-${effort}`);
212+
}
213+
});
214+
215+
test.each([
216+
["none", "medium"], ["off", "medium"], ["minimal", "medium"],
217+
["low", "medium"], ["xhigh", "max"], ["ultra", "max"],
218+
])("maps %s to the supported SWE-2 %s lane", async (effort, expected) => {
219+
expect(await resolveWireModelUidForTests("swe-2-high", "unused", "unused", effort)).toBe(`swe-2-${expected}`);
220+
});
221+
222+
// Case is normalised, which the source contribution did not do: a caller that
223+
// sends HIGH means the same lane as high.
224+
test("effort matching is case-insensitive", async () => {
225+
expect(await resolveWireModelUidForTests("swe-2-medium", "unused", "unused", "HIGH")).toBe("swe-2-high");
226+
});
227+
228+
test("omitted or unknown effort preserves an explicit variant", async () => {
229+
expect(await resolveWireModelUidForTests("swe-2-high", "unused", "unused")).toBe("swe-2-high");
230+
expect(await resolveWireModelUidForTests("swe-2-max", "unused", "unused", "future-effort")).toBe("swe-2-max");
231+
});
232+
233+
test("other model families keep their existing suffix precedence", async () => {
234+
for (const model of ["claude-opus-5-medium", "gpt-5-6-sol-high", "swe-1-7-high", "swe-20-high"]) {
235+
expect(await resolveWireModelUidForTests(model, "unused", "unused", "max")).toBe(model);
236+
}
237+
});
238+
});

0 commit comments

Comments
 (0)