Files
magpie/docs
yetone 1f03d75462 claude bridge: a caller on another computer naming no folder is told the tools run elsewhere
packinggoods on Discord: magpie on a Windows machine, the agent on a Mac.
Every shell command came wrapped in PowerShell. The model's prompt held
Claude Code's own environment section from the bridge's run: "Primary
working directory: C:\Users\...\Temp\magpie-claude-work, Platform: win32,
Shell: PowerShell". That describes the gateway, and no tool of the run
runs there: every tool is the caller's.

Claude Code has no option to leave that section out. With the real
claude 2.1.312 against a capture server (sandbox HOME, fake key), it is a
<system-reminder> in the run's first message, before magpie's text, with
the default prompt and with --system-prompt-file alike; the SDK's
excludeDynamicSections only moves it there. claude.exe on xiaomi-gpu gives
the same section with the Windows platform, temp folder and OS version.

13f9c7fca already told a run that the caller's environment wins, but only
when the caller's instructions name a folder in a form clientNamedWorkDir
reads, and never a lean run. Now:
- serveSubscription marks a request not from this computer
  (Request.remoteCaller = !local(r)). A run in magpie's folder for such a
  caller that names no folder (envUnknown) gets envUnknownNote after its
  instructions: the environment given elsewhere is not where the tools
  run, so no platform, shell or path is taken from it. A caller with no
  system prompt gets the instructions block for the note alone.
- a lean run gets the note in its system prompt (leanSystem), the named-
  folder one worded envElsewhereLeanNote since the environment comes after
  it there. startRun now picks the folder before writing system.md.
- A caller on this computer that names no folder, a run in the caller's
  own folder, and a named-folder caller in the non-lean run are told what
  they were before, so their cached prompts are unchanged.
The notes name no app and no vendor. Nothing else of the request changes:
no flag, header, env or Claude Code prompt text. Gateway facts beyond the
environment section don't reach the prompt: --setting-sources "" (no
CLAUDE.md), CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 and
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS=1 were already set.

Tests: TestClaudeRemoteCallerNamingNoFolderIsToldToolsAreElsewhere (IPv4
and IPv6 remote, with and without a system prompt, loopback, remote
naming a folder) and TestClaudeLeanPromptSaysWhereToolsRun. Both are red
on origin/main's claude_subscription.go and ir.go (0 of 2 runs told; lean
system prompt "Rules."). TestClaudeLeanPromptIsTheRunsSystemPrompt and
TestClaudeClientCacheAbsentUnchanged now send from loopback, which they
were about all along (httptest's address is another computer's).

Run (mote-run): go test ./internal/gateway -run
'Claude|Bridge|Subscription|Lean|Prompt|WorkDir|Resume' ok;
go test -timeout 45m ./internal/gateway: ok (532s); go vet ./internal/gateway
for darwin, linux (-tags nogui) and windows ok; gofmt -l clean. win-run on
xiaomi-gpu: the touched tests ok (the script-driven ones skip on Windows).
Real claude 2.1.312 fed the new first message: the note follows the
environment reminder inside external_system_instructions.
Not tried: a real model turn from a Mac client through a Windows
gateway, so whether the model now stops wrapping commands in PowerShell
is not measured; packinggoods's client and magpie version are not known.
2026-10-30 01:23:03 +08:00
..