OpenAI's reasoning models turn temperature and top_p away with a 400, and
droid sends neither. droidBody now takes both out of a Responses request
for a model whose upstream is openai, also when the body already opens
with droid's line. configModels says temperature: false for those models,
so OpenCode doesn't send it either. Grok and the chat-completions models
keep theirs.
Run: bun test in packages/factory, 144 pass. The new test fails on 0.1.30's
index.mjs (temperature still in the body). Not tried against Factory's API
with a real account.
sky杨, on magpie 0.1.1254 with this plugin at 0.1.29, got 403 "Factory:
Forbidden" from Claude Code on every model, GPT, Claude and Gemini alike.
Factory's body was a bare "Forbidden", not a phrase-specific refusal.
Header diff against droid 0.242.0 (npm droid and @factory/cli-darwin-arm64
0.242.0, unpacked with --ignore-scripts into an empty directory and read
with strings, never run). Its model requests carry: Authorization,
X-Factory-Client: cli, X-Client-Version, X-Factory-Org-Id, User-Agent
factory-cli/<ver>, x-session-id, x-assistant-message-id, x-api-provider,
x-provider-routing-source (registry_default without a routing claim),
OpenAI-Platform: org-bHuLtG1fGmYk5YaOihAAXFBw for openai/azure_openai,
and X-Api-Key "placeholder" from its Anthropic client. The plugin sends
each of these with the same value, apart from the release: 0.233.0, nine
releases behind. The WorkOS client id is unchanged. droid's binary still
reads a server-side min_cli_version flag and runs a forced auto-update.
0.1.16 was the same case (JL: every model 403 "Forbidden" from pi and
Claude Code while droid worked; the plugin said 0.231.0, two behind), and
JL's later reports (0.1.25) were about models, not refusals. Whether
Factory refuses an old release with a 403 is still not confirmed: there is
no Factory account to try with. This is the one header difference found.
Run: bun test in packages/factory, 143 pass. With VERSION put back to
0.233.0, droid.test.mjs goes red (Expected "0.242.0", Received
"0.233.0"). bun scripts/check.mjs factory: ok.
Not tried against Factory itself.
Full suite: bun test (packages/factory) 143 pass
Echoo, with Factory moved onto this plugin, got "API Error: 403 Factory:
Forbidden" from Claude Code on GLM-5.3-Flash, while Codex worked on the
same account and model. GLM is a chat model Factory serves on /api/llm/o,
so magpie translates Claude Code's Messages request into chat completions
(or Responses) before the plugin gets it. Only anthropicBody, the
/api/llm/a route, adapted Claude Code's fixed phrases Factory refuses (its
identity line, "You have been invoked in the following environment", "You
are powered by the model", update-config's "not Claude, so memory", tool
output quoting them). droidBody, for /api/llm/o, only added droid's line,
so all of them went to Factory as they were. The headers, the model and
the account are the same for both agents; Codex's prompt has none of the
phrases.
anthropicBody's per-text adapters are now functions of their own
(claudeIdentity, promptText, systemMessageText, userBlockText), and
droidBody applies them to chat completions and Responses:
- chat's first system message and Responses' instructions as a system
prompt; other system and developer messages as system messages;
- user text as a user block; a chat user string, where magpie joins a
turn's blocks with nothing between them, also reminder by reminder;
- chat's tool messages and Responses' function_call_output as tool output.
The Messages route is unchanged: the refactor kept every earlier test
green before the new code went in.
testdata/claude-code-2.1.300-glm-{chat,responses}.json are magpie's
translations of a real Claude Code 2.1.300 request, captured in a sandbox
HOME (paths changed to /Users/me, tools left out).
Run: bun test in packages/factory, 143 pass. With index.mjs at 0.1.28 the
new claude-chat.test.mjs fails 4 of 5 (the Codex one passes on both).
bun scripts/check.mjs factory: ok. Routed the captured request through the
plugin: each refused phrase is 0 in the chat and Responses bodies now, as
on /api/llm/a (1 each with 0.1.28).
Not tried against Factory itself: there is no Factory account to try with.
magpie shows a provider with no models picked only the first 24 of its
list. 0.1.27 placed each Fast Mode model beside its base model, which
pushed GPT-5.3-Codex, Grok 4.7, Grok 4.6, GLM-5.3 and GLM-5.3-Flash past
24 ("not exposed"). The six Fast Mode models now come after every other
model, so the first 24 are 0.1.26's again. Asking a base model for fast
still reaches its Fast Mode model (fastBody), and a Fast Mode model can
be picked by name.
Run: bun test packages/factory (138 pass), bun scripts/check.mjs (all
plugins pass). The new fast.test.mjs case fails on 0.1.27's order (put
back by hand: 3 pass, 1 fail) and passes with this one.
Not tried: a real Factory account; magpie's exposure was not run against
the published package, only the list order checked.
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.
JL (Windows, droid 0.240.0, Factory desktop 0.197.1, magpie 0.1.1226,
plugin 0.1.24): droid and Factory desktop offer claude-haiku-5-5, droid
through magpie didn't, as the plugin's model table didn't have it.
How droid gets its models: its npm package (@factory/cli 0.240.0, the
platform binary @factory/cli-darwin-arm64) bundles the model registry in
bin/droid; the picker lists that registry (order `y`), gated by
availableInCLI, unreleased, feature flags and legacy grouping. Diffing the
registry of 0.233.0 (the release the plugin's table was last matched to)
against 0.240.0 gives three new models: claude-haiku-5-5, mistral-large-4
and gpt-6-astra-ultrafast.
- Haiku 5.5: Anthropic Messages, x-api-provider anthropic, context
872000 / output 128000 (contextLimits ce, as Sonnet 5.5 and Opus 5.5),
efforts low..max (droid's "off" is the request without a level).
- Mistral Large 4: generic chat completions, x-api-provider mistral, Droid
Core (billingPool core), 524288 / 64000, images, effort high.
- GPT-6 Astra Ultra Fast stays out: droid offers it only once the user has
accepted Factory's high-cost terms (explicitOptInRequirement high_cost).
models.test.mjs is new; its fixture (testdata/droid-0.240.0-models.txt) is
the registry's own bytes: the picker order, the context helper and the three
entries. It checks the two models as droid has them and that every model in
droid's picker is offered or on a named list left out (router, Gemini,
unreleased, opt-in, the older generations the plugin never offered). With
the Haiku 5.5 line removed both tests fail. usage.test.mjs's Core list
gains Mistral Large 4.
Run: bun test in packages/factory (126 pass), bun scripts/check.mjs factory;
a fake Factory saw /api/llm/a/v1/messages with x-api-provider anthropic for
claude-haiku-5-5 and /api/llm/o/v1/chat/completions with mistral for
mistral-large-4. Not tried against Factory itself (no Factory account here);
droid itself was not run.
* factory 0.1.23: a resumed turn's restored skills reach Factory wherever they sit
#68 took 0.1.22, so this moves to 0.1.23.
Claude Code 2.1.292 session 1a2063e5 is the turn Factory answered 403.
Its transcript renders the post-compaction attachments, in order, as system
reminders: a token marker, a restored Read and its result, an omitted-file
note, the invoked-skills reminder, the agent-type list, MCP server
instructions, the environment paragraph and the model line. No token marker
follows the skills reminder. The snapshot's contextRendering is "announced",
so the same paragraphs also travel unwrapped in one system turn. The request
bytes were not in the routing log; the fixture is those rendered paragraphs,
unwrapped, in that order.
announcedContext used to reassemble the reminder only when a token marker
came right after it, and then treated everything up to that marker as skill
text. A reminder at the end of the turn, or followed by a Read, the
environment or a hook, kept the refused opening. A reminder with other
attachments and a later token swallowed those attachments into the skill
encoding.
The refused part is the fixed opening plus the complete IMPORTANT paragraph.
That complete reminder is rephrased wherever it sits. Skill text now ends at
the next paragraph the adapter already knows (token marker, hook, restored
Read, omitted-file note, Read result, environment, model line, skill-list
header, changed-file note, agent-type list, MCP instructions) or at the end
of the turn. Those following paragraphs stay themselves and are adapted on
their own. A second pass is byte-for-byte. Quoted fragments, an incomplete
IMPORTANT paragraph, a hook that owns the reminder and assistant content stay
untouched.
0.1.22 was not tried against Factory: the installed copy stayed 0.1.21, and
this change was not sent to Factory either.
Run: HOME set to an empty temp dir, bun test packages/factory: 120 pass,
0 fail. node --check packages/factory/index.mjs, bun scripts/check.mjs
factory, and git diff --check are clean. The new test covers the captured
order plus a reminder at the end of the turn, a reminder followed by Read,
environment and a hook, and a quoted skill body. Fetch is stubbed.
* factory 0.1.23: restored skills open a resumed turn without token metadata
A resumed turn can start with the complete invoked-skills reminder when no
files were restored and totalTokensReminder is off. restoredContext now
recognizes its exact opening and IMPORTANT paragraph through the existing
invokedSkillsMatch and attachment boundaries. A restored-file opening can
also use the complete skills reminder as evidence when it ends the turn.
Adapted openings, incomplete reminders, quotations and hook-owned output
retain their existing behavior.
Cover no-token system turns and folded user text on inference and token
counting, including standalone reminders, trailing tokens, omitted-file and
Read prefixes, exact skill decoding, cache metadata and byte-for-byte second
passes. Each of the six boundaries missing independent regression coverage
now follows a quoted skill directly. README documents the no-token forms.
Run with HOME set to an empty temporary directory: bun test packages/factory,
121 pass, 0 fail. node --check packages/factory/index.mjs,
bun scripts/check.mjs factory and git diff --check pass.
Removing each of the omitted-note, Read-result, model, skill-list, MCP and
changed-file boundaries makes the new independent regression test fail.
The whole-project test suite is left to CI. Fetch is stubbed; no request was
sent to a real Factory account.
* factory 0.1.24: main already published 0.1.23 (#71), so this change takes the next version
#71 shipped factory 0.1.23 while this PR waited, so npm has 0.1.23. This
only moves the version, so the squash publishes as 0.1.24.
Run: merged onto main a885a16, HOME=<scratch> bun test packages/factory:
124 pass, 0 fail; bun scripts/check.mjs: all pass.
---------
Co-authored-by: chenguoqing <chenguoqing@kemai.cn>
Co-authored-by: yetone <yetoneful@gmail.com>
Claude Code with the context-management beta sends context_management
(here clear_thinking_20251015, keep all). Factory's streaming route
answers it with 400 "context_management: Extra inputs are not permitted";
the same body with stream false, or without the field, gets 200 (the
reporter's three cases). A streamed /messages request now goes without
the field; an unstreamed one keeps it. The server then clears nothing,
and Claude Code's own compaction still runs.
The version bump also releases the previous commit's #72 fix.
Run: HOME=<tmp> bun test in packages/factory, 119 pass (1 new from the
reporter's body; the existing all-fields test now expects the field gone
on its streamed request). With the deletion disabled by hand both go red.
Not sent to Factory: no Factory account here.
After /compact, Claude Code 2.1.280 sends the files it restores and the
session's runtime context as one system text block with no reminder
wrappers and no opening token marker: restored-file notes ("Note: <path> was
read before the last conversation was summarized…"), "Called the Read tool
with the following input: {…}" and its result, "# Environment\nYou have been
invoked in the following environment:", the model line, token and date.
The reporter's bisect shows Factory 403s on each of those fixed fragments,
and 0.1.21 matched none of them: SYSTEM_ENV_CONTEXT is anchored at the
block's start, COMPACT_READ / COMPACT_FILE need a standalone wrapped
reminder, and the token-prefixed bundle path needs a leading token marker.
restoredContext recognizes the complete turn: its first paragraph is a
generated restored-file note or Read call (as COMPACT_FILE / COMPACT_READ
would match it wrapped), and a later paragraph, before any hook output, is
the generated environment paragraph or a token marker. Then
announcedContext adapts every paragraph from the first on, with the
existing compat spellings (Previously read file…, # Runtime context / The
session environment is:, Current model name / Model ID / Model knowledge
cutoff) and the lossless JSON encoding of Read results; everything else
stays byte-for-byte. It runs for system-role strings and text blocks and
for the same block folded into user text. An adapted turn no longer opens
with the generated note, so a second pass is byte-for-byte.
Quoted, incomplete (no environment or token), hook-owned and assistant
forms are left untouched.
Run: bun test (packages/factory: 116 pass; repo: 1010 pass, 0 fail),
bun scripts/check.mjs (all pass). The two new tests use the issue's literal
fragments (several notes, Read call + result, environment, model line with
claude-opus-5-5[1m], token, date); the adapting one fails on 0.1.21's
index.mjs, and removing the env/token requirement, the hook guard, the
user-text path or starting at paragraph 1 each turns a test red. PR #66
applied on top passes too (119 factory tests). Stubbed fetch only; no
request was sent to Factory (no Factory account here).
After pi compacted a session, every turn on factory/claude-opus-5-5 was 403
"Factory: Forbidden". The reporter's replays through magpie found the
refused part: the sentence pi opens its summary message with,
"The conversation history before this point was compacted into the
following summary:" (pi-coding-agent dist/core/messages.js
COMPACTION_SUMMARY_PREFIX, the same in 1.0.4 and 1.1.0), whole; with it
removed, reworded or halved the request was answered.
A user text that is pi's whole summary message (the sentence, a blank line,
<summary>, and </summary> last) now opens "Earlier conversation context is
summarized below:", the summary itself unchanged. pi's other fixed summary
opening, BRANCH_SUMMARY_PREFIX ("The following is a summary of a branch
that this conversation came back from:"), is reworded the same way; that
Factory refuses it is not confirmed. On Messages (string content and text
blocks), chat completions and Responses user messages alike. The sentence
quoted by a user, without pi's summary around it, or in an assistant turn
goes on as it is.
pi.test.mjs: 3 new tests; the two adaptation tests fail on 0.1.20
(Expected/Received differ on the summary text), the third checks what is
left alone. bun test (114 pass) and bun scripts/check.mjs factory pass.
Not tried against Factory itself (no Factory account here).
MODELS predated GPT-6.1 Sol, so a droid account whose policy allows the
model could not reach it through the plugin. droid's built-in picker, read
by giving "droid exec -m" an id it rejects (it prints the whole list),
names it gpt-6.1-sol — droid spells the minor with a dot, as it does
gpt-5.6-sol, not the gpt-6-1-sol other providers' plugins carry.
It goes on RESPONSES with openai as its vendor, 1050000 context and
128000 output like the rest of the GPT-6 family, images on. Factory's
docs list low, medium, high, xhigh and max for it and no none (gpt-6-sol
and gpt-6-luna have one), so it takes E5 rather than E6. The same docs
were read against the other 30 entries: their efforts are correct.
The picker also offers 19 models this list lacks: Claude Opus 4.5, 4.6
and 4.7, Claude Sonnet 4.5, GPT-5.2, GPT-5.4 Mini, GPT-5.5 Pro, Grok
4.5, DeepSeek V4 Pro, the DeepSeek V4 Flash 0731 snapshot, Inkling, and
nine -fast variants. The superseded ones were left out, and the rest
carry no context or output figure from Factory, from the picker or from
the other plugins here — writing a guessed limit would mislead. The list
stays what droid offers, not what one organization's policy allows: of
the entries already here, 21 are blocked by the account this was checked
on.
Tests: bun test (458 pass) and bun scripts/check.mjs factory pass. The id
was confirmed against droid 0.233.0's picker and passes that account's
policy and effort validation; no inference request was sent.
anthropicBody adapted a role:"system" message only when its content was a
string, so Claude Code 2.1.288's context as [{type:"text",...}] reached
Factory unadapted and was refused (403). Each text block of such a message now
goes through systemContext, its other fields and non-text blocks kept; a user
text block opening with the generated environment context (a system message
folded into the user's turn) is adapted too. The top-level system already
treats a string and an array alike, and the OpenAI route adapts no context.
Tests: the #658 shape (fails on 0.1.13), string/array parity, idempotence;
two tests that asserted array content was left alone now use text outside the
generated shape. Not tried with a live Factory account.
Factory refused three generated phrases the adapter left as they were:
- the instructions reminder's "(user's private global instructions for all
projects)" naming ~/.claude/CLAUDE.md, now "(global instructions)" in that
reminder only;
- Claude 5's runtime context after a SessionStart hook's output, as a system
message or folded into the user's turn: the context after the hook is
adapted as it is alone, the hook's output left as it is;
- the model line inside a system prompt (Claude Desktop's), adapted as in a
reminder.
Three tests cover them and fail without the change; bun test passes.
auth.refresh with refreshLead 3 minutes (in-fetch: 2). It renews under
the lock the request path and mendOrg already share, asks whoami again as
droid does, and gives the tokens and org fields. A renewed map (spent
refresh token → what it gave) lets a request that read the old sign-in
before magpie saved go on with the new one, and keeps rotated tokens when a
save fails. WorkOS refusing the refresh token is signIn "expired" (as the
request path's lapse already was); 429 and 5xx throw and are retried.
The check before each request stays for OpenCode, which doesn't call the
hook (magpie 0.1.684+ does). refresh.test.mjs fails without the change;
HOME=$(mktemp -d) bun test passes (396 across the repo).
.github/workflows/publish.yml runs the tests (in a throwaway HOME) and
scripts/publish.sh on each package.json change pushed to main, or by hand;
npm's OIDC exchange stands in for a token and an OTP. Every package now
names magpie-community/plugins' publish.yml as its trusted publisher on
npmjs.com, and gets the repository field npm checks it against.
After /model, Claude Code 2.1.287 sends a separate string-content system message that opens with the new model paragraph and carries <total_tokens> metadata but no environment block; Factory refused it with 403, so continuing a conversation after a model switch failed. systemContext now also adapts that shape: only when the message starts with the model paragraph and has a complete generated <total_tokens>N tokens left</total_tokens> paragraph, it rewrites each whole model paragraph (named or not, routing-group ids, accumulated switches) to Current model / Model ID / Model knowledge cutoff, leaving every other byte, role and order as sent; inference and count_tokens share it, and a second pass is byte-identical. Tests cover accumulated switches across both endpoints with idempotence, and pass-through for incomplete markers, quoted text, array content and non-system roles. Factory bumped to 0.1.9.
- every {type:"failed"} carries an error reason magpie shows
- commandcode/devin: accounts taken from the CLI are marked metadata.cli and re-read its credentials on each request, usage and models
- factory: a refused refresh answers 401 authentication_error (Anthropic shape on /llm/a/, OpenAI's elsewhere) instead of throwing; the whoami back-off is per account; 403 hints name the account to sign in again
- versions: factory/devin/commandcode/cursor/kiro/mimo/zed/zcode 0.1.2, workbuddy 0.1.3