Skip to content

Commit 09b9e6d

Browse files
wtfsayoclaude
andcommitted
fix(devin): resolve models through catalog family metadata
Parse ClientModelConfig #23 ModelInfo, #30 ModelFamilyMetadata and #31 default flag. A family id with no effort now selects the family's default member (swe-1-7 -> swe-1-7-medium, not the Max row), an effort moves only the effort axis to the nearest rung, Fast Mode and 1M Context follow only explicit requests, and resolution never leaves the family. The suffix fallback's variant scan matches the collapsed base instead of a string prefix, so claude-opus-5 no longer lands on claude-opus-5-5-*. The picker collapses by family, reads ladders from the effort axis, and advertises the family default as defaultReasoningEffort; swe-1-6-fast stays its own row. swe-1-6 is marked text-only (live: it drops images silently) so the vision fallback applies. Uncapped turns send the selected row's catalog maxOutputTokens instead of 8192. CompletionConfiguration #3 is max_newlines, now a fixed value; the input-ceiling plumbing that fed it a context window is removed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 24b2f39 commit 09b9e6d

16 files changed

Lines changed: 754 additions & 179 deletions

File tree

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,10 @@ configuration that names the old id is rewritten at startup.
571571
session token doubled and dash-joined in an `Authorization: Basic` header while the protobuf body
572572
keeps one copy, the request envelope goes up uncompressed, and `Metadata` #31 carries a
573573
732-character device fingerprint whose length — not value — the service checks. Inside
574-
`CompletionConfiguration`, #2 is the output cap and #3 is the context window; swapping those two
575-
makes every turn fail with an opaque `invalid_argument`. A temperature of exactly 0 is refused, so
574+
`CompletionConfiguration`, #2 is the output cap and #3 is `max_newlines`, sent at a fixed large
575+
value; swapping those two makes every turn fail with an opaque `invalid_argument`. With no caller
576+
or configured cap, the output cap is the selected model's own ceiling from the catalog, and 8192
577+
only when the catalog is unavailable. A temperature of exactly 0 is refused, so
576578
it is clamped to the smallest accepted value.
577579
- A pre-output 429 with a stated recovery delay is surfaced immediately by default, releasing the
578580
admitted turn's shared capacity. Set `OPENCODEX_DEVIN_STATED_RESET_WAIT_MS` to a positive cumulative
@@ -591,13 +593,17 @@ configuration that names the old id is rewritten at startup.
591593
- Experimental unofficial bridge; not shown in the dashboard preset by default. See the
592594
[provider guide](/guides/providers/) for login instructions.
593595

594-
For SWE-2, an explicit reasoning effort overrides an effort suffix in the model
595-
id. For example, `swe-2-high` with `medium` selects the native `swe-2-medium` UID;
596-
`xhigh`, `ultra`, and `max` select `swe-2-max`. Values below Medium select Medium
597-
and do not disable SWE-2 reasoning. Without an explicit effort, a suffixed model
598-
id is preserved. This applies through the shared adapter to every Devin account,
599-
whichever login path minted the credential; other model families keep their
600-
existing suffix precedence.
596+
The model id you pick is a model family, and the reasoning effort picks the
597+
variant. With no effort, the family's own default variant is used: `swe-1-7`
598+
selects `swe-1-7-medium` and `swe-2` selects `swe-2-high`. An effort changes only
599+
the effort and lands on the nearest variant the family has, rounding up on a tie,
600+
so `swe-2` at `low` selects `swe-2-medium` and `kimi-k3` at `medium` selects
601+
`kimi-k3-high`. `fast` selects the Fast variant and `1m`, `max-1m` or `none-1m`
602+
the 1M-context variant where the family has one; otherwise they change nothing.
603+
A suffixed id such as `claude-opus-5-high-fast` keeps its variant without an
604+
effort, and with one keeps its Fast and context settings. Resolution never moves
605+
to another family. When the account catalog is unavailable, the effort is
606+
appended to the id instead.
601607

602608
## `azure-openai` (alias: `azure`)
603609

‎scripts/test-layout/layout.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@
911911
"devin-adapter.test.ts": "providers",
912912
"devin-cli-authmode-migration.test.ts": "providers",
913913
"devin-effort-ladder.test.ts": "providers",
914+
"devin-family-resolution.test.ts": "providers",
914915
"devin-hardening.test.ts": "providers",
915916
"devin-image-passthrough.test.ts": "providers",
916917
"devin-live-models.test.ts": "providers",

‎src/adapters/devin.ts‎

Lines changed: 118 additions & 63 deletions
Large diffs are not rendered by default.

