From c70c9df24e236d863212dd3d0b58c1dc90388152 Mon Sep 17 00:00:00 2001 From: Versun Date: Thu, 8 Oct 2026 17:58:41 +0800 Subject: [PATCH] =?UTF-8?q?devin=200.1.12:=20a=20temperature=20or=20top=5F?= =?UTF-8?q?p=20of=200=20goes=20to=20Devin=20as=201e-6=20=E2=80=94=20Devin?= =?UTF-8?q?=20answered=20every=20request=20carrying=20exactly=200=20with?= =?UTF-8?q?=20400=20"an=20internal=20error=20occurred=20(trace=20ID=20?= =?UTF-8?q?=E2=80=A6)"=20(in=3D0/out=3D0),=20on=20claude-opus-5-5,=20claud?= =?UTF-8?q?e-sonnet-5-5=20and=20swe-2=20alike,=20streamed=20or=20not,=20so?= =?UTF-8?q?=20a=20caller=20that=20asks=20for=20greedy=20output=20(Hermes?= =?UTF-8?q?=20Agent's=20command=20approvals=20send=20temperature=200,=20ma?= =?UTF-8?q?x=5Ftokens=2016)=20failed=20on=20every=20devin/*=20model=20and,?= =?UTF-8?q?=20the=20400=20not=20being=20one=20magpie=20falls=20back=20on,?= =?UTF-8?q?=20never=20reached=20the=20next=20member=20of=20a=20group.=201e?= =?UTF-8?q?-6=20is=20the=20smallest=20step=20above=200=20and=20goes=20thro?= =?UTF-8?q?ugh,=20as=20do=200.1,=201=20and=202;=20any=20other=20value=20is?= =?UTF-8?q?=20sent=20as=20it=20came,=20and=20none=20still=20as=20Devin's?= =?UTF-8?q?=20defaults=20(1,=200.95).=20sampling.test.mjs=20decodes=20fiel?= =?UTF-8?q?d=208=20of=20build()'s=20request:=20its=20first=20test=20fails?= =?UTF-8?q?=20with=20the=20fix=20taken=20out.=20HOME=3D$(mktemp=20-d)=20bu?= =?UTF-8?q?n=20test=20packages/devin=20(45=20pass,=200=20fail)=20and=20bun?= =?UTF-8?q?=20scripts/check.mjs=20pass.=20Tried=20against=20a=20real=20Dev?= =?UTF-8?q?in=20account=20through=20magpie:=20temperature=200=20and=20top?= =?UTF-8?q?=5Fp=200=20=E2=86=92=20400;=201e-6=20=E2=86=92=20200.=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devin/index.mjs | 8 +++++-- packages/devin/package.json | 2 +- packages/devin/sampling.test.mjs | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 packages/devin/sampling.test.mjs diff --git a/packages/devin/index.mjs b/packages/devin/index.mjs index 7455547..7dfff7b 100644 --- a/packages/devin/index.mjs +++ b/packages/devin/index.mjs @@ -1179,8 +1179,12 @@ function build(chat, uid, key) { for (const m of msgs) out.bytes(3, encodeMsg(m)) out.varint(7, 5) const max = chat.max_completion_tokens || chat.max_tokens || 128000 // the server holds it to the model's own - const temp = typeof chat.temperature === "number" ? chat.temperature : 1 - const topP = typeof chat.top_p === "number" ? chat.top_p : 0.95 + // Devin answers "an internal error occurred" to a temperature or top_p of + // exactly 0 (on every model: its Claude ones and swe-2), where 1e-6 goes + // through; a 0 is sent as the smallest step above it, as near greedy + const above0 = (v) => (v === 0 ? 1e-6 : v) + const temp = above0(typeof chat.temperature === "number" ? chat.temperature : 1) + const topP = above0(typeof chat.top_p === "number" ? chat.top_p : 0.95) out.bytes(8, new PB().varint(1, 1).varint(2, max).varint(3, 400).double(5, temp).varint(7, 40).double(8, topP)) // the caller's tools, and any the conversation used that it no longer diff --git a/packages/devin/package.json b/packages/devin/package.json index 13dfbf5..eb43659 100644 --- a/packages/devin/package.json +++ b/packages/devin/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-devin-auth", - "version": "0.1.11", + "version": "0.1.12", "description": "Devin subscriptions (the devin CLI's account) in OpenCode and magpie", "type": "module", "main": "./index.mjs", diff --git a/packages/devin/sampling.test.mjs b/packages/devin/sampling.test.mjs new file mode 100644 index 0000000..ea84c0c --- /dev/null +++ b/packages/devin/sampling.test.mjs @@ -0,0 +1,36 @@ +// Devin answers "an internal error occurred" to a temperature or top_p of +// exactly 0 (Hermes's command approvals send temperature 0): a 0 goes to +// Devin as 1e-6, any other value as it came. +import { expect, test } from "bun:test" +import { _internal } from "./index.mjs" + +// sampling is the temperature and top_p in the request's field 8. +const sampling = (chat) => { + const f8 = _internal.fields(_internal.build(chat, "claude-opus-5-5", "k")).find((f) => f.num === 8) + const out = {} + const b = f8.data + const view = new DataView(b.buffer, b.byteOffset, b.byteLength) + for (let i = 0; i < b.length; ) { + const key = b[i++] + if ((key & 7) === 0) while (b[i++] & 0x80); + else if ((key & 7) === 1) { + out[key >> 3] = view.getFloat64(i, true) + i += 8 + } else throw new Error(`unexpected wire type in field 8: ${key & 7}`) + } + return { temperature: out[5], top_p: out[8] } +} + +const say = { messages: [{ role: "user", content: "hi" }] } + +test("a temperature or top_p of 0 goes to Devin as 1e-6", () => { + expect(sampling({ ...say, temperature: 0 })).toEqual({ temperature: 1e-6, top_p: 0.95 }) + expect(sampling({ ...say, top_p: 0 })).toEqual({ temperature: 1, top_p: 1e-6 }) + expect(sampling({ ...say, temperature: -0, top_p: 0 })).toEqual({ temperature: 1e-6, top_p: 1e-6 }) +}) + +test("any other temperature or top_p goes as it came, and none as Devin's defaults", () => { + expect(sampling(say)).toEqual({ temperature: 1, top_p: 0.95 }) + expect(sampling({ ...say, temperature: 0.2, top_p: 1 })).toEqual({ temperature: 0.2, top_p: 1 }) + expect(sampling({ ...say, temperature: 1e-6 })).toEqual({ temperature: 1e-6, top_p: 0.95 }) +})