Skip to content

fix(cli): make configure inputs a typed request so first-run setup can't crash#94

Merged
elyasmnvidian merged 1 commit into
mainfrom
emehtabuddin/sygh-6-bug-first-run-launcher-setup-crashes-before-configuration
Jul 20, 2026
Merged

fix(cli): make configure inputs a typed request so first-run setup can't crash#94
elyasmnvidian merged 1 commit into
mainfrom
emehtabuddin/sygh-6-bug-first-run-launcher-setup-crashes-before-configuration

Conversation

@elyasmnvidian

@elyasmnvidian elyasmnvidian commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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:

Switchyard is missing claude launch defaults. Starting setup.
AttributeError: 'Namespace' object has no attribute 'disable_skill_distillation'

Why it happened

cmd_configure (the code behind switchyard configure) read its inputs straight off an argparse Namespace. Two callers built that namespace: the configure CLI 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_configure a real type. A new ConfigureRequest dataclass lists every field the command reads and its default, in one place. Both callers build that same type:

  • the configure command via ConfigureRequest.from_namespace(args) (the one spot that touches the raw argparse namespace),
  • launch setup via the constructor, passing only the handful of fields it knows and letting the rest take their defaults.

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

  • New switchyard/cli/configure_request.py — the ConfigureRequest dataclass and its from_namespace builder.
  • cmd_configure and its helpers take ConfigureRequest instead of a bare namespace.
  • Launch setup builds a ConfigureRequest instead of a hand-rolled namespace.
  • switchyard configure behavior is unchanged.

Test

The old setup test replaced cmd_configure with a stub, so it never noticed the missing fields — that's how the crash shipped. Now test_configure_parser_builds_a_complete_request runs a real configure parse through from_namespace and 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 (--reconfigure forces 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-discovery

Before (fix reverted):

Switchyard is missing claude launch defaults. Starting setup.
AttributeError: 'Namespace' object has no attribute 'disable_skill_distillation'

After:

Switchyard is missing claude launch defaults. Starting setup.
Saved Switchyard config to <cfg>/config.json
Saved Switchyard credentials to <cfg>/credentials.json
  switchyard  ready  →  azure/anthropic/claude-haiku-4-5
  ...
  READY
  requests : 1
  tokens   : 80,072 in  5 out

Setup finishes, writes the config and credentials, the proxy starts, and one claude turn 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 separate credentials.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.

@elyasmnvidian
elyasmnvidian requested a review from a team as a code owner July 20, 2026 16:08
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

First-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.

Changes

Launch bootstrap configuration

Layer / File(s) Summary
Bootstrap fields and regression coverage
switchyard/cli/launch_command.py, tests/test_launch_claude.py
The bootstrap namespace now includes routing-profile and skill-distillation values, while the launch test validates the corresponding helper calls and defaults.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit hops through setup’s gate,
No missing fields to make it wait.
Profiles rest and skills stay still,
The launch now climbs the config hill.
“Bootstrap bright!” the bunny sings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change adds the missing bootstrap fields and regression coverage needed to prevent the first-run AttributeError in #60.
Out of Scope Changes check ✅ Passed The added fields and test updates are directly tied to the launcher bootstrap crash and stay within the issue scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: typed first-run configure inputs to prevent launch bootstrap crashes.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8b8dad8 and a61f93a.

📒 Files selected for processing (2)
  • switchyard/cli/launch_command.py
  • tests/test_launch_claude.py

Comment thread tests/test_launch_claude.py Outdated
@elyasmnvidian elyasmnvidian changed the title fix(cli): stop first-run launch setup crashing before it saves defaults fix(cli): first-time launch no longer crashes during setup Jul 20, 2026
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/sygh-6-bug-first-run-launcher-setup-crashes-before-configuration branch 2 times, most recently from cfd120a to 00fdad1 Compare July 20, 2026 19:28
@elyasmnvidian elyasmnvidian changed the title fix(cli): first-time launch no longer crashes during setup fix(cli): make configure inputs a typed request so first-run setup can't crash Jul 20, 2026
@elyasmnvidian

Copy link
Copy Markdown
Contributor Author

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):

  • Before (origin/main, without this commit): 1996 passed, 2 failed
  • After (this branch): 1997 passed, 2 failed

The two failures are identical on both branches, so they're pre-existing and unrelated to this change: a flaky routing e2e test (test_evict_reroute_e2e) and a verify test that picks up a real secrets file on this box (test_verify…secrets_file_wins). The one extra pass on this branch is the new regression test that runs a real configure parse through ConfigureRequest.from_namespace. Every test that was green before is still green.

Live runs with real tokens (model azure/anthropic/claude-haiku-4-5, one headless claude turn each):

  1. First-run setup — the path this fix actually changes. Fresh config dir, --reconfigure forces setup:
Switchyard is missing claude launch defaults. Starting setup.
Saved Switchyard config to <cfg>/config.json
Saved Switchyard credentials to <cfg>/credentials.json
  switchyard  ready  →  azure/anthropic/claude-haiku-4-5
  ALPHA
  requests : 1
  tokens   : 52,039 in  5 out

Setup finishes, writes the config and credentials, the proxy starts, and the model replies for real.

  1. Normal launch with credentials on the command line (setup is skipped) — confirms the common path still works:
  switchyard  ready  →  azure/anthropic/claude-haiku-4-5
  BRAVO
  requests : 1
  tokens   : 89,587 in  6 out

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>
@elyasmnvidian
elyasmnvidian force-pushed the emehtabuddin/sygh-6-bug-first-run-launcher-setup-crashes-before-configuration branch from 00fdad1 to 20afd35 Compare July 20, 2026 21:49
@elyasmnvidian
elyasmnvidian merged commit 932a938 into main Jul 20, 2026
16 of 17 checks passed
@elyasmnvidian
elyasmnvidian deleted the emehtabuddin/sygh-6-bug-first-run-launcher-setup-crashes-before-configuration branch July 20, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] First-run launcher setup crashes before configuration

2 participants