‎src/adapters/devin/cloud-direct/catalog.ts‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,18 @@
3535
* #5 supports_images bool ← tri-state: absent stays unknown
3636
* #18 max_input_tokens varint ← per-account context window
3737
* #22 model_uid string ← what `GetChatMessage` accepts
38+
* #23 model_info ModelInfo { #6 features { #15 supports_thinking },
39+
* #13 max_output_tokens, #23 model_family_uid }
40+
* #30 family_metadata ModelFamilyMetadata { #1 family_label,
41+
* #2 repeated Entry { #1 axis key, #2 { #1 order, #2 name } },
42+
* #3 is_default_model_in_family }
43+
* #31 is_default_model_in_family bool
3844
* }
3945
*
46+
* #23/#30/#31 were read back from a live 267-row catalog (2026-09-27): every
47+
* current row names its family, and each family marks one default member.
48+
* Legacy `MODEL_*` rows carry no #30.
49+
*
4050
* Disabled semantics: TRUE means "this UID exists in the catalog but the
4151
* caller's account/tier cannot run inference against it." BYOK models
4252
* surface as `disabled: false` so users with their own provider keys still
@@ -91,6 +101,73 @@ export interface ModelCatalogEntry {
91101
* (see src/providers/antigravity-models.ts).
92102
*/
93103
supportsImages?: boolean;
104+
/** ModelInfo #13: the model's own output-token ceiling. */
105+
maxOutputTokens?: number;
106+
/** ModelInfo #6.15. */
107+
supportsThinking?: boolean;
108+
/** ModelInfo #23, e.g. `swe-1.7` for both `swe-1-7` and `swe-1-7-medium`. */
109+
familyUid?: string;
110+
/** ModelFamilyMetadata #1, e.g. `SWE-1.7`. */
111+
familyLabel?: string;
112+
/**
113+
* ModelFamilyMetadata #2: this row's position on each of its family's axes,
114+
* keyed by axis name (`Effort`, `Reasoning Effort`, `Fast Mode`, `1M Context`,
115+
* `Thinking`, ...). Toggle axes such as `Fast Mode` carry only an order.
116+
*/
117+
familyAxes?: Record<string, DevinFamilyAxisValue>;
118+
/** #31 (or #30.3): the member the family selects when nothing is asked for. */
119+
isFamilyDefault?: boolean;
120+
}
121+
122+
export interface DevinFamilyAxisValue {
123+
order: number;
124+
name?: string;
125+
}
126+
127+
/**
128+
* Rows whose catalog entry claims image support that the model does not have.
129+
* Live 2026-09-27: `swe-1-6` answered "NOIMAGE" to a solid red PNG while
130+
* `swe-1-6-fast` and `swe-2-medium` named the colour, so the image is dropped
131+
* server-side without an error. Marking it text-only lets the vision fallback
132+
* describe the image instead of the model silently never seeing it.
133+
*/
134+
const IMAGE_BLIND_UIDS = new Set(['swe-1-6']);
135+
136+
function parseFamilyMetadata(buf: Buffer): { label?: string; axes: Record<string, DevinFamilyAxisValue>; isDefault: boolean } {
137+
let label: string | undefined;
138+
let isDefault = false;
139+
const axes: Record<string, DevinFamilyAxisValue> = {};
140+
for (const f of iterFields(buf)) {
141+
if (f.num === 1 && f.wire === 2 && Buffer.isBuffer(f.value)) label = f.value.toString('utf8');
142+
else if (f.num === 3 && f.wire === 0) isDefault = f.value === 1n;
143+
else if (f.num === 2 && f.wire === 2 && Buffer.isBuffer(f.value)) {
144+
let key = '';
145+
const value: DevinFamilyAxisValue = { order: 0 };
146+
for (const e of iterFields(f.value)) {
147+
if (e.num === 1 && e.wire === 2 && Buffer.isBuffer(e.value)) key = e.value.toString('utf8');
148+
else if (e.num === 2 && e.wire === 2 && Buffer.isBuffer(e.value)) {
149+
for (const v of iterFields(e.value)) {
150+
if (v.num === 1 && v.wire === 0) value.order = Number(v.value);
151+
else if (v.num === 2 && v.wire === 2 && Buffer.isBuffer(v.value)) value.name = v.value.toString('utf8');
152+
}
153+
}
154+
}
155+
if (key) axes[key] = value;
156+
}
157+
}
158+
return { ...(label ? { label } : {}), axes, isDefault };
159+
}
160+
161+
function parseModelInfo(buf: Buffer): { maxOutputTokens?: number; familyUid?: string; supportsThinking?: boolean } {
162+
const out: { maxOutputTokens?: number; familyUid?: string; supportsThinking?: boolean } = {};
163+
for (const f of iterFields(buf)) {
164+
if (f.num === 13 && typeof f.value === 'bigint' && f.value > 0n) out.maxOutputTokens = Number(f.value);
165+
else if (f.num === 23 && f.wire === 2 && Buffer.isBuffer(f.value) && f.value.length > 0) out.familyUid = f.value.toString('utf8');
166+
else if (f.num === 6 && f.wire === 2 && Buffer.isBuffer(f.value)) {
167+
for (const g of iterFields(f.value)) if (g.num === 15 && g.wire === 0) out.supportsThinking = g.value === 1n;
168+
}
169+
}
170+
return out;
94171
}
95172

