Uh oh!
There was an error while loading. Please reload this page.
feat: add --model flag and preferences file for LLM model override - #2543
Merged
Conversation
Adds --model / -m CLI flag to override the agent's default LLM model:
spawn codex gcp --model openai/gpt-5.3-codex
Also supports persistent per-agent model preferences via config file at
~/.config/spawn/preferences.json:
{ "models": { "codex": "openai/gpt-5.3-codex" } }
Priority: --model flag > preferences file > agent default.
This enables a future web UI to pass model selection via CLI args when
invoking spawn programmatically to provision machines.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>louisgv
approved these changes
Mar 12, 2026
louisgv
left a comment
Collaborator
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: 9ad5a56
Findings
No security issues found. All inputs are properly validated and sanitized.
Security Analysis
Command Injection Protection: ✅ SECURE
- Model ID from --model flag is validated via
validateModelId()with strict regex:/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*\/[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/ - Prevents shell metacharacters and command injection
- Test coverage: packages/cli/src/tests/orchestrate.test.ts:363
- Model ID from --model flag is validated via
Path Traversal Protection: ✅ SECURE
- Preferences file path is hardcoded via
getSpawnPreferencesPath() - Uses
join(getUserHome(), ".config", "spawn", "preferences.json") - No user input in path construction
- Preferences file path is hardcoded via
JSON Parsing Safety: ✅ SECURE
- Uses
tryCatchIf(isFileError, ...)for error handling - Valibot schema validation prevents malformed data
- Returns null on parse failure (fail-safe)
- Uses
Preferences File Injection: ✅ SECURE
- Even if attacker modifies preferences.json, model ID still goes through
validateModelId() - Priority order (flag > preferences > default) is secure
- Even if attacker modifies preferences.json, model ID still goes through
Tests
- bun test: ✅ PASS (1380/1380 tests passing)
- biome lint: ✅ PASS (0 errors)
- bash -n: N/A (no shell scripts modified)
Code Quality
- Version bump: ✅ 0.16.19 → 0.17.0 (minor - new feature)
- Help text updated: ✅
- Flag registration: ✅ Added to KNOWN_FLAGS
- Type safety: ✅ Uses valibot schema validation
-- security/pr-reviewer
Uh oh!
There was an error while loading. Please reload this page.
AhmedTMM added a commit
to AhmedTMM/spawn
that referenced
this pull request
Mar 13, 2026
…penRouterLabs#2543) Adds --model / -m CLI flag to override the agent's default LLM model: spawn codex gcp --model openai/gpt-5.3-codex Also supports persistent per-agent model preferences via config file at ~/.config/spawn/preferences.json: { "models": { "codex": "openai/gpt-5.3-codex" } } Priority: --model flag > preferences file > agent default. This enables a future web UI to pass model selection via CLI args when invoking spawn programmatically to provision machines. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
5 tasks
AhmedTMM added a commit
to AhmedTMM/spawn
that referenced
this pull request
Mar 13, 2026
…penRouterLabs#2543) Adds --model / -m CLI flag to override the agent's default LLM model: spawn codex gcp --model openai/gpt-5.3-codex Also supports persistent per-agent model preferences via config file at ~/.config/spawn/preferences.json: { "models": { "codex": "openai/gpt-5.3-codex" } } Priority: --model flag > preferences file > agent default. This enables a future web UI to pass model selection via CLI args when invoking spawn programmatically to provision machines. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
2 tasks
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 freeto 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.
Summary
--model/-mCLI flag to override the agent's default LLM model~/.config/spawn/preferences.json--modelflag > preferences file > agent hardcoded defaultUsage
Context
The long-term plan is for a web UI to invoke
spawncommands programmatically to provision cloud machines. The--modelflag enables the web UI to pass model selection as a CLI arg (along with--headless --output json).The preferences file supports setups like GitHub/Telegram/WhatsApp integrations where the config is written once and reused across invocations.
Files changed
packages/cli/src/flags.ts— added--model,-mto known flagspackages/cli/src/index.ts— extract--modelflag, setMODEL_IDenv varpackages/cli/src/commands/help.ts— added to usage, examples, and env vars sectionspackages/cli/src/shared/orchestrate.ts— load model from preferences file, updated priority orderpackages/cli/src/shared/paths.ts— addedgetSpawnPreferencesPath()packages/cli/package.json— version bump to 0.17.0Test plan
bunx @biomejs/biome check— 0 errorsbun test— 1380 tests pass🤖 Generated with Claude Code