devin 0.1.12: a temperature or top_p of 0 goes to Devin as 1e-6 — Devin answered every request carrying exactly 0 with 400 "an internal error occurred (trace ID …)" (in=0/out=0), on claude-opus-5-5, claude-sonnet-5-5 and swe-2 alike, streamed or not, so a caller that asks for greedy output (Hermes Agent's command approvals send temperature 0, max_tokens 16) failed on every devin/* model and, the 400 not being one magpie falls back on, never reached the next member of a group. 1e-6 is the smallest step above 0 and goes through, as do 0.1, 1 and 2; any other value is sent as it came, and none still as Devin's defaults (1, 0.95). sampling.test.mjs decodes field 8 of build()'s request: its first test fails with the fix taken out. HOME=$(mktemp -d) bun test packages/devin (45 pass, 0 fail) and bun scripts/check.mjs pass. Tried against a real Devin account through magpie: temperature 0 and top_p 0 → 400; 1e-6 → 200. (#50)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 })
|
||||
})
|
||||
Reference in New Issue
Block a user