96173
export interface CacheEntry {
@@ -127,6 +204,9 @@ export function parseCatalogBuffer(buf: Buffer, apiKey: string, host: string): C
127204
let disabled = false;
128205
let contextWindow = 0;
129206
let supportsImages: boolean | undefined;
207+
let info: ReturnType<typeof parseModelInfo> = {};
208+
let family: ReturnType<typeof parseFamilyMetadata> | undefined;
209+
let isFamilyDefault = false;
130210
for (const sf of iterFields(f.value as Buffer)) {
131211
if (sf.num === 1 && sf.wire === 2 && Buffer.isBuffer(sf.value)) {
132212
label = (sf.value as Buffer).toString('utf8');
@@ -145,15 +225,26 @@ export function parseCatalogBuffer(buf: Buffer, apiKey: string, host: string): C
145225
contextWindow = Number(sf.value);
146226
} else if (sf.num === 22 && sf.wire === 2 && Buffer.isBuffer(sf.value)) {
147227
modelUid = (sf.value as Buffer).toString('utf8');
228+
} else if (sf.num === 23 && sf.wire === 2 && Buffer.isBuffer(sf.value)) {
229+
info = parseModelInfo(sf.value);
230+
} else if (sf.num === 30 && sf.wire === 2 && Buffer.isBuffer(sf.value)) {
231+
family = parseFamilyMetadata(sf.value);
232+
} else if (sf.num === 31 && sf.wire === 0) {
233+
isFamilyDefault = sf.value === 1n;
148234
}
149235
}
236+
if (IMAGE_BLIND_UIDS.has(modelUid)) supportsImages = false;
150237
if (modelUid.length > 0) {
151238
byUid.set(modelUid, {
152239
modelUid,
153240
label: label || modelUid,
154241
disabled,
155242
...(contextWindow > 0 ? { contextWindow } : {}),
156243
...(supportsImages !== undefined ? { supportsImages } : {}),
244+
...info,
245+
...(family?.label ? { familyLabel: family.label } : {}),
246+
...(family ? { familyAxes: family.axes } : {}),
247+
...(isFamilyDefault || family?.isDefault ? { isFamilyDefault: true } : {}),
157248
});
158249
}
159250
}

‎src/adapters/devin/cloud-direct/chat.ts‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,15 @@ function collapseSystemIntoUser(messages: ChatHistoryItem[]): ChatHistoryItem[]
332332
* CompletionConfiguration — mirrors the LS-shipped defaults, lets the caller
333333
* override the obvious knobs.
334334
*/
335-
/** Output cap when the caller named none. */
335+
/** Output cap when neither the caller nor the catalog named one. */
336336
const DEFAULT_MAX_OUTPUT_TOKENS = 8192;
337-
/** Context window when the caller named none. */
338-
const DEFAULT_CONTEXT_WINDOW = 128_000;
337+
/**
338+
* CompletionConfiguration #3 is `max_newlines`, not a token count and not an
339+
* input ceiling: live, a value of 5 did not truncate a 25-line answer. It is
340+
* still sent, at the value every turn has carried, so the request shape the
341+
* service accepts does not change.
342+
*/
343+
const MAX_NEWLINES = 128_000;
339344

340345
/**
341346
* Cognition rejects a temperature of exactly 0 with the same opaque internal
@@ -353,7 +358,6 @@ function safeTemperature(value: number | undefined): number {
353358

354359
function encodeCompletionConfiguration(opts: {
355360
maxOutputTokens?: number;
356-
maxInputTokens?: number;
357361
temperature?: number;
358362
topK?: number;
359363
topP?: number;
@@ -365,15 +369,15 @@ function encodeCompletionConfiguration(opts: {
365369
};
366370
// Tag map, verified by building the same turn with a working client and
367371
// diffing the encoded messages field by field: #2 is the OUTPUT cap and #3 is
368-
// the context window. This layout had those two swapped, so a caller asking
369-
// for 32 output tokens put 32 into the context-window field and the request
370-
// came back as an opaque "an internal error occurred" — for every turn, on
371-
// every account, which is why free and paid failed identically. #6 and #11
372-
// are not part of the message the service accepts.
372+
// max_newlines. This layout once had those two swapped, so a caller's output
373+
// cap landed in #3 and a large value in #2, and the request came back as an
374+
// opaque "an internal error occurred" — for every turn, on every account,
375+
// which is why free and paid failed identically. #6 and #11 are not part of
376+
// the message the service accepts.
373377
return Buffer.concat([
374378
encodeVarintField(1, 1),
375379
encodeVarintField(2, opts.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS),
376-
encodeVarintField(3, opts.maxInputTokens ?? DEFAULT_CONTEXT_WINDOW),
380+
encodeVarintField(3, MAX_NEWLINES),
377381
enc64(5, safeTemperature(opts.temperature)),
378382
encodeVarintField(7, opts.topK ?? 40),
379383
enc64(8, opts.topP ?? 1.0),
@@ -543,7 +547,6 @@ interface BuildArgs {
543547
requestType?: number;
544548
completionOpts?: {
545549
maxOutputTokens?: number;
546-
maxInputTokens?: number;
547550
temperature?: number;
548551
topK?: number;
549552
topP?: number;

0 commit comments

Comments
 (0)