Files
plugins/packages/factory/package.json
T
yetone 63c2ff93f4 factory: each conversation is a Factory session of its own (0.1.48)
marovole on X: on Factory, Gemini 4 Argon, Hydrogen and Carbon answer
400 "Factory: Invalid model ID in request body" now and then. Success
and failure take turns within one conversation (Droid, v0.1.4404).

The plugin sent one x-session-id, a random UUID made when the plugin
loaded, on every request of its process. So every conversation, every
model and every subagent shared one Factory session. droid makes its
x-session-id per conversation (createProxyHeaders' sessionId in droid
1.14), and a subagent's Task gets a session of its own. Gemini is the
one route where droid locks the provider itself (getNextProvider with
lockedProvider "google"). A session that a Claude or GPT request opened
and that a Gemini request then joins is a state droid never sends.

x-session-id is now a v4 UUID hashed from the conversation magpie
names. A chat.headers hook is told the conversation (its session, else
the hash of its first message). If no hook runs (OpenCode 2), the
x-magpie-session or x-opencode-session header names it. Each subagent
(x-magpie-subagent) gets its own id. A request that names no
conversation keeps the process's id, as before. The header that carries
the conversation, x-magpie-factory-conversation, is taken off before the
request leaves.

Not proven: there is no Factory account here, so the refusal was not
reproduced against Factory itself. session.test.mjs reproduces it with a
fake Factory that holds a session to the provider it was opened with.
That is the hypothesis, not Factory's code. The feature flags droid's
registry puts on exactly these three models (Gemini4Argon/Hydrogen/
Carbon) are the other candidate. Nothing on magpie's side can change
those.

Run (mica, HOME=$(mktemp -d)):
- bun test packages/factory/session.test.mjs gemini.test.mjs: green.
- With session.test.mjs on the old index.mjs: all red. The fake answers
  the Gemini conversation's requests 400 and the ids are shared.
- The root bun test and scripts/check.mjs: 9055 pass, 20 skip, 0 fail (9075 tests, 636 files); check.mjs ok.

Not changed: commandcode keeps one x-session-id for each process ("as
one CLI session has"); filed as plugins#1313. minimax already names
its session per conversation.
2026-11-18 16:21:03 +08:00

13 lines
599 B
JSON

{
"name": "@magpie-community/opencode-factory-auth",
"version": "0.1.48",
"description": "Sign in to a Factory (Droid) subscription from OpenCode or magpie",
"type": "module",
"main": "./opencode.mjs",
"exports": { ".": "./opencode2.mjs" },
"files": ["index.mjs", "opencode.mjs", "opencode2.mjs", "anthropic-tools.mjs", "client-phrases.json", "README.md"],
"keywords": ["opencode", "opencode-plugin", "magpie", "factory", "droid"],
"license": "MIT",
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/factory" }
}