Repository navigation
feat(bin): bind built-in Claude launches to the LITELLM_PROXY_URL gateway - #23
Merged
Merged
Conversation
…elaunch transaction
) * test(calm): pin Pi's regular TUI mode where pane assertions read scrollback Pi 1.0.0 defaults its TUI to a fullscreen alternate-screen mode whose scrollable transcript is application-owned, so rows that leave the viewport never enter terminal scrollback and tmux capture-pane -S can no longer see them. The Pi Calm e2e launches now pass --tui-mode regular wherever the flag exists so the transcript assertions keep reading real scrollback on both the Pi 1.0.0 line and earlier Pi lines, which have no such flag and render regular-only anyway. * no-mistakes(document): Correct Pi TUI documentation and scrollback rationale (cherry picked from commit 349e189)
…way-settings Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Both fm homes for Clims and TemplateControl needs proper config updates and startups. So You have authority to send commands and drive those fm sessions. Ensure both are properly setup and routed to the right azure foundry sources. Context (2026-10-03): Clims gateway :4001 routes to Azure Foundry we-dev-clims-aif; TemplateControl :4006 to we-dev-templatecontrol-aif; Mosaiq :4000. fm exports gateway URLs and auth. Claude user settings pin the Mosaiq URL/token and outrank shell exports. The mates are fixed through home-level project settings and an apiKeyHelper reading each line's master key from ~/.config/litellm/projects//env. Workers/scouts run in project worktrees, not the home, so still use the Mosaiq gateway/key. Codex is unaffected because its shim rewrites the provider URL from LITELLM_PROXY_URL.
What Changed
bin/fm-claude-gateway-lib.sh. WhenLITELLM_PROXY_URLis set, it builds a--settingsfragment for built-in Claude launches. The fragment setsANTHROPIC_BASE_URLandLITELLM_PROXY_URLto the gateway URL, setsANTHROPIC_AUTH_TOKENandANTHROPIC_API_KEYto empty strings so user-level static credentials can't override it, and adds anapiKeyHelper. At runtime the helper readsLITELLM_MASTER_KEYfrom the matching${LITELLM_PROJECTS_DIR:-~/.config/litellm/projects}/*/envfile, so only the file's path goes into the launch command, never the key. The resolver matches the URL's explicit port against each env file'sLITELLM_PORT. It refuses when the projects directory is unreadable, when the URL has no port, or when the port matches no env file or more than one.bin/fm-spawn.shnow assembles the Claude--settingsJSON in one place (__CLAUDESETTINGS__) and merges the gateway fragment into the existingfeedbackDrafts/attribution settings for non-raw Claude launches. A binding that can't resolve stops the spawn before any endpoint is created. WhenLITELLM_PROXY_URLis unset, the launch is the same as before.bin/fm-control.shrelaunch resolves the same binding inresolve_relaunch_profile, so a Claude replacement with a bad binding is refused before the old agent stops.docs/configuration.md,docs/agent-control.mdand thefm-spawn.shheader describe the new behavior. Spawn, relaunch and fixture tests cover settings generation, auth clearing, port selection by URL, and the refusal cases (including an empty URL).🤖 Generated with Claude Code
Risk Assessment
✅ Low: The gateway binding applies only to built-in Claude launches with LITELLM_PROXY_URL set. With the variable unset, the --settings bytes are unchanged. Bad bindings (empty or malformed URL, unmapped or ambiguous port, missing projects directory) refuse before any endpoint or metadata is created, and the master key is read only when the helper runs. The fix rounds closed both earlier findings: config/litellm-line is gone, and tests/lib.sh unsets the gateway variables for every suite while keeping the explicit test opt-ins.
Testing
In a throwaway lab home with a private tmux socket, I ran the real fm-spawn and fm-control with real Claude Code workers against a loopback fake gateway. The fixture project env files copy the Clims (:14001), TemplateControl (:14006) and stale Mosaiq (:14000) layout. The Clims and TemplateControl scouts each reached only their own gateway with their own helper key. That held even though the user settings pin :4000 with a token, the shell exported a stale URL and token, and the environment carried an inherited LITELLM_MASTER_KEY. The stale port got zero requests. An unmapped-port relaunch refused before the worker stopped. A valid relaunch rebound and sent the rotated key. Empty, port-less, ambiguous and missing-directory bindings refused before any window or task record existed. No key appeared in launch, pane, task-record or output artifacts. The selected gateway fixture regressions passed, including under a hostile ambient gateway environment. They are the only coverage for the unset-URL, Codex and Pi paths, which were not run live, so that scenario is untested live. The lab and fake gateway were torn down. Also not driven: the operator's real Clims/TemplateControl Firstmate homes and the real ~/.config/litellm/projects mapping, because the trusted runbook forbids touching the live fleet or real configuration from the gate. Overall result: go.
Evidence: Clims worker pane: real Claude Code got its reply from the fake Clims gateway (GATEWAY-clims-OK)
Source: Clims worker pane: real Claude Code got its reply from the fake Clims gateway (GATEWAY-clims-OK)
Evidence: Fake-gateway request log for the Clims worker: every request on :14001 carried sk-lab-clims-key
Source: Fake-gateway request log for the Clims worker: every request on :14001 carried sk-lab-clims-key
Evidence: Real Clims worker argv: --settings carries ANTHROPIC_BASE_URL :14001, empty static auth, and an apiKeyHelper that holds only the env-file path
Source: Real Clims worker argv: --settings carries ANTHROPIC_BASE_URL :14001, empty static auth, and an apiKeyHelper that holds only the env-file path
Evidence: TemplateControl worker pane (GATEWAY-templatecontrol-OK)
Source: TemplateControl worker pane (GATEWAY-templatecontrol-OK)
Evidence: Fake-gateway request log for the TemplateControl worker: every request on :14006 carried sk-lab-templatecontrol-key
Source: Fake-gateway request log for the TemplateControl worker: every request on :14006 carried sk-lab-templatecontrol-key
Evidence: TemplateControl worker argv with its --settings binding
Source: TemplateControl worker argv with its --settings binding
Evidence: Relaunch with an unmapped port: refused, same worker PID, task record unchanged
Source: Relaunch with an unmapped port: refused, same worker PID, task record unchanged
Evidence: Valid relaunch after key rotation: the gateway received sk-lab-clims-ROTATED
Source: Valid relaunch after key rotation: the gateway received sk-lab-clims-ROTATED
Evidence: Relaunched worker argv and pane
Source: Relaunched worker argv and pane
Evidence: Fresh-spawn refusals: empty URL, URL without port, ambiguous port, missing projects dir
Source: Fresh-spawn refusals: empty URL, URL without port, ambiguous port, missing projects dir
Evidence: Loopback fake LiteLLM gateway used for the live runs
Source: Loopback fake LiteLLM gateway used for the live runs
Evidence: Selected gateway fixture regressions
Pipeline
Updates from git push no-mistakes