psylch on #119 (plugin 0.1.26): claude-opus-5-5-fast answered "Factory: Not found.", and Opus 5.5 asked with speed "fast" was recorded as tier_asked fast, tier_served standard, with nothing said. The plugin now offers droid 0.240.0's Fast Mode models: Opus 5.5/5/4.8 Fast on Anthropic's API, GPT-5.5/5.4/5.3-Codex Fast on Responses, each at its base model's limits and efforts. They go out as droid 0.240.0 sends them (read from its binary, saved in testdata/droid-0.240.0-fast.txt): the Fast Mode id itself as the model, with speed "fast" and the fast-mode-2026-02-01 beta for anthropicFastMode models, at service_tier "priority" for the GPT ones (their apiRequest Ee). A request asking a base model for fast (speed "fast" on Messages, service_tier "priority" on Responses) is sent to its Fast Mode model, as droid's fast toggle switches to it. A model with no Fast Mode model is sent as asked. Left out: Opus 4.6/4.7 Fast and GPT-5.4 Mini Fast (base not offered), GPT-5.6 Sol Fast (unreleased:!0), GLM-5.2 Fast (feature flag, a Baseten id). Run: the full bun test (1222 pass, 0 fail) with a sandbox HOME; the new fast.test.mjs and the picker test fail on the old index.mjs (4 fail). Not tried: a real Factory account (none signed in here), so whether Factory serves the Fast Mode ids at fast speed to a plan, and what its usage says about speed, is unverified. A non-stream request magpie translates for a plugin account drops speed before the plugin sees it, so there only the -fast ids reach fast.
102 lines
5.5 KiB
JavaScript
102 lines
5.5 KiB
JavaScript
// magpie-community/plugins#119 (psylch, plugin 0.1.26): Factory sells Opus
|
|
// 5.5 Fast and Opus 5 Fast, and droid offers them, but the plugin had no
|
|
// -fast model ("Factory: Not found."), and Opus 5.5 asked with speed "fast"
|
|
// was served at standard speed with nothing said. The cases are droid
|
|
// 0.240.0's own entries and request code, saved byte for byte in testdata.
|
|
import { afterEach, expect, test } from "bun:test"
|
|
import { readFileSync } from "node:fs"
|
|
import { FactoryAuthPlugin } from "./index.mjs"
|
|
|
|
const DROID = readFileSync(new URL("./testdata/droid-0.240.0-fast.txt", import.meta.url), "utf8")
|
|
const real = globalThis.fetch
|
|
afterEach(() => (globalThis.fetch = real))
|
|
|
|
function entry(id) {
|
|
const line = DROID.split("\n").find((l) => l.startsWith(`"${id}":{id:"${id}",`))
|
|
if (!line) throw new Error(`${id} is not in the fixture`)
|
|
return line
|
|
}
|
|
|
|
async function plugin() {
|
|
const seen = []
|
|
globalThis.fetch = async (url, init) => {
|
|
seen.push({ url: String(url), ...init })
|
|
return new Response("{}", { headers: { "content-type": "application/json" } })
|
|
}
|
|
const auth = { type: "oauth", access: "factory-token", expires: Date.now() + 3_600_000, activeOrganizationId: "org_A" }
|
|
const hooks = await FactoryAuthPlugin({ client: { auth: { set: async () => {} } } })
|
|
const cfg = { provider: {} }
|
|
await hooks.config(cfg)
|
|
return { models: cfg.provider.factory.models, l: await hooks.auth.loader(async () => auth), seen }
|
|
}
|
|
|
|
const OFFERED = ["claude-opus-5-5-fast", "claude-opus-5-fast", "claude-opus-4-8-fast", "gpt-5.5-fast", "gpt-5.4-fast", "gpt-5.3-codex-fast"]
|
|
|
|
test("droid's Fast Mode models are offered at their base model's limits and efforts", async () => {
|
|
const { models } = await plugin()
|
|
for (const id of OFFERED) {
|
|
const text = entry(id)
|
|
const base = text.match(/baseVariant:"([^"]+)"/)[1]
|
|
const m = models[id]
|
|
expect(m).toBeDefined()
|
|
expect(m.name).toBe(text.match(/,name:"([^"]+)"/)[1])
|
|
expect(m.limit).toEqual(models[base].limit)
|
|
expect(m.provider).toEqual(models[base].provider)
|
|
const efforts = JSON.parse(text.match(/reasoningEffort:\{supported:(\[[^\]]*\])/)[1]).filter((e) => e !== "off")
|
|
expect(Object.keys(m.variants)).toEqual(efforts)
|
|
}
|
|
// left out, each for its reason (index.mjs, above MODELS)
|
|
for (const id of ["claude-opus-4-6-fast", "claude-opus-4-7-fast", "gpt-5.4-mini-fast", "gpt-5.6-sol-fast", "glm-5.2-fast"]) expect(models[id]).toBeUndefined()
|
|
expect(entry("gpt-5.6-sol-fast")).toContain("unreleased:!0")
|
|
expect(entry("glm-5.2-fast")).toContain("featureFlag:")
|
|
})
|
|
|
|
test("an Opus Fast Mode model goes out as droid sends it: its own id, speed fast and the fast-mode beta", async () => {
|
|
const { l, seen } = await plugin()
|
|
expect(entry("claude-opus-5-5-fast")).toContain("anthropicFastMode:!0")
|
|
expect(DROID).toContain('if(t?.anthropicFastMode){if(_.speed="fast",!f.betaFlags.includes("fast-mode-2026-02-01"))')
|
|
const url = "https://api.factory.ai/api/llm/a/v1/messages"
|
|
await l.fetch(url, { method: "POST", headers: { "anthropic-beta": "client-beta" }, body: JSON.stringify({ model: "claude-opus-5-5-fast", max_tokens: 8, messages: [{ role: "user", content: "hi" }] }) })
|
|
let sent = JSON.parse(seen[0].body)
|
|
expect(sent.model).toBe("claude-opus-5-5-fast")
|
|
expect(sent.speed).toBe("fast")
|
|
expect(seen[0].headers.get("anthropic-beta")).toBe("client-beta,fast-mode-2026-02-01")
|
|
expect(seen[0].headers.get("x-api-provider")).toBe("anthropic")
|
|
|
|
// the issue's second case: Opus 5.5 asked for fast reaches Opus 5.5 Fast
|
|
await l.fetch(url, { method: "POST", headers: { "anthropic-beta": "fast-mode-2026-02-01" }, body: JSON.stringify({ model: "claude-opus-5-5", speed: "fast", max_tokens: 8, messages: [{ role: "user", content: "hi" }] }) })
|
|
sent = JSON.parse(seen[1].body)
|
|
expect(sent.model).toBe("claude-opus-5-5-fast")
|
|
expect(sent.speed).toBe("fast")
|
|
expect(seen[1].headers.get("anthropic-beta")).toBe("fast-mode-2026-02-01")
|
|
|
|
// not asked for fast: Opus 5.5 as it was
|
|
await l.fetch(url, { method: "POST", body: JSON.stringify({ model: "claude-opus-5-5", max_tokens: 8, messages: [{ role: "user", content: "hi" }] }) })
|
|
sent = JSON.parse(seen[2].body)
|
|
expect(sent.model).toBe("claude-opus-5-5")
|
|
expect("speed" in sent).toBe(false)
|
|
expect(seen[2].headers.get("anthropic-beta")).toBeNull()
|
|
})
|
|
|
|
test("a GPT Fast Mode model goes out as droid sends it: its own id at the priority tier", async () => {
|
|
const { l, seen } = await plugin()
|
|
expect(entry("gpt-5.5-fast")).toContain("apiRequest:Ee,")
|
|
expect(DROID).toContain('Ee=C({parallelToolCalls:!0,extendedCache:!0,safetyId:!0,verbosity:"low",serviceTier:"priority"})')
|
|
const url = "https://api.factory.ai/api/llm/o/v1/responses"
|
|
await l.fetch(url, { method: "POST", body: JSON.stringify({ model: "gpt-5.5-fast", input: "hi" }) })
|
|
let sent = JSON.parse(seen[0].body)
|
|
expect(sent.model).toBe("gpt-5.5-fast")
|
|
expect(sent.service_tier).toBe("priority")
|
|
expect(seen[0].headers.get("x-api-provider")).toBe("openai")
|
|
expect(seen[0].headers.get("anthropic-beta")).toBeNull()
|
|
// GPT-5.5 at the priority tier is its Fast Mode model
|
|
await l.fetch(url, { method: "POST", body: JSON.stringify({ model: "gpt-5.5", service_tier: "priority", input: "hi" }) })
|
|
sent = JSON.parse(seen[1].body)
|
|
expect(sent.model).toBe("gpt-5.5-fast")
|
|
// a model with no Fast Mode model is left as it was asked
|
|
await l.fetch(url, { method: "POST", body: JSON.stringify({ model: "gpt-6-sol", service_tier: "priority", input: "hi" }) })
|
|
sent = JSON.parse(seen[2].body)
|
|
expect(sent.model).toBe("gpt-6-sol")
|
|
expect(sent.service_tier).toBe("priority")
|
|
})
|