ac4af582301a4e8a29245dbba767eba31334ddf9
108
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bc8b01d603 |
claude: the short system prompt is set in the Claude Code editor, not Settings › Replies
The scattered settings audit after netube99 on X. Short Claude system
prompt and Claude Code's interactive mode changed only Claude
subscription runs, yet sat in Settings › Models › Replies, while the
Claude Code editor already had its own "Claude Code runs as" switch for
the second, whose card said "Switched here or in Settings › Models ›
Replies".
Both rows now go in a claudeRunList in the Claude editor (PROV_PREFS), so
Settings' search still finds them and Open goes to the editor. In the app
the editor's own "runs as" switch is the one shown, and the duplicate
interactive mode row is hidden by CSS; in magpie web as a gateway, where
that switch is disabled, the row shows (the list gets a gw class from
renderReplies: body.gateway-mode is set only on a change, not at boot).
provPrefsField lets Claude's run list through in gateway mode, without
the warm-ups, which are this computer's. The card and the "off" reason
no longer name Settings (zh, zh-TW, ja, de written with them), and the
bridge's subsystem page names the editor.
Run (mote, mote-run, origin/main
|
||
|
|
5506c84437 |
gateway: a skill's body reaches the run with its Skill call's result
Claude Code answers a Skill call with "Launching skill: <name>" and sends the skill's SKILL.md after the results, as a text block headed "Base directory for this skill: …". Since |
||
|
|
8fa3c60f80 |
claude: an interactive run takes many images between words (#5654)
Chapin2018's message of nineteen images between words (the issue's
script, Claude Code 2.1.319, claude-fable-5-1) ended the interactive
helper "after 13s (exit status 1)" and the client got a 502, while -p
answered. The cause is how the helper saw a paste taken. It looked for
"[Image #N]" and "[Pasted text #N" only in what Claude Code drew after
the paste. Once the prompt runs past a row, Claude Code draws it again
only where it changed and moves the cursor past cells that are already
right. After the 33rd piece the drawing held "\r\x1b[16C\x1b[1B3": one
digit of "[Image #33]". The helper waited out pasteWait (10s) and ended.
Text marks came out in part too ("[Pasted t xt #16"), so several word
pieces each sat out their own 10s before that. There is no limit in
Claude Code's TUI: the same paste is on its screen whole, so no -p
fallback is needed.
Each check now also reads the prompt as the 200x50 screen grid shows
it: the rows between its last two rules, words one space apart (a mark
can wrap onto the next row). The mark that ends it counts (lastMark),
an image's [Image #N] or a whole [Pasted text #N +k lines], numbered
past the piece before, and so do words the prompt ends with. The
stream check stays first.
Run:
- Real, macOS arm64, this Mac, sandbox HOME and CLAUDE_CONFIG_DIR
(token by env, nothing rotated, DISABLE_AUTOUPDATER=1), the issue's
script unchanged, --images 19, Claude Code 2.1.319:
- origin/main
|
||
|
|
0f8c3d8672 |
claude: a deferred built-in the bridge's model calls reaches the client as WebFetch, not mcp__magpie__WebFetch
Claude Code with tool search on leaves WebFetch, WebSearch, CronCreate and
the other deferred built-ins out of tools until a ToolSearch loads them.
The run's model, offered the client's tools as mcp__magpie__<name>, called
mcp__magpie__WebFetch, and toolStart handed that over whole: the 11-02
fix for an unloaded magpie MCP tool (packinggoods) kept the full name for
every cut name the client hadn't declared. The client answered "No such
tool available: mcp__magpie__WebFetch", the model retried, and
status lines such as claude-hud showed a "magpie" MCP failure.
toolStart now keeps the prefix only when the cut name has the router's
form, <server>__<tool> (magpieServerTool): the client names magpie's MCP
tools mcp__magpie__<server>__<tool>, and its built-ins (WebFetch,
WebSearch, CronCreate, CronDelete, CronList, NotebookEdit, Monitor,
TaskStop, SendMessage, EnterWorktree, ExitWorktree: the deferred list of
a real Claude Code session) have no __ and no prefix. A sibling the same
line got wrong: another MCP server's deferred tool, called as
mcp__magpie__mcp__linear__get_issue, is handed over as
mcp__linear__get_issue, the client's name (it was handed over whole too).
toolStart is the one place a called name is mapped back for the client:
streamed and whole messages and the interactive mode's early call
(r.onCall) all go through it; mcpCall's declaredName serves offered
tools only, and the history's names (bridgeName) are unchanged.
Run (on mote, at this tree):
- go test ./internal/gateway -count=1 -timeout 45m: ok
- gofmt -l: nothing; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok; go build: ok
Broken by hand: magpieServerTool returning true (the old behaviour)
turns TestClaudeBridgeHandsOverAnUnloadedMagpieTool red on the new
WebFetch and mcp__linear__ cases ("handed a call of
mcp__magpie__WebFetch, want WebFetch").
Not tried: a real Claude Code client with tool search on (the reporter's
Windows setup); a deferred tool the run's model calls by the bare client
name (WebFetch) is still the run's Claude Code's to answer and isn't
handed over. A client MCP server of its own named "magpie" with a tool
lacking __ would now be cut; magpie's router names every tool
<server>__<tool>.
Rebased on
|
||
|
|
9a92fd099b |
claude: a long auto mode classifier keeps its cache marks as claude -p (#5585, #5655)
With Claude Code's interactive mode on, the classifier was pasted into a new run each call with none of its marks: Claude Code marks only the last block of what it is pasted, and the classifier's tail changes every call, so each call read only Claude Code's own prompt and wrote the whole transcript again (126K and 132K a call at 1h's 2x in iamnil's rows). Desktop's header-less classifier lost its marks at parse time ( |
||
|
|
a7113d5c92 |
gateway: a Mac's Claude Code cache pick reaches the remote magpie's relay (linkaww)
linkaww's chain: Claude Code on a Mac (API-key mode) -> the Mac's magpie -> a Docker magpie whose Claude provider is the relay. Two rules asked for: a 5m pick on the Mac never writes an hour's cache; with nothing picked, the relay keeps Claude Code's subscription default, an hour. Claude Code 2.1.316 marks five minutes with no ttl, whether its user picked them or it is its default off a subscription (the marker names a ttl only for 1h). So since v0.1.3256 the relay, which followed the marks, wrote 5m with nothing picked, and an unmarked side call (Haiku's title, the classifier) fell to the Docker computer's own pick, an hour, under a 5m pick. Now the Mac's magpie names the pick: X-Magpie-Claude-Cache-TTL (ClaudeCacheTTLHeader), "5m", "1h" or "default", set by passOnCaller for a request from Claude Code on this computer (its token or its claude-cli/ User-Agent from loopback, never Claude Desktop's) and passed on as it came through further magpies. It is read as claudeRunTTL reads the pick (claudePickedTTL); a settings.json that can't be read or parsed names none (claudeSettingsKnown), and the marks decide as before. The far magpie takes it from a magpie/ request alone (callerFrom) and takes it off what comes in (withCaller), so no vendor sees it; native passthrough already drops X-Magpie-*. runTTLFor: forced 5m; marks that name an hour; else the pick (Request.pickedTTL), "default" giving claudeRunTTL (that computer's pick or an hour); else the marks; else claudeRunTTL. Claude Code on the relay's own computer gets the same rule from its local pick. A Claude Code that goes straight to a remote magpie sends no header and keeps today's marks-first behaviour. Nothing sent to Anthropic changes beyond the run's CLAUDE_CODE_PROMPT_CACHE_TTL. Known limits, in the bridge doc: a pick made only in Claude Code's shell env or a project's .claude/settings.json isn't seen by magpie, so it goes as "default" (an hour unless the marks name one); subagentPromptCacheTtl is not told apart. Tests: TestClaudeRunKeepsTheUsersCacheTTL gains 11 cases (the Mac's 5m/1h/default, marked and unmarked, against this computer's settings, forced, marks naming 1h, Claude Code here, unreadable settings); TestClaudeCacheTTLFromAMagpieOnly; TestClaudeCacheTTLOf; TestClaudeCacheTTLReachesTheRemoteMagpie (two real handlers: 5m, default, unreadable -> none, another agent -> none, vendor sees no X-Magpie-* header). Run (on mote, at this tree rebased on |
||
|
|
bb33142eae |
gateway: a relayed Claude run cut from a busy, forked or side-questioned session keeps its 5m cache (linkaww)
The relay's runs keep the cache lifetime of the session they go on from
(savedSession.cachePrefix). Three of the four places that make a
savedSession left it out: branch (a fork's turn), retryBranch (a turn
sent again while its run is busy) and branchAt (the turn after the
interactive mode's side question). cachePrefix.runTTL() reads an empty
ttl as an hour, so each such run was started with
CLAUDE_CODE_PROMPT_CACHE_TTL=1h under a 5m pick, and wrote 1h cache
entries. Each now carries its run's cachePrefix, as shelve did.
Tests: the fork, busy-retry and side question harnesses log each run's
CLAUDE_CODE_PROMPT_CACHE_TTL; with promptCacheTtl 5m picked
(pickFiveMinutes), everyRunKept5m requires every resumed run to have 5m.
Run (on mote, at this commit, base
|
||
|
|
dca338f3a3 |
gateway: a relayed Claude run keeps its cache as long as the request's own marks ask (Linka)
v0.1.3247 ( |
||
|
|
999ba6a00e |
claudetui: a replayed history keeps its words when one of its lines names an image file and an image follows (#5548)
#5548, Suge8 (magpie 0.1.3106, Claude Code 2.1.318, macOS, interactive mode, Pi over OpenAI Chat): a compacted Pi conversation told whole to a new Claude Code reached it as its four images and the closing notes only; the history, which had `ls` output naming screenshots (a.jpg, …), came into the next prompt, out of order. Cause: send pasted a message's text piece and, without waiting for it to show, the image after it; only the last text piece was waited for. Claude Code 2.1.318 tries each pasted line ending in .png, .jpg, .jpeg, .gif or .webp as an image file before it takes the words in (for a relative name it asks the clipboard through osascript, about 0.45s), and keeps one "pasting" mark for every paste. The image's read ended first and cleared it, so the Enter after the closing notes sent the prompt without the words. Fix: - send waits for every text piece to show before the next piece, not only the last one. - shown counts a "[Pasted text #N" only with N past the paste before it, else the words' own last line: images and pasted text share Claude Code's numbering, so send keeps one number for both, and the prompt drawn again shows the earlier "[Pasted text #1". An inline paste (800 bytes and 2 line breaks at most) takes no number in 2.1.318, so the number stays exact. A paste not shown within shownWait is still gone past, as before. - Every paste goes through send, the WSL and queued (busy) messages too; a message of an image alone has no text to wait for, and one of text alone was already waited for. Tests: the fake Claude Code now does what 2.1.318 does here: it draws a long paste as "[Pasted text #N +B lines]" numbered with the images, draws the prompt again as a paste starts, takes words naming an image file in after 1s, and keeps one pasting mark (an Enter while it is set is lost). TestShimWaitsForWordsNamingImages sends [words naming foo.png, image, an ls naming bar.png and baz.png, image, closing notes], and the same naming .txt files. TestShimPastesImages now expects its second image as #3: the "and" between two images is 4 line breaks, pasted text as 2.1.318 numbers it. Run, at this tree on |
||
|
|
dbc74414bb |
claude: a relayed run keeps its prompt cache as long as the user picked, not always an hour
linkaww (Discord #feedback, server v0.1.3237 in Docker, Claude Code 2.1.319) set the Agents page's prompt cache for the main conversation and subagents to 5 minutes, and settings.json had "5m", but 237 of 241 relayed requests since 11-01 wrote an hour's cache. cleanClaudeEnv took CLAUDE_CODE_PROMPT_CACHE_TTL out of the run's environment and put back "1h" every time ( |
||
|
|
325dc3ab32 |
claude-tui: a Claude Code that draws nothing is said with what it waits on, and its turn isn't waited out twice
sowhynot (v0.1.3222, macOS): every interactive run ended "Claude Code showed no prompt in 45s: nothing on its screen (0 bytes read)", and the bridge then started a new Claude Code told the whole conversation, which waited out another 45s before the turn was answered 502. Cause class: Claude Code blocks before its first draw on something it waits for and writes nothing to the pty. Reproduced on mote with real Claude Code 2.1.319 (npm latest) in a sandbox HOME: its read of the "Claude Code" Keychain item is a synchronous `security find-generic-password` with no time limit (its other Keychain reads have 2s/10s limits), so a Keychain waiting on an allow window or a locked keychain gives exactly "0 bytes read" at 45s. Its network waits (remote managed settings and policy limits, for a setup-token or team account with --mcp-config) are bounded at ~30s and draw after, so they don't give 0 bytes. - claudetui: with 0 bytes read, the reason adds what Claude Code runs (its descendants from ps, longest first) and how much it holds; a Keychain read is named with its item and what to do. Other commands are named by program (and an interpreter's script) only, never their arguments. macOS and Linux; Windows says what it said before. - gateway: a helper that ends saying why the interactive mode didn't come up is tuiNoStart, not tried again told the whole conversation, unless Claude Code ended itself before its prompt (claudetui.EndedEarly, the "No conversation found" case the retry is for). - No early end on 0 bytes: a Keychain window may still be answered. No -p fallback: removed on purpose in |
||
|
|
82403f9f6d |
claude: /usage is read through -p, never the interactive mode, which opened idle accounts' 5-hour window (#5582)
Since v0.1.2635 ( |
||
|
|
665b9aff12 |
gateway: a reply of several requests tells the last one's prompt, bills them all
Claude Code reads a reply's input, cache_creation and cache_read as how full its conversation is. A reply more than one upstream request made summed all three across them. In the bridge: Claude Code's own ToolSearch/WebSearch going on into the answering message, a TUI message written after its call was told (lateUsage), a cut stream's retry ( |
||
|
|
766d2a9f54 |
gateway: a Claude turn sent again while its run is busy with it goes on from a copy of its session (#5405)
A client's connection dropped mid-reply and its request was retried, with no cancel reaching magpie (#5405, margbug01: a gateway between the client and the server magpie retried after "unexpected EOF"). The run the first attempt resumed was still busy with the very turn, so resume and unshelve found nothing, and the retry started a new Claude Code told the whole conversation in one message: only Claude Code's own system prompt and tools read from the cache, the rest (92K to 142K tokens in the report) written again on every retry. retryBranch, tried in start between unshelve and retire, finds a busy run of the account whose last heard request is this one, message for message, and starts the retry's run from a copy of that run's session cut before the turn (cutReply at backLine/backMsg), told only the turn, as a branch off a side question already is. The busy run is left alone; when both park at the same key, keepIdle lets the older go. nil, and the conversation told whole as before, when no run matches, the client places its own cache marks, the run was or is being taken back, it was started for this turn (nothing before the turn to cut at), or the session can't be cut (logged). Changed from ggbdpq's patch: it matched with follows, which also takes a request that goes on past the busy run's turn; the retry is matched by the heard request's key alone. A copy cut for an older run is discarded when a newer one is taken, a failed cut is logged as the patch's notes say, and a run with a reply id but no line yet is cut by the reply, as branchAt does. The test waits for the busy run to have heard the turn instead of sleeping 200ms, and stops the held first attempt in t.Cleanup, so a failing assert doesn't leave it running. The doc's "goes on to step 3" now says step 4. Run (mote, -tags nogui): - TestClaudeTurnSentAgainWhileItsRunIsBusyBranchesOffItsSession (print, interactive) -count=3: ok. - Broken by hand: claude_subscription.go back to origin/main, test kept: FAIL in both modes, "0 runs branched, 2 started anew, want one of each". Restored: ok. - TestClaudeTurnPastABusyRunsTurnIsNotBranchedOffIt (print, interactive): a turn sent past the busy run's own, with a reply the client has, is told whole (one message, or the interactive mode's transcript), not branched off the busy run. -count=3 with the other test: ok; -race -count=5 of both: ok. - Broken by hand: the match back to follows: FAIL in both modes, "the turn past the busy run's was branched off it" (nextTurn gives its run only "now commit it", the turn and reply before it lost). Restored: ok. - -run TestClaude ./internal/gateway/: ok 139s. - -race -count=5 -run of the busy-retry, fork, side-question, given-up, rewind, unshelve and branch tests: ok 52s. - go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of internal/gateway: clean. - gofmt -l on both Go files: empty. Not tried: a real Claude subscription with a real dropped connection. The full suite runs after the push. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
77031d5817 |
claude usage: a /usage panel with no window is no window started, and a failure says why
koohoko5924 (Discord #help, v0.1.3057, macOS): a Claude Enterprise
account with a five-hour window only. A manual refresh took ~5s and
gave the card no window and the error "Claude Code's usage showed no
usage figures: ▐▛███▜▌ … magpie-claude-work…": Claude Code's banner,
not a reason.
Claude Code 2.1.316's Usage tab (gi) draws a window only once
Anthropic's answer has it non-null, and a window is null until the
request that starts it. An idle 5h-only account's panel loads with
the session's cost, maybe the plan's credit bar, and no window. The
helper told that panel's words, joined from the top of the screen, and
the card took them as a failure with the banner first.
- claudetui: a panel that loaded (tabs, Session/Total cost, nothing
loading, refreshing, stale or failed, no gateway Spend limit) with no
"Current session"/"Current week" is told as NoUsageWindow ("No usage
window has started"). The provider reads that as no window started:
no error, the unstarted 5h window as for any account.
- claudetui: the two rate-limit errors gi draws ("Claude is temporarily
limiting requests to the usage page (not your usage limit)…",
"Usage endpoint is rate limited until …") are failures to load, like
"Failed to load usage data": retried once, then told as an error with
the panel's own "Error: …" text, never the banner. A panel with no
window and no error is told from its tabs on, the session's cost
lines left out.
- provider: "(not your usage limit)" no longer reads as an account
refused (claudeDenied, at every place claudeUsageDenied judged a
reading: the CLI parse, codex_switch, quota_last, subscription_usage).
Counts ("Last 7d · 403 requests …") are taken out wherever they sit in
a line before that check, as the panel's words come on one line now.
A no-figures error keeps every line (600 runes), not the first clipped
at 120.
Tests are built from 2.1.316's own strings (ko/gi/hi in the bundled
cli.js), drawn on the helper's 200x50 grid row by row. Guessed: the
exact bytes of a real Enterprise panel (not captured; no such account
here) and the credit bar's layout.
Run (mote, at this tree): go test ./internal/claudetui ./internal/provider
-run 'Usage|Claude|Shim|Quota|Codex' ok; go vet for claudetui, provider,
gateway; GOOS=linux -tags nogui and GOOS=windows go vet; gofmt -l clean.
Broken by hand (each red, then restored):
- the NoUsageWindow case off: TestShimReadsUsageWithNoWindow red in all
three panels (told the panel's words as success);
- the provider's claudeNoWindow branch off: TestClaudeUsageNoWindowStarted
red ("showed no usage figures: No usage window has started");
- claudeDenied back to claudeUsageDenied: TestClaudeUsageWhyKept red
("read as an account refused");
- usageFailed back to "Failed to load usage data" and the whole screen as
the reason: TestShimToldWhyUsageFailed red in all three (the banner as
the reason; the rate-limit panels told as no window), TestUsageNoWindow
red.
Not tried: a real Claude Enterprise account; a real rate-limited panel.
|
||
|
|
b7631300ec |
claudetui: a successful interactive turn tells its account's allowance
Since the interactive mode replaced -p for Claude subscription turns ( |
||
|
|
60fe6645a9 |
claude: a caller's folder Claude Code would ask about is known before the run, and the session kept (sleepy_shibe)
sleepy_shibe on Discord (magpie 0.1.2996, Claude Code 2.1.318, own account, interactive mode): message counts 36, 65, 85, 108, 128 for one conversation. Confirmed at origin/main |
||
|
|
498b6419ff |
claude: a turn Anthropic refuses in the interactive mode as a third-party app's is asked again as claude -p, and the agent's prompt is remembered
Raven (Discord #general): Cindy with Pi as its engine, routed through
group/auto to a Claude subscription, failed every turn with "Anthropic
refused an interactive-mode turn on claude-opus-5-5 as a third-party
app's", and the message told them to turn the interactive mode off in
Settings, which makes every request of every agent run as -p (about twice
the plan count).
Now, with the interactive mode on:
- a refusal carrying "Third-party apps now draw from your extra usage",
met before a byte of the reply reached the client (stream head, or a
whole reply with no parts), is asked again once as claude -p
(redoAsPrint); the client sees only the -p answer;
- the agent's system prompt (sha256 of its first 2KB, billing header
dropped, so Pi's trailing <cwd> doesn't change it) is remembered for
12h, and its next turns go straight to -p (wantTUI, req.tuiRefused,
clientCache.print) while every other agent stays interactive;
- a refusal after the reply had begun (keepalive sent, or text said) is
not redone, so nothing is spent twice; the prompt is still remembered
and the message now says magpie runs its next turns as -p: ask again;
- a -p run that is refused too fails as before ("run as claude -p"),
once, no loop;
- the setting is untouched; with it off (claudePrintMode) everything is
-p as before. The run is the real claude binary, nothing else changed
in what is sent.
This reverses the #4503 call (
|
||
|
|
2947685999 |
claude: an interactive run's calls keep the conversation they answered when their line comes late
kay20475 on X (magpie 0.1.3005, local magpie -> shared server magpie ->
Claude subscription, interactive bridge): a Claude Code sub-agent's
requests on one account read 99%, 6%, 6%, 99% from the cache; the two 6%
requests were 169.1k each, 35s apart, about 3s long with a short reply.
That is the shape of Claude Code's AgentSummary: every ~30s it sends the
sub-agent's conversation with its last results and "Describe your most
recent action in 3-5 words", while the sub-agent's own run has already
taken those results.
Cause. Such a request finds no run waiting on its calls and should go on
in a branch of the sub-agent's run's session (branch). branch takes it
only when the conversation stored on the call's line (callLine.told)
matches the one before the reply. park stored that only on lines it
already had. The interactive mode streams a reply first and reads its
session lines from the file afterwards (118-162ms after the call). So the
run parked before noteLines had the call's line, and the line came in
with no conversation. The next park then gave it the next request's
conversation. branch returned nil, and every AgentSummary (and every
fork directive) was told the whole conversation in a new Claude Code,
pasted as one text block. A single block can't match the cache beyond
the tools and system prompt, so 6%, and the next summary missed the same
way because its tail differs.
Fix. park also keeps the conversation for each call the client was shown
(r.shown), as a line with no uuid yet. noteLines keeps it when the line
comes, and branch skips lines with no uuid.
Test: TestClaudeForkBranchesOffTheLeadsSession/interactive now has the
fake write the call's session line after the reply's stream, once the
result is handed over, so after the park, which is the real order.
Broken by hand: with this test and the old claude_subscription.go on
mote, it fails ("told it whole", want "branched at line-...").
Run on mote at this tree (base
|
||
|
|
49e382735f |
claude: a side question after a run's first reply of words branches by the reply's id
sleepy_shibe (Discord #feedback, magpie 0.1.2948, Claude Code 2.1.318,
claude-opus-5-5, macOS, interactive mode): when the last turn's reply
was words only, the turn after a prompt suggestion found no run
("claude: no run waits for this turn: its run ended 0s ago: the
interactive Claude Code can't go on with this turn") and a new Claude
Code was told the whole conversation as a transcript. With a tool call
in the turn it branched. 3 sessions, 7 times.
Cause (the reporter's reading, checked in a test): the interactive mode
streams a reply and the bridge hears its session line only later, from
the file. resume saves run.lastLine as the turn's backLine. A run's
first reply of words has no line heard yet, so backLine, behindLine and
the shelf's behindLine were empty while behindMsg (from message_start)
held the reply's id. branchAt returned nil at `at == ""` with no log,
and the run was let go. With a tool call, the run waited on the call and
heard the call's line first, so there was a line to cut at (
|
||
|
|
d892dd6a22 |
gateway: a Claude conversation keeps the folder it named first when its caller moves
EricWvi on X (Claude Code -> local magpie -> a magpie on a server -> a
Claude subscription): the cache read flipped between under 10% and over
90%, each drop on a turn whose folder had changed (.../frontend, then
.../frontend/src). Claude Code 2.1.316 says a cd as a later
"# Environment update" message, "Primary working directory: /y (was /x)".
clientNamedWorkPlace took the last folder named, so a run started again
for the conversation (saved session resumed, branch, replay) got a
different prefix than its first run:
- a caller elsewhere: envTurnsNote names the folder, so append.md changed;
- a caller on this computer: the run worked in the new folder, whose
session project doesn't hold the saved session, so --resume was lost
and the whole conversation was told again.
Either way the whole conversation was written to the cache again.
Now the first text that names a folder decides it (within that text, its
last line, so "said twice" in one system prompt keeps its meaning). The
move still reaches the model in the conversation as the caller said it.
No text is added to the prompt; the note's wording is unchanged.
The reporter's per-turn flips on a v0.1.2879 server are the earlier
safeguards restart (git_state.cwd in safeguardsKept), fixed by
|
||
|
|
d3c544ddf4 |
claude: a replayed transcript marks no earlier turn as the one to answer
The interactive mode gives a conversation no run has to a new Claude Code as its own transcript (replaySession): a user line with the messages before the last reply, the reply as the assistant line, and the turn after it typed. The user line was rendered with renderClaudePrompt, which ran historyEnd again on the cut messages, so for U0 A0 U1 A1 U2 it was history(U0, A0) + <current_turn>U1, "the turn to answer now", followed by A1, then U2 typed. U1 was answered already; the reporter saw the model answer an old question again, and say earlier tool calls had no results (愛睏柴犬阿茶 on Discord #feedback, with the analysis and the fix suggested). renderClaudePrompt is now renderClaudePromptAt(req, historyEnd(...)); replaySession calls it with the split at the end, which tells every message before the reply inside <conversation_history> and closes it there, with no <current_turn>. Every other render is unchanged. Siblings: historyEnd has two callers, replaySession (whose own split, on the whole request, is right: the reply and the turn typed after it) and renderClaudePrompt. replaySession is the only place that renders a cut slice of the messages (grep 'Messages = .*Messages\[:'). renderClaudeTurn (the typed turn) has no history marks. Run (on mote, mote-run): - go test ./internal/gateway -run TestClaudeTUIReplayMarksNoEarlierTurnCurrent: red on the old code (all 5 subtests: two turns, three turns, tool results in both turns, tool results only before the reply, the client's calls after the reply), green with the fix. - Broken by hand: put renderClaudePrompt(&before) back in replaySession, the new test went red; restored. - go vet ./internal/gateway, GOOS=linux and GOOS=windows go vet: ok. - go test ./internal/gateway -run 'Claude|Replay|Prompt|Turn': ok 124.6s. - go test ./internal/gateway -run 'Loop|Guard|Doc': ok. - gofmt -l internal/: clean. Not tried: a real Claude Code resumed on such a transcript with a real account (the change to what the model sees was checked in the transcript file only); the full suite runs after the tag. |
||
|
|
59c1306035 |
claude: an auto-mode client's tool loop keeps its interactive run (#4804)
Auto mode's safeguards change with every tool batch: prior_turn_context grows by the turn before. An interactive Claude Code run read them once, from CLAUDE_CODE_EXTRA_BODY in its environment as it started. So a tool loop either started the run again (the whole conversation written to the cache again), or kept it and sent the classifier the context it started with, which is not what real Claude Code sends. Each turn's safeguards now reach the running run: - The bridge writes the extra body to <run tmp>/guard.json and hands its path to the helper as MAGPIE_CLAUDE_GUARD (mapped for WSL in newTap). - tap.js, on each /v1/messages request whose string body has a safeguards key, reads the file and puts its safeguards in the body. It also sets CLAUDE_CODE_EXTRA_BODY to the file's text, so Claude Code's own later reads agree. The first time, it writes guard.json.live. - setSafeguards rewrites the file (temp and rename, retried for Windows) instead of restarting, once .live exists. Without .live (a Claude Code that doesn't load the tap), it falls back to the old rule: keep the run when only the varying parts changed, otherwise restart. A beta change, or safeguards appearing or going, still restarts. The tap changes only the safeguards value; any other byte of the body is Claude Code's own. Bodies without safeguards, count_tokens and non-string bodies are passed through untouched. The tool-results path logged "process expired" alone while the run's end read "magpie ended it". It now aborts the run with the reason and logs "tool results process expired: <reason>". continueWith's "not waiting for tool results" does the same. Tests: - TestClaudeTUIToolLoopCarriesEachBatchsSafeguards: three tool batches with growing prior_turn_context, then the answer. Checks one run and that each request carried its own batch's safeguards. - TestClaudeTUIToolResultsLogWhyTheRunEnded: no tap and the rules change. Checks that the log has the reason. - TestTapPutsTheGuardFilesSafeguards (bun and node): the rewrite, the bodies left alone, the env, and .live. - TestTapEnv: MAGPIE_CLAUDE_GUARD is passed through, WSL-mapped. Run (worktree at |
||
|
|
8468afecb3 |
claude: a turn's images say they are attached, so the file notes after them are not taken for the images
Claude Code notes each image it is given ([Image: source: .../images/N.jpg])
in a note after the message, with a path in the gateway's temp folder. With
no history before the turn, nothing said what they are: the model took the
paths for the images, said it could not see them and quoted the paths as on
another computer (sinsoul1647 on Discord, v0.1.2862, 7 tool-result photos).
The prompt (renderClaudePrompt) and a saved session's turn (renderClaudeTurn)
now say the images, tool results' too, are in the message.
Tried: real claude 2.1.316 on mote against a fake Anthropic server, with
-p user images, MCP tool-result images, a url source, the TUI paste and a
resumed transcript: every one reached the API as image blocks, so the loss
is the model's reading of the notes, not a dropped image.
Not tried: the reporter's client; whether the model stops quoting paths.
Broken by hand: with the note left out, TestClaudePromptSaysToolResultImagesAreAttached is red.
Run at the pushed head (rebased on
|
||
|
|
40a287b217 |
gateway: a quiet Claude Code run begins the reply and pings its client (#5043)
A streamed Claude subscription turn whose run says nothing for minutes
(the interactive mode tells a message only once it is whole; a long
conversation replayed to a new Claude Code is prefilled uncached first)
gave its client the held stream's 200 and comments, and those stop at
keepaliveLongest (5 min). Claude Code 2.1.316's byte watchdog then ended
the request 300s later, at 599s: the reporter's 599.29s and 599.33s.
Each cancel aborts the TUI run (letGo), so the retry is a new Claude Code
that replays the history and writes it to the cache again (#3808).
keepBridgeHeard wraps the run's events for a stream: after
bridgeHeardAfter (1 min) of a quiet run it sends an empty KStart, which
makes relay begin the reply (message_start), and a KAlive every
keepaliveEvery while it stays quiet, up to translatedQuietLongest, so the
client gets its protocol's pings (#2316's pattern). The hold still holds
the frames to holdLead and passes an error over. The run's own start
later adds its usage (collector), and a failure in the first minute is
still a status.
The gain is bounded. Claude Code 2.1.316 turns every 10s with bytes into
a ping of its own (RSr, __n=1e4) and counts 30 pings in a row (vSr=30),
so a stream of pings and comments alone ends 600s after its last other
event. The run now has until about 14 minutes (message_start at ~4 min
plus 600s), where it had 599s. The reporter's retries answered first at
385s and 527s.
Run:
- Real claude.exe 2.1.316 (-p, sandbox HOME, env -i) against a fake
Anthropic server:
- headers at 3s, comments to 300s: ended at 598.38s ("[byte-watchdog]
... no bytes for 300000ms"; "Stream idle timeout before first event").
- comments forever: ended at ~600s from headers ("no chunks received
for 300s").
- no headers: "Request timed out" at 360s.
- this fix's shape (message_start + ping at 300s, a ping every 60s):
lasted to 904s, then "no chunks received for 300s" and fell back to
non-streaming. That is the 600s bound above.
- mote-run: go test -tags nogui -count=1 -timeout 45m ./internal/gateway
ok (675.8s), at this change before its comment-only edits.
- mote-run: go test -tags nogui -count=1 -timeout 45m ./internal/gateway
ok (680.2s) again at this tree, rebased on origin/main
|
||
|
|
3088872e63 |
claude: an interactive run goes on when only Claude Code's varying safety context changed (xybio)
xybio on Discord (Claude Pro, Claude Code through magpie, likely in auto mode) saw it twice: right after the 5-hour window reset, one message took the window from 100% to 0%. Their Usage page for the day (claude-opus-5-5): - 62 requests and 17M tokens, almost all of it cache (input 102, output 31.3K); - a 29.4% cache hit rate, so about 12M tokens were written to the cache, around 290K for each of the 41 that succeeded. That is the whole conversation written again on almost every request. The cause is in the bridge. With server review on, which it is for a Claude account (AutoModeReviewed), every request carries Claude Code's `safeguards`. The interactive mode's Claude Code reads CLAUDE_CODE_EXTRA_BODY only as it starts, so setSafeguards restarted the run whenever the field differed in any byte. A new run is told the whole conversation, and that writes it all to the cache again. The field's classifier_context differs on nearly every request. That is in Claude Code's own code (2.1.316, Jmr): - prior_turn_context grows with each tool round's tool_use_ids; - git_state.status follows every edit; - system_reminders, artifacts, text_provenance and the shed list vary too. So every tool round and every turn of one message started a fresh run (4 turns gave 4 runs in the new test on the old code), each paying a full cache write of the history. Change: in an interactive run, setSafeguards compares safeguardsKept forms. That form leaves out the parts Claude Code itself names as variable and sheds over its 256KB budget: - prior_turn_context, system_reminders, artifacts, text_provenance, shed; - Chrome's tabs; - git_state except cwd, root, branch and default_branch. When only those changed, the run goes on with the context it started with. A change to the rules, permission or auto mode, folders, or the repository and branch still restarts it. A field that isn't the expected JSON is compared whole. The -p path is unchanged: it takes every change in place through apply_flag_settings. The cost is that the server classifier sees those varying parts as they were when the run started. This is noted in docs/subsystems/claude-subscription-bridge.md. Run at the pushed head (52d69934f, on origin/main |
||
|
|
3d7b1233dd |
claudetui: /usage's screen is read at the terminal's own 200 by 50 on macOS and Linux (#4988, shinnqy on X)
shinnqy on X: in the latest magpie Claude Code's usage doesn't load.
#4988 (0.1.2776, macOS, Team plan): the card said 100% / unused, and
`magpie quota refresh claude` gave one window, "7 days · Fable" 0%, while
the account's 5 hours were 29% and 7 days 17% used.
Cause:
|
||
|
|
17d2ef10fa |
claude: a conversation's instructions stay after Claude Code's prompt in every interactive run
m4rs0n on Discord: since #2432 ( |
||
|
|
0561d53521 |
gateway: spawned Claude Code registers no claude-cli:// URL handler (#4928)
--setting-sources "" keeps the user's own disableDeepLinkRegistration from loading, so every spawned claude registered the claude-cli:// OS URL handler again and "Claude Code URL Handler.app" came back after the user had deleted it. A headless run has no use for an OS URL handler: the setting is now passed as flag settings (--settings is not one of the sources --setting-sources controls) on the bridge run and the warm-up and usage runs beside it, whatever the user's settings read. Review: applied as ggbdpq posted it (patch sha256 checked against the issue's). Checked in the Claude Code binary that flag settings read disableDeepLinkRegistration === "disable" and that --setting-sources "" doesn't filter --settings. `claude auth login` and `auth status` take no --setting-sources, so the user's own settings already apply there; they are not changed. Broken by hand at the reviewed head: claude_warmup.go and claude_subscription.go reverted to their parent, TestClaudeSubscriptionPromptKeepsForeignHarnessOutOfSystem, TestWarmClaudeAsksClaudeCodeOnce, TestClaudeUsageRunsClaudeCode, TestAskClaudeTUIOn and TestClaudeUsageTUIOn red. Restored, green. Run at the pushed tree (this stack of nine on origin/main |
||
|
|
a8d36b0faa |
fix(claude): a run let go after answering a prompt suggestion leaves its session for the conversation's next turn (#4914)
Claude Code asks its prompt suggestion after each turn as the conversation and one message more, and its run goes on with it (#1638): the run waits on from the suggestion's exchange, under a key the conversation's own next turn never comes by, since the client leaves the exchange out of its messages. While the run is kept, that turn finds it by where it stood before and takes it back to there (resume). But a run let go past idleMost was lost to its conversation: shelve kept its session where the suggestion's exchange had left it, or, when the conversation's own turn had already taken the run back from a suggestion (-p), not at all — its session was marked taken back, which the file may not say, and no session was kept. The next turn found no run and no saved session, and a new Claude Code was told the whole conversation in one message, a prefix the cache had never seen, written to the cache again (a 50k conversation: 19k read and 29k written where 49k read and 50 written; the log said no run here had had a conversation one had). The shelf now keeps a session where the conversation's next turn comes by, too (savedSession.behind, run.behindKey), and unshelve takes it from there when no session waits at the turn's own key. A session taken back is kept once the run has answered a whole turn since (run.replied, set as a turn ends, cleared at each take-back): the file's lines since are that turn and what came after, and Claude Code's resume goes on from them. And a run's end is kept under the boundary before its own (run.convPrev), so the log of a turn that finds it gone says what became of it when its last exchange was a side question. Run: TestClaudeLetGoConversationAfterSuggestionResumesItsSession fails on the parent |
||
|
|
3a74cd92e8 |
claude: /usage waits for its figures, and a read without them is unknown
Seagull fries (haioushutiao, Discord #help; magpie 0.1.2704, Claude Code
2.1.316, Windows 11, Claude Pro): the Claude card said 暂时无法获取额度,
"Claude Code's /usage told no allowance: ❯ /usage ─── Settin s Status
Config Usage …". Reproduced with a real Claude Code 2.1.316 under
Windows' pseudo console in a sandbox: /usage's panel is drawn first with
"Loading usage data…" while Claude Code asks Anthropic for the figures
(5s timeout, retried only on a 401), and the helper took 3s of a still
screen as the panel drawn whole. On a slow answer it told the panel's
frame as the result, and parseClaudeUsage called any text with no window
"told no allowance". A failed load ("Error: Failed to load usage data",
"r to retry") went the same way.
claudetui:
- screen.go: a small terminal grid (CUP/CUU..CHA/VPA, EL, ED, ECH, CR/LF
with scrolling, OSC/DCS skipped, an escape or UTF-8 character cut
between reads kept), 200x50 on Windows as the pseudo console is made,
80x24 elsewhere. The pseudo console sends only the cells that changed,
skipping a cell that holds the same letter ("Settin\x1b[1Cs"), so the
stream read split words and kept a redrawn digit beside the old one.
While /usage is read, each look of the screen with a window is kept
(panel), and usageText reads that before the stream.
- command(), built on b4073c06a's wait for the panel (ikunbots; its
usageDrawn and "hadn't drawn" error kept, now also judged on the grid,
since the pseudo console's split "Settin s" never matched its tabs):
"Loading usage data" on screen is waited out (to
commandWait, s.doing "was still loading /usage's figures" for the
deadline message); "Failed to load usage data" gets one "r"; a panel
still with no figure and loading or failed on screen is an
error_during_execution result, "/usage couldn't load the plan's usage:
<screen>".
- the fake draws the panel a frame at a time (fakeFrames), as Claude Code
does: with one write, the pseudo console passed on only the last
frame, which no longer shows the windows. TestShimReadsUsage now passes
on Windows (#4820, the fake's side; a real panel with figures was not
seen on Windows, see below).
provider:
- parseClaudeUsage: a panel with no figure is "Claude Code's /usage
showed no usage figures: …", not "told no allowance" (kept for
claudeUsageDenied's refusals).
- claudeUsageUnknown: Claude Code's "temporarily unavailable" and the
helper's "couldn't load the plan's usage" keep the account's reported
reading (quota_last), as the first did alone before. Other no-figure
text is still shown as an error (TestClaudeHeaderSurvivesUnclassified-
UsageFailure, TestClaudeUsageReadingAloneDoesNotHideUnclassifiedFailure
hold that).
Fixtures are the reporter's case as the pseudo console passed it on for
the real 2.1.316 (a temporary dump of the helper's screen bytes, sandbox config,
proxy that never answers / refuses): testdata/usage-loading-win-2.1.316.bin
and usage-failed-win-2.1.316.bin.
Run at the pushed head:
- mote: go test ./internal/claudetui ./internal/provider ok; go test
-run 'Claude|Usage|TUI' ./internal/gateway ok; GOOS=darwin/linux/
windows go vet ./internal/claudetui ./internal/provider ok; gofmt -l
clean.
- xiaomi-gpu (win-run): go test ./internal/claudetui: all pass except
TestShimFirstMessageWaitsForTools, red on Windows at main (#4810).
- xiaomi-gpu, real Claude Code 2.1.316 (npm), sandbox CLAUDE_CONFIG_DIR
with a fake token, magpie.exe built from this tree, helper run as the
gateway runs it: a proxy that never answers gives is_error "/usage
couldn't load the plan's usage: … Settings Status … Loading usage data…"
after the 20s wait (was a success with the chrome); a refused proxy
shows "Failed to load usage data", "r" is pressed, and the same error
comes back in 6.6s. "Settings" is whole now.
Broken by hand (before the rebase onto b4073c06a; the merged loop is
re-checked below):
- old tui.go: TestShimWaitsForUsageFigures slow, retried and failed again
all red, each telling the reporter's chrome as success.
- the "r" not written: TestShimWaitsForUsageFigures/retried red.
- old parse message: TestClaudeUsageWithoutFiguresIsUnknown red ("told
no allowance"); old quota_last check: its couldn't-load cases red.
- after the rebase, on the merged loop: the "r" not written,
TestShimWaitsForUsageFigures/retried red; the old "anything still 3s"
in place of usageDrawn on the grid, TestShimWaitsPastTheBanner red.
Not tried: a real account (the box has none of the owner's), so a real
2.1.316 panel with figures was never seen through the pseudo console;
whether Claude Code's frames that show the windows reach the pseudo
console's output before it renders the next one is shown only by the
fake. Not taken: asking Anthropic's /api/oauth/usage, which the owner
ruled out (
|
||
|
|
b4073c06a0 |
claude-tui: /usage waits for its panel, never takes Claude Code's banner as it (ikunbots on X)
ikunbots (v0.1.2738) showed a Claude card saying "Claude Code's /usage told no allowance: ▘▘ ▝▝ /private/var/folders/…/magpie-claude-work-501 ────". After /usage is typed, Claude Code draws itself again (banner, folder, the prompt's rules) before the panel. A slow /usage leaves that still, and the helper took any screen still for 3s as the panel, so the banner was told as /usage's answer and parsed as an error. Now a screen without "NN% used" counts as drawn only when the panel's Settings tabs show and nothing says loading (usageDrawn). With no panel by commandWait (or the caller's deadline), the result is an error naming what was last drawn, never a success carrying the banner. Run (on mote): - go test ./internal/claudetui/: ok (new TestShimWaitsPastTheBanner: the fake draws the reporter's banner, then the 2.1.316 panel 4.5s later; TestUsageDrawn; a "banner, no /usage panel" case in TestShimEndsAtItsCallersDeadline). - Broken by hand (old "anything still 3s" condition back): TestShimWaitsPastTheBanner red, told the banner as the result, as in the report. - go test -run 'Usage|TUI' ./internal/gateway/ ./internal/provider/: ok. - GOOS=darwin/linux/windows go vet ./internal/claudetui/ ./internal/gateway/: clean; gofmt clean. Not tried: a real slow /usage on a real account; the "loading" word is a guess at the panel's loading text, which only keeps waiting longer. |
||
|
|
1490045f59 |
claude bridge: an unloaded deferred magpie MCP tool is handed over by its full name
packinggoods (#feedback, 11-02): every first MCP call in Claude Code failed with "Error: No such tool available: magpie-web-search__web_search" and the retry worked. Claude Code with tool search on names a deferred MCP tool in a reminder and leaves it out of tools until ToolSearch loads it. Through the Claude subscription bridge the run's model reads that name and calls it, mcp__magpie__magpie-web-search__web_search; toolStart cut mcp__magpie__ and, the tool not being one the client sent, handed the client the bare magpie-web-search__web_search, which it has no tool of. After a ToolSearch the tool is in tools, the cut name maps back, and the call works: the retry. |
||
|
|
eb8b840dd4 |
claude: a one-off ask's instructions go after Claude Code's system prompt in the interactive mode (#2432)
The interactive mode's helper pastes a run's first message as one text,
without the cache marks renderClaudePrompt puts on it. A one-off ask's
caller instructions were in that message, so Claude Code's auto mode
classifier wrote them to the cache on every check of one conversation:
laozhang713's six checks on one account, no 429, read 1,197 and wrote
83-85k each (#2432; j1374615791-lab saw the same at 125k).
A new interactive run for a one-off ask (no tools, no reply before it,
not lean, no client marks: appendsPrompt) now gets the instructions by
--append-system-prompt-file (append.md, the leanSystem text, the
environment note worded as a lean run's), and its first message holds
the ask alone. Such a run is let go after its reply (ended); it is never
shelved or branched (run.appended), since a session resumed without the
file would have no instructions. Every other run is unchanged.
Run:
- TestClaudeTUIOneOffAskAppendsInstructions and
TestClaudeAppendOnlyForInteractiveOneOffs (tools, reply, -p) on mote.
Broken by hand (appendsPrompt returning false): the first goes red.
- mote: gofmt; go vet ./internal/gateway for darwin, linux and windows;
go test ./internal/gateway -run 'Claude|Lean|TUI|Subscription|Replay|Branch'
ok (65s), at base
|
||
|
|
e7185daebe |
claude: a failed interactive read says why in app.log, and names the trust question (#4830)
mydosu (#4830) found nothing in app.log to say why every /usage read and
test of a saved account failed, and the card's reason, "showed no
prompt", said nothing of the trust question Claude Code was waiting on.
- claudetui: when the helper's deadline comes while Claude Code shows
"trust this folder", the reason is "Claude Code asked whether to trust
<folder>, not answered in the 16.8s its caller waits for it: <screen>".
Any other screen keeps "showed no prompt".
- gateway: askClaudeTUI and claudeUsageTUI log a failure to app.log
(logOneOff): "claude: a /usage read of saved account <dir> failed: ...",
with the helper's whole reason on one line, which the card clips to 300
bytes. The home folder and any /Users/<name>, /home/<name> or
C:\Users\<name> become ~, secrets go through redact.Scrub, and past
800 bytes the line keeps the first 300 and the last 500, so the end of
the last screen stays.
- docs/subsystems/claude-subscription-bridge.md says both.
Run at this head (mote, rebased on origin/main; the gateway set re-run
with Upstream|Unsent|Routing added after the rebase): gofmt -l clean; go vet for claudetui and
gateway, and GOOS=linux and GOOS=windows go vet for claudetui, gateway
and provider: ok. go test -count=1 -timeout 45m ./internal/claudetui
./internal/provider: ok. ./internal/gateway -run
'Claude|TUI|Usage|Warm|Ask|Trust|Subscription|Bridge|OneOff': ok.
Windows (win-run): ./internal/claudetui ran with the new trust_unanswered
case passing through ConPTY; TestShimFirstMessageWaitsForTools and
TestShimReadsUsage are red there, the same at origin/main
|
||
|
|
aab48dea94 |
claude: a saved account's .claude.json says magpie's work folder is trusted (#4830)
mydosu (#4830, Windows, v0.1.2679, Claude Code 2.1.316): since
|
||
|
|
d39358f1bb |
claude: /usage and "hi" reads run in magpie's work folder and say why they ended (#4830)
mydosu's Claude Code quota reads on Windows failed for both accounts
with "exit status 1" alone. Two things were behind it:
- Each one-off interactive run (claudeUsageTUI, askClaudeTUI) started in
a new magpie-claude-<n> temp folder, which the helper trusted, so each
read wrote one more trusted projects entry into the config's state file.
The reporter had 67 in ~/.claude.json.
- The caller's budget (subscriptionTimeout, 20s) is shorter than the
helper's own waits (45s for the prompt, 20s for a panel). The context's
kill came first, and that is TerminateProcess on Windows, so Wait said
"exit status 1" with an empty stderr. On Unix the same kill says
"signal: killed".
What changed:
- One-off TUI runs work in claudeWorkDir (oneOffDir). That is the
owner-checked folder the bridge's own runs already use, so each config
directory holds one trusted entry instead of one per read. A temp
folder is made only when that folder can't be.
- The run's session file there is removed by the session_id the helper's
init line names (dropOneOff). It is not removed under WSL.
- The helper is told its caller's deadline (claudetui.DeadlineEnv, the
context's deadline less min(3s, a quarter of what is left)). At that
time it ends on its own, saying what Claude Code hadn't done and its
last screen, e.g. "Claude Code hadn't drawn /usage's panel in the
2.9s its caller waits for it: ...".
- A run that still says nothing reads "Claude Code's interactive mode
said nothing before magpie stopped waiting for it (...)" (oneOffErr),
not an exit code.
- quotaError says these reasons on the card as "Allowance unavailable:
{why}" (an existing key in every language). The full text stays in
the tooltip. Nearby comments were cut so the core script budget holds
without a raise.
- No -p fallback was added. The -p asks keep their own temp folder,
since -p asks nothing about trust.
- The entries older magpies left in ~/.claude.json are left alone:
magpie never writes that file.
Run at this head (after the rebase on
|
||
|
|
a8e98e1abb |
gateway: a Claude Code run that exits mid-reply is a failure, not a 200 (#4822)
A Claude subscription run whose Claude Code exited after its reply began, with no message_stop nor a result (only the message_start, or part of the text), closed its segment as if the reply had ended. The client was answered 200 with nothing or the words so far, and the agent took it as a finished turn. - readOutput: at the end of Claude Code's output, a reply begun on the open segment (KStart, tracked in emit as unended until a KStop or KError) ends with a KError, 502, "Claude Code exited before it ended its reply" and the end of its stderr. -p and the interactive mode share this path. - relay, not streamed: any error is a status, words said before it too (was: a 200 with the partial reply), as a translated reply cut short is (errEndedShort). The try's usage is kept as before ( |
||
|
|
af4ff747bc |
claudetui: Claude Code's first-run screens are gone through as a person would, not the run's end (#4817, steven_4422 on Discord)
With "runs as" Interactive, a Claude Code whose onboarding was never finished (no hasCompletedOnboarding in the state file: steven_4422's every request 502'd, uiuing's /usage read in #4817) stopped on the "Security notes" screen, and |
||
|
|
ccd746e039 |
claude: /usage is read in the interactive mode, typed in it, not through -p
With the interactive mode on, the plan's allowance (the Claude account's
usage card) was still read by `claude -p /usage`, the one -p run left
beside a request. Claude Code 2.1.316's -p /usage also tells only the
session's cost, no window. Now claudeUsage, with claudeTUIOn, runs the
interactive mode's helper (claudeUsageTUI) and gives it a line
{"type":"command","command":"/usage"}. The helper types /usage, waits for
the panel to settle (a "N% used" and a second without change, or three
seconds of anything else, 20s at most), closes it with Esc, and tells
what was drawn as -p's lines say it (usageText: "Current session: 0% used
· resets 5am (Asia/Shanghai)"), so parseClaudeUsage reads it unchanged.
No model is asked. The helper types no other command. The machine
reasons a request is refused for (no shim, OS, missing, off) refuse the
read the same way. Turned off, -p runs it as before.
Run (mote, at this tree on origin/main
|
||
|
|
a25d3d0815 |
claude: a JSON schema is answered in the interactive mode, through an answer tool
With the interactive mode on, a request with a JSON schema was refused
with a 400 since v0.1.2592: interactive Claude Code takes --json-schema and does nothing
with it, its StructuredOutput tool being -p's alone. It now runs in the
interactive mode like any other request.
- serveClaudeSubscription compiles the schema (santhosh-tekuri/jsonschema
v6.0.3, draft-07 unless it says otherwise, as -p reads one; a $ref
outside the schema is refused, never fetched) and adds an answer tool,
StructuredOutput or a numbered name apart from the client's tools, with
the schema as its input schema, through the bridge's MCP server. A
schema that can't be compiled is a 400 before any run.
- mcpCall checks each call against the schema: one that doesn't fit is
told why (isError) to be made again, as -p's is; one that fits is kept.
- At the turn's result the kept input is the reply's structured output.
A turn that ended with no call is told once to call the tool, and
fails "no answer fitting the schema" if it still doesn't. Neither the
call nor the words around it reach the client.
- claudePrint no longer lists the schema. The two refusal tests
(TestClaudeTUIOnRefusesPrint, TestClaudeTUIRefusalIsNoAccountsFault)
now use the case that is still refused before any run: an image by
its URL that can't be downloaded (127.0.0.1, which magpie never
fetches).
- The provider editor's card no longer says -p takes "a JSON schema"
the interactive mode can't (en, zh-CN, zh-TW, ja, de).
- docs/subsystems/claude-subscription-bridge.md: the refusal list, and
how a schema is answered.
Run:
- A real run, haiku, the test account in a sandbox HOME, real Claude
Code 2.1.316 through the helper with --json-schema and a stdio MCP
server named magpie serving the answer tool and its description: the
result's structured_output was null (the premise), and the model
called mcp__magpie__StructuredOutput at once with
{"color":"Sky blue","hex":"#87CEEB"}, which fits the schema's
pattern. 7.2s, one turn. Not run: the whole gateway path with a real
account (the unit tests drive it with Claude Code's real transcript
rows).
- mote, at this tree (base
|
||
|
|
14e3513780 |
claude: Claude Code in WSL runs interactively when Windows can't read its transcripts
With the interactive mode on, Claude Code in WSL was refused with a 502
in two cases: the distro user's own folder unreadable from Windows
(\\wsl$ needs the 9P redirector, which a session over ssh hasn't;
"wslread") and a distro whose home the probe didn't find ("wsl-home").
Both now run interactively: the helper reads the transcript inside the
distro.
- claudetui/wslread.go: before Claude Code starts, a shell run through
wsl.exe notes how much of $HOME/.claude/projects/*/<sid>.jsonl is
there (a resumed session's earlier turns), says "ready", then tail -F's
the rest; the helper copies it to a file of its own and tails that as
any transcript. When Claude Code ends it waits for the copy to stop
growing (settle), then closes the shell's stdin, which ends it.
- claudetui.WSL gets Distro (Projects omitempty); the gateway's tuiWSL
sets it when Windows can't read the folder or the home is unknown.
- the wslread and wsl-home refusals are gone (claudeTUI, claudeWhy,
claudeNotTUIWhy); the GUI's "wsl-home" reason and its 4 strings too.
- docs/subsystems/claude-subscription-bridge.md says how it is read.
Run, at origin/main
|
||
|
|
59fdab0af7 |
gateway: a caller's folder the user hasn't trusted runs in magpie's, not a 502 (lwjef on X)
lwjef (X, 2116867007799030000): a cwd Claude Code hasn't trusted hangs the interactive-mode bridge (paseo chat). Cause: in the user's own account the helper leaves the trust question to the user (no MAGPIE_CLAUDE_TUI_TRUST) and ends at once saying so. Up to 11-01 that run became -p; since |
||
|
|
bee3ea6753 |
claudetui: the first message waits for Claude Code to list magpie's tools (MinhuWang on X)
MinhuWang (X, 2116836405548916907): in the interactive mode the first
message can go before MCP has loaded, and then has none of pi's tools.
Cause: the helper's ready() took the drawn "❯ " prompt as ready. Claude
Code connects its MCP servers beside the prompt, so a message pasted at
once was answered with no mcp__magpie__ tools. Reproduced with the real
Claude Code 2.1.309 (sandbox HOME, a copy of the owner's account): an MCP
server held 8s before answering initialize got "NOTOOL" for "what is the
secret word, use your tool".
Fix: startRun gives claude-mcp-helper a third argument, a `listed` file in
the run's temp folder, which RunMCP writes after it has answered
tools/list. The helper finds that path in the run's --mcp-config
(mcpListed) and ready() waits for it as well as the prompt, inside the
same ReadyWait (45s); past it the run ends saying the tools weren't
listed. Runs without that server (warm-up, model test) don't wait.
Run (mote, at this tree):
- go test ./internal/claudetui ./internal/claudebridge: ok
- go test -run 'Claude|MCP|Bridge' ./internal/gateway: ok
- real Claude Code 2.1.309 here, a sandbox HOME with a copy of the
account's credentials, the new helper and the real claude-mcp-helper
behind an 8s sleep: initialize answered at 12.7s, the first turn called
mcp__magpie__pi_secret and answered "The secret word is PELICAN".
Without the sleep: answered at 2.1s, same answer. 2.1.309 sends
server/discover before initialize; the helper's method-not-found answer
is taken and initialize follows.
Broken by hand: toolsListed returning true made
TestShimFirstMessageWaitsForTools red ("echo: hello (without magpie's
tools)"); RunMCP not writing the file made TestToolsListedFileWritten
red.
Not tried: Claude Code in WSL (the path is the gateway's Windows temp
path, handed to magpie.exe as the callback path is); a Claude Code that
lists tools only on its first request (2.1.309 lists them at start),
which would now wait 45s and fail saying so instead of answering
without tools; the full gateway suite (run after the next commits).
|
||
|
|
37d7913c20 |
claude: the interactive mode is given an earlier conversation as a transcript
A conversation no run has (a run lost to an update, a client's own history) was told to a new Claude Code in its interactive mode as one first message, pasted. #4778's 229 messages and 3 images that way were refused; #4780's 56 messages and 25 images were pasted one by one until the paste timed out, and the request got a 502 or an empty reply. Now, when the conversation has a reply that calls no tool, replaySession writes it as Claude Code's own transcript: a session file in the project folder Claude Code reads, a user line holding the conversation before that reply (as renderClaudePrompt tells it, images as image blocks, client cache marks out) and an assistant line holding the reply's words. The run starts with --resume on it, as a saved session's run does, and is typed only the turns after the reply. If Claude Code can't go on from it, start tries once more told whole (req.told). -p (interactive mode off), WSL (no session folder) and a conversation with no such reply are told whole as before. The file goes in the folder of the work path with its links followed: the first try wrote it beside the unresolved /var/folders path on a Mac, and the replay test was red on mote for it. Real run (this Mac, sandbox HOME and CLAUDE_CONFIG_DIR, one of the owner's real Claude accounts by CLAUDE_CODE_OAUTH_TOKEN, real Claude Code 2.1.316 through magpie claude-tui-helper, -p stream-json in, the interactive mode under it, --model haiku): the transcript was made by replaySession itself (a throwaway test on mote, not committed) from 6 earlier messages with 3 images (red, blue, green 64x64 PNGs) and a 455KB file whose line 004321 names a fruit, 464,798 bytes; the work folder was reached through a symlink. Typed only "Name the colours of images A, B and C, and the secret fruit named in line 004321 of the file. One line." Answer in 8.4s: "A: red, B: blue, C: green; secret fruit in line 004321: PAPAYA." Claude Code appended to the same session file (504,788 bytes after). Run (mote, at this tree, rebased on |
||
|
|
949000a36a |
claude: a request the interactive mode refuses is a 400 no account rests for
A request Claude Code's interactive mode can't take (a JSON schema, a branch of a -p run's session, WSL Claude Code whose home wasn't found) was refused with a 502. The fallback asked every account of the subscription in turn and rested some for it: #4778 saw 15 tries across 3 accounts. The refusal is the same on every account, so it is now a 400 (tuiRefusal), which the fallback neither retries nor rests an account for. The message is reworded so that "Models" no longer stands just before the error's "invalid_request_error": "Settings › Models › Replies runs every request as -p\",\"type\":\"invalid_request_error" matched provider.ModelUnserved, which made the 400 retryable again. Run (mote, at this tree): go vet ./internal/gateway, GOOS=windows and GOOS=linux -tags nogui go vet; go test -run "TUI|Claude|Resume|Interactive|Refusal|Fallback" ./internal/gateway ok. gofmt -l clean. Broken by hand: with the 400 mapping taken out, TestClaudeTUIRefusalIsNoAccountsFault is red (502); with the old wording it was red on WSL (retryable true through ModelUnserved). Not tried: a refusal against real accounts. Not changed: a run that starts and fails (tuiNoStart) is still a 502, retried on the next account. Part of #4778. |
||
|
|
049848c5ed |
claude: a branch of a -p run's session goes to the interactive mode, told whole
With the interactive mode on, tool results another request answered
first for a run made as claude -p (before the mode was turned on) were
refused with a 502 (claudePrint's "branch"): the branch would have gone
on as -p. It now starts a new interactive Claude Code told the whole
conversation (startRun): -p's prompt isn't the interactive mode's, so
the cache has nothing of the -p session to read either way, and nothing
runs as -p while the mode is on. This is the second refusal behind
@crosscn's 502 on an old conversation (X, 11-01); the first, words over
400KB, went in v0.1.2614.
- startRun drops such a branch (from and req.branch nil) and logs it;
- the "branch" entry in claudePrint is gone;
- docs/subsystems/claude-subscription-bridge.md says so.
Test: TestClaudeTUIBranchOfPrintRunIsToldWhole (a -p run's saved
session given as the branch: the run is interactive, has no --resume,
and is told the first words too; req.branch is cleared).
Run on mote (go1.26.8), at origin/main
|
||
|
|
2b52302dcb |
claude: the interactive mode takes a first message of any length
@crosscn on X (11-01): after the upgrade made the interactive mode the default, a week-old conversation (a DeepSeek harness on a Claude model) got a 502, and worked again only with -p turned back on. A conversation told whole to a new interactive Claude Code is its first message, and words over 400KB were refused (claudePrint's "big", tuiPromptMost). The bound was never tried: the commit that set it lists "a ~400KB paste" under Not tried. Tried on real Claude Code 2.1.316 in a sandbox HOME, haiku: a 3MB bracketed paste showed "[Pasted text #1 +46154 lines]" after 35s; a 500KB one was sent, its transcript holds every line and the question, and the model answered it (184,168 tokens written to the cache). - tuiPromptMost and the "big" refusal are gone; claudeTUI, claudePrint, claudePrintWhy and claudeNotTUIWhy no longer take the prompt, which only that bound read. - the helper waits for a paste to show a second per 64KB longer than pasteWait (shownWait): 10s alone would press Enter while a 3MB paste was still being taken in. - the editor's tooltip says -p takes what the interactive mode can't "yet": a JSON schema (en, zh, zh-TW, ja, de). - docs/subsystems/claude-subscription-bridge.md says so. Tests: TestClaudeTUIBigFirstMessage (a ~1.1MB first message runs through the helper, 200), TestShownWaitGrowsWithThePaste; TestClaudeTUIOnRefusesPrint refuses a JSON schema now; TestClaudeTUIChosen's long-message row runs interactively. Run on mote (go1.26.8): - full go test ./internal/gateway ./internal/claudetui (-timeout 45m) at |
||
|
|
15b035eef0 |
claude: the interactive mode takes an image known by its URL
The interactive mode is pasted files, so an image a client names by its
URL alone made the run fall to the refusal list ("image"), which with
the TUI on means a 502. Now serveSubscription downloads each such image
first (fetchURLImages): from public addresses only (publicClient, the
same fetch the other providers use), checked to be an image by its
bytes, and kept by URL (32 of them) so a conversation that hands the
same URLs over each turn downloads each once. One that can't be had
fails the request with a 400 naming the URL and why; nothing of a
non-image's content is echoed. claudePrint's "image" entry stays as a
backstop, unreachable with the mode on.
The provider editor's tooltip for claude -p no longer lists the image
among what the interactive mode can't take (en, zh, zh-TW, ja, de), and
the bridge's subsystem page says how the image is fetched.
Run (mote, at this tree on
|
||
|
|
7d1f2ecba3 |
claudecode: magpie keeps the Claude Code it downloaded at the newest release
alextjy on Discord runs magpie in Docker with Claude Code from `magpie claude-code install`, and asked whether a magpie update touches it and how it updates. The download lives in <cache>/claude-code (/config/cache, on the volume), so a new image keeps it. But nothing ever updated it: every run magpie starts sets DISABLE_AUTOUPDATER, so it stayed at the version first installed until the user ran install again. claudecode.KeepCurrent now runs while magpie serves (a WhileServing loop): a minute after start and every six hours it asks downloads.claude.ai for the latest release and downloads a newer one, checked against the manifest's SHA-256 and size as install does. The version it replaced is removed on the next look rather than at once, since a run being started may hold its path (Install, the CLI's, still removes it at once; a folder with a .part download in it is left alone). It does nothing when magpie downloaded none, when the machine has its own `claude` (that one is run and updates itself), or when DISABLE_AUTOUPDATER is set for magpie, Claude Code's own way to hold a version. A failed look keeps the download and is logged. It never downgrades. The status line of `magpie claude-code`, the Docker docs (en, zh, ja) and the bridge's subsystem page say so. Run: - wsl-run (Ubuntu 24.04, Go 1.26.8): go vet, then go test -race -v ./internal/claudecode/ -run 'Keep|Install|Find': all pass. - Broken by hand on WSL, each red: no newer() check (UpdatesMagpiesDownload, LeavesWhatIsntMagpiesToUpdate), no own() check (the_machine's_own), pruning at install (UpdatesMagpiesDownload), no prune on the next look (UpdatesMagpiesDownload). - Real use on WSL, sandbox HOME and XDG_CACHE_HOME: a throwaway program with a fake 2.1.1 download ran KeepCurrent against the real downloads.claude.ai. After 1m34s it logged "updated from 2.1.1 to 2.1.316", the kept binary's --version said "2.1.316 (Claude Code)", 2.1.1 was still there for the next look, and the loop ended with its context. - mote, at this tree: GOOS=windows and GOOS=linux go vet -tags nogui of both packages, go vet ./internal/claudecode/, go build ., then go test -tags nogui ./internal/claudecode/ ./internal/cli/ -timeout 45m: VET-OK; claudecode ok 0.680s, cli ok 56.673s. - gofmt -l clean. Not tried: the Docker image itself (no docker on the test boxes), and a Windows run whose replaced binary is still in use (prune leaves what it can't remove for the next look). Full suite not run: the change is the claudecode package, one WhileServing line and one CLI status line. A WSL run of ./internal/cli/ at the default 10m timeout timed out while the box ran other sessions' full suites; the 45m run above replaces it. |