fix(cli): make configure inputs a typed request so first-run setup can't crash#94
Conversation
WalkthroughFirst-run launch bootstrap now initializes the routing-profile and skill-distillation fields expected by interactive configuration. A regression test verifies these fields and the related helper behavior. ChangesLaunch bootstrap configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_launch_claude.py`:
- Around line 115-129: Extend the bootstrap namespace assertions in the launch
regression test to directly validate routing_profiles, skill_distillation, and
disable_skill_distillation on configure_args. Keep the existing helper
assertions, and assert each field has the expected default value consumed by
cmd_configure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: bc4b681e-cc3c-44ad-b6c5-79f8e2348060
📒 Files selected for processing (2)
switchyard/cli/launch_command.pytests/test_launch_claude.py
cfd120a to
00fdad1
Compare
|
Tested this before and after the change — nothing regressed. Full unit suite, before vs after (same machine and env, run separately so they don't contend for sockets):
The two failures are identical on both branches, so they're pre-existing and unrelated to this change: a flaky routing e2e test ( Live runs with real tokens (model
Setup finishes, writes the config and credentials, the proxy starts, and the model replies for real.
Both round-tripped real tokens through the gateway and returned the exact one-word reply asked for. |
…n't crash Signed-off-by: Elyas Mehtabuddin <emehtabuddin@nvidia.com>
00fdad1 to
20afd35
Compare
The first time you run
switchyard launch claude(or codex/openclaw) without a saved setup, it runs a one-time setup: it asks for your provider, model, and API key and writes them to a config file so later launches don't need those flags. That setup crashed before it could write anything:Why it happened
cmd_configure(the code behindswitchyard configure) read its inputs straight off an argparseNamespace. Two callers built that namespace: theconfigureCLI command (argparse fills every field), and launch setup, which hand-built a namespace with ~30 fields. The two drifted — launch setup was missing three fields the command reads, so the command hit a missing attribute and stopped.The fix
Give
cmd_configurea real type. A newConfigureRequestdataclass lists every field the command reads and its default, in one place. Both callers build that same type:configurecommand viaConfigureRequest.from_namespace(args)(the one spot that touches the raw argparse namespace),Now a caller can't leave out a field the command needs — a missing or misspelled field is a mypy error or fails right where it's built, instead of crashing mid-launch. The change also lets us drop ~11 defensive
getattr(args, ...)reads and 15 dead fields that launch setup was setting for no reason.What changed
switchyard/cli/configure_request.py— theConfigureRequestdataclass and itsfrom_namespacebuilder.cmd_configureand its helpers takeConfigureRequestinstead of a bare namespace.ConfigureRequestinstead of a hand-rolled namespace.switchyard configurebehavior is unchanged.Test
The old setup test replaced
cmd_configurewith a stub, so it never noticed the missing fields — that's how the crash shipped. Nowtest_configure_parser_builds_a_complete_requestruns a realconfigureparse throughfrom_namespaceand checks the field that crashed is present, and the bootstrap test asserts the request setup builds works with the real configure helpers.Live run — NVIDIA Inference Hub, real tokens
Real setup path with a fresh config dir (
--reconfigureforces setup):switchyard launch claude --reconfigure --model azure/anthropic/claude-haiku-4-5 --base-url https://inference-api.nvidia.com/v1 --api-key $NVIDIA_API_KEY --no-tui --no-model-discoveryBefore (fix reverted):
After:
Setup finishes, writes the config and credentials, the proxy starts, and one
claudeturn reaches the model through the NVIDIA gateway for a real reply (80,072 in / 5 out).Saved
config.json(the API key goes to a separatecredentials.json):{ "default_provider": "nvidia", "launch": { "claude": { "model": "azure/anthropic/claude-haiku-4-5", "route": {"model": "azure/anthropic/claude-haiku-4-5", "type": "single"} } }, "providers": {"nvidia": {"base_url": "https://inference-api.nvidia.com/v1"}} }Fixes #60.