A new switch in magpie's plugin options, standard_only ("Standard usage
only"), off by default, read at each usage reading. When on,
limitWindows reports the Standard 5 hours / 7 days / 30 days windows
with no notModels and never aside (extra usage or not), so they count
every model, Droid Core's open models included. Droid Core's windows
become aside (shown only) and Extra usage stays aside. Off, the windows
are exactly as before.
magpie only leaves an account out before sending when it is held at a
usage cap (gateway perKeyBarred/capHeld; order routing tries a used-up
account and benches it only after Factory refuses). The README says to
pair the option with an account cap (magpie provider account-cap
factory <account> 99): then a held account is out before affinity, the
next account takes the same model, and with every account held magpie
answers 429 without sending.
Run at this commit, rebased on origin/main 74be632 (TMPDIR and HOME
under a scratch dir; the factory run was at d1b6500):
- bun test packages/factory: 174 pass, 0 fail
- bun test (whole repo): 2383 pass, 0 fail, exit 0
- bun scripts/check.mjs: exit 0
Broken by hand, usage.test.mjs's two new tests:
- index.mjs back to origin/main: both red
- usage not passing the option to limitWindows: the switch test red
- Droid Core's windows not aside under the option: both red
Not tried: a real Factory account, a real magpie host reading the
switch, or routing with a cap set (read from magpie's source only).
poer2023 (#302): anthropicBody() dropped every top-level system text
block, and a string system, that starts with
"x-anthropic-billing-header: cc_version=". When the header and the
instructions after it arrive joined in one block or one string (Claude
Code's auto-mode classifier policy, for one), the instructions went with
it and Factory got only the Droid identity.
Fix: only the header's first line goes. The rest of the text stays, and
the block keeps its other fields (cache_control and the rest); the rest
then goes through promptText like any other system block, so an identity
line after the header is still made Droid's. A block, or string, holding
only the header (or the header and blank lines) is still dropped.
Siblings: grep -rn "x-anthropic-billing-header" packages/ finds only one
other plugin that strips it, workbuddy (FLAGGED), which already removes
just the line with /x-anthropic-billing-header:[^\n]*\n?/gi and keeps the
rest (unflag.test.mjs covers "header\nhello" -> "hello"). kiro and
antigravity-cloak only carry it in fixtures or escape it. No other
plugin has the bug.
Test: request.test.mjs "a billing header joined with instructions loses
only its own line (#302)" takes the reporter's literal inputs (billing
"cc_version=2.1.300; cc_entrypoint=cli;" + "Preserve this task
instruction. SYSTEM_POLICY_SENTINEL"): joined block with cache_control,
joined string, separate blocks, billing only, billing plus blank lines,
on /v1/messages and /count_tokens, checks the exact system sent, that
messages and max_tokens are unchanged, and that a second pass of the
sent body is byte-for-byte; plus a header followed by Claude Code's
identity line.
Run:
- packages/factory: H=$(mktemp -d); HOME="$H" bun test (bun 1.4.2):
172 pass, 0 fail across 16 files.
- Broken by hand: with index.mjs at origin/main 3d355d3 the new test
fails (70 pass, 1 fail); with the fix, 71 pass.
- The reporter's offline repro-billing.mjs from the issue, run with
node against the fixed index.mjs: all four cases pass (joined block,
joined string, separate blocks, billing only), network false.
Not tried: a real Factory account or Claude Code's auto mode end to end;
the check stops at the body handed to the stubbed fetch.
doubl4door (Discord, factory 0.1.34): Claude Code on Factory's Opus got
403 "This request was blocked by Factory's usage policy check" (code
content_policy_rejected), and the plugin's hint pointed at the org's model
policy and plan. droid 0.245.0 tells this refusal apart by that code, only
when Factory sent no x-factory-upstream-error header, and says the check
covers the whole conversation. contentRefused does the same: explain()
says to start a new session or remove the quoted text, and mendOrg's
whoami-and-resend is skipped, since the same conversation is refused
again under any org. Other 403s are handled as before.
Run (sandbox HOME):
- HOME=$(mktemp -d) bun test packages/factory: 171 pass, 0 fail
- bun scripts/check.mjs factory: ok; git diff --check clean
- Broken by hand: without the mendOrg skip 2 of content-policy's 4 tests
fail; without explain's branch 3 fail.
Not tried against Factory's server (no Factory account here); the body
shapes tested are code at the top level and under error.
Factory's proxy gate refuses a request whose body carries certain client
phrases (pi's opening and compaction sentence anywhere; Claude Code's
identity, env line, billing header, compaction opening and
GLOBAL_INSTRUCTIONS inside tool output). The phrases now live in
client-phrases.json; sanitizeBody escapes each phrase's first character as
\uXXXX in every request body (only re-stringified when something changed),
and the Gemini path escapes them too. Version 0.1.35.
Run at the reviewed head f0e78b4 (sandbox HOME):
- HOME=$(mktemp -d) bun test packages/factory: 167 pass, 0 fail
- bun scripts/check.mjs factory: ok; git diff --check clean
- npm pack lists client-phrases.json
- Broken by hand: without sanitizeBody 5 new tests fail; without the
Gemini escapeDeep 1 fails.
Not tried against Factory's server (no Factory account here); the author's
real-account A/B is in the PR.
zygs1083-dotcom (#243): after compaction, a long Claude Code session went
403 Forbidden on all three Factory accounts. Claude Code renders its
instructions attachment two ways (n_t in 2.1.292 to 2.1.303):
- first copy: "Codebase and user instructions are shown below. …"
- changed copy (changed: true, reason compaction and others):
"Instruction files were re-read after the conversation was compacted;
these differ from their earlier copies — each replaces its earlier copy,
and the instructions preamble above still applies:" (or "These
instruction files changed — …" without a reason)
Both list "Contents of ~/.claude/CLAUDE.md (user's private global
instructions for all projects):", the phrase Factory refuses (magpie#634).
Only the first opening was matched, so the changed copy went out as it was.
- INSTRUCTIONS_REMINDER matches both openings, requiring the changed
copy's full sentence and the "Contents of " that follows it. The rename
is limited to the reminder itself: text joined after its close (chat
completions' joined user text) stays as written. String user turns on
/llm/a get it too; before, only text blocks did.
- quotedToolText encodes tool output that quotes the phrase (the
reporter's session read Claude Code's renderer source and went 403
from then on), losslessly, as for the other phrases.
- A 403 the plugin rebuilds keeps Factory's request id (x-request-id,
request-id, x-amzn-requestid, cf-ray, or the body's request_id) and the
error's code and type in the message, and request_id on the Anthropic
body. Headers already went back as they came.
The fixtures are the literal texts the 2.1.303 bundle's n_t/Mje/bMr build
and id() wraps; 2.1.301 and 2.1.302 have the same strings, and the
2.1.292 darwin-arm64 npm package has the same sentence pieces.
What was run at this commit:
- bun test packages/factory/: 161 pass, 0 fail.
- bun scripts/check.mjs factory: ok. git diff --check: clean.
- Broken by hand: with the old startsWith-only opening, the 4 changed-
wrapper tests fail; without the phrase in quotedToolText, the tool-result
test fails too; with upstreamIds returning nothing, the 403 test fails.
- Not tried: a real Factory request with the changed reminder (no live
account was used), so that Factory accepts the renamed copy is inferred
from the first copy's fix in 0.1.12, not seen.
Factory refuses one sentence in Claude Code's built-in update-config skill description. The plugin reworded it only when the entry was a whole line in the skill-list reminders, and only without a slash. claude-code-guide's own system prompt renders the entry as `- /update-config: …` under "# User's Current Configuration", so its first request was 403.
This change matches the entry by name, with or without the slash. It rewords only "not Claude" to "not the assistant" inside that entry. The rewording now also runs on system prompt blocks (promptText) and at the existing call sites (bareSkills, announcedSkills, announcedContext, generatedContext, userBlockText). factory 0.1.32 -> 0.1.33.
What was run at af6422e (reviewer):
- bun test packages/factory: 153 pass, 0 fail. bun scripts/check.mjs factory: ok. git diff --check: clean.
- Broken by hand: with promptText's configSkillText call removed, 2 of the new tests fail.
- magpie plugin host (magpie main cb05dc2d1), with a copy whose API/WorkOS hosts point at a local fake:
- API-key sign-in worked.
- /v1/messages with a claude-code-guide-shaped system prompt went out with block 0 as the Droid identity and the update-config entry reworded. A user's "/custom: Keep not Claude" entry was left unchanged, and the stream came back 200.
- No new hosts, telemetry or dependencies.
Every model in MODELS carries the tokenMultiplier droid 0.241.1's registry
has for it (testdata/droid-0.241.1-costs.txt, byte for byte). A promotion
running takes its discount off it, with the multiplier before it as rateWas;
one that has ended or not begun is no discount. The rate reaches magpie
through a provider hook (host.js reads rate/rateWas from its models; a
config hook's models carry no rate there). Fast Mode entries stay last.
Reviewed at 498b8723e5350657aa26f8f0e2bb1d859f59803b:
- each multiplier and promotion checked against the testdata excerpt;
gpt-5.6-sol's expired M promotion is skipped and Pt (20%) applies, as
droid's first-running-promotion rule gives
- host.js info(): the provider hook's list replaces the config list, and
the request path strips temperature for OpenAI models in droidBody, so
capabilities.temperature=true in providerModel changes nothing sent
- factory unchanged on main between the PR's base 7687314 and fe5631c
Run (HOME=$(mktemp -d), PR head merged with main fe5631c):
- bun test: 1620 pass, 2 fail; the two are cursor latency.test reds under
the full run at load ~260, already filed as #159 and #162; packages/cursor
alone: 267 pass, 0 fail
- bun test packages/factory: 149 pass, 0 fail
- packages/factory/rate.test.mjs against main's index.mjs: 5 fail
- bun scripts/check.mjs: passes
Not tried with a real Factory account here (the author did, 46 models).
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.
Ziqi-Cui's Codex session on Opus 5.5 gathered nine screenshots, ~4.5 MB
of data URLs, and Factory answered every request after with 413 "Request
Entity Too Large". The plugin passed the 413 on as it came, which reads
as the context window; it is Factory's limit on a body's bytes.
On a 413 from Factory the plugin now sends the request once more with
every image and file but the newest replaced, in place, by a line saying
it was left out (droid 0.239.0 removes older images/PDFs from large
requests the same way). Anthropic image/document blocks, Responses
input_image/input_file, chat image_url/file and Gemini inlineData/fileData
are found wherever they are, tool results included, so every tool call
keeps its result; a Gemini function response's parts, which take inline
data alone, drop the image instead. One retry, never more; none when
there is nothing older to leave out.
If the 413 stands, or nothing could be left out, the error (Anthropic's
request_too_large, else invalid_request_error) gives Factory's words,
says the limit is on the body's bytes and what was left out, and carries
magpie's gateway 413 hint word for word (compact, or start a new
session), so the gateway, finding it, doesn't add it twice and OpenCode
users get it too. The words avoid what the gateway reads as a context
overflow, so it stays a 413.
The caller's own session and files are untouched: only the body sent to
Factory changes, and only on the retry.
Run: bun test in packages/factory (134 pass), bun scripts/check.mjs.
Broken by hand: without the 413 branch, three of size.test.mjs's four
tests fail. Not tried: a real Factory account (none here) or Factory's
real limit, which neither droid's binary nor its changelog states; the
fake upstream refuses over a chosen size.
The plugin offered no Gemini model, so Gemini 4 Argon, new in droid
0.241.1's picker, and the Gemini 3.x models magpie's built-in has were
missing for everyone moved onto the plugin.
- Gemini 4 Argon, Gemini 3.1 Pro, Gemini 3.8/3.7/3.6/3.5 Flash and
Gemini 3 Flash are offered on @ai-sdk/google at /api/llm/g/v1, with
droid 0.241.1's names, total context 1M, output 65536, efforts and
images. Each effort is a thinkingConfig thinkingLevel, as the zed
plugin sends Gemini's.
- send() takes the Google package's models/<id>:streamGenerateContent
to Factory's /api/llm/g/v1/generate, as the built-in does (pathOf
Gemini, FactoryGemini): the model in the body, no stream field, the
system instruction without a role and opened with droid's line like
factoryDroidGoogle. x-api-provider is google; the Google package's
x-goog-api-key is dropped. A rewritten body no longer keeps the
caller's content-length.
- Gemini counts in standard's windows, not Droid Core's, as the
built-in's factoryCore has it.
- Gemini 4 Argon is behind a Factory feature flag (featureFlag
Gemini4Argon, unreleased) in droid 0.241.1; an account it isn't on for
may be refused it.
testdata/droid-0.241.1-gemini.txt is droid 0.241.1's picker and Gemini
entries, byte for byte from @factory/cli-darwin-arm64@0.241.1 bin/droid
(each line checked present in the binary). muse-spark-1.2, also new in
that picker, is not added here.
Run: bun test in packages/factory (130 pass), bun scripts/check.mjs.
Broken by hand: without the route rewrite the three gemini.test.mjs
tests fail; without google in CORE's exclusion usage.test.mjs fails.
Not tried: a real Factory account (none signed in here), so neither
Factory's answer to these bodies nor Gemini 4 Argon's flag was seen.
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.
Claude Code also sends the skill list as a standalone system message with
only its entries: no header, no <system-reminder> wrapper, no
<total_tokens> tail, as text blocks and (later in the same session) as a
plain string. The adapter only knew the headed and token-terminated forms,
so the update-config line went through unchanged and Factory answered
403; the reporter got 200 with only "not Claude" -> "not the assistant".
bareSkills applies that same known-line change to a system message that
opens with a "- " entry, both content shapes. User messages, quoted lists
and other skills' lines are left alone.
Run: HOME=<tmp> bun test in packages/factory, 118 pass (2 new, the
reporter's body byte for byte as fixture). With bareSkills made a no-op
by hand the new test goes 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