fix(shared): give custom agents on a known CLI that CLI's model picker
What & why
A custom agent whose command is a CLI Paradev already knows — e.g. an OpenCode agent pinned to another provider (opencode --model venice/z-ai-glm-5-3) — is stored with presetId: "custom". resolveAgentLaunchPresetId only special-cased omp, so these agents:
- show a single Default row in the new-workspace model picker, and
- can't take a model override at launch (
validateAgentModelSelection/buildAgentModelArgssee an unknown preset).
This resolves a custom / custom:* agent to the preset matching its executable (basename, .exe stripped) when that preset has model support with a real model flag. OpenCode-based custom agents then get the live opencode acp model discovery (every provider the user has authed), and the CLI's --model flag at launch. Builtin presets and custom agents on unknown CLIs are unchanged; polygraph (whose "model" flag is --agent) is excluded.
How I tested it
- New cases in
packages/shared/src/agent-models.test.ts(custom → opencode/claude/codex, absolute paths,.exe, unknown CLI stayscustom, builtins untouched).bun testinpackages/shared: 95 pass. bun testoverpackages/host-service/src/{trpc/router/agents,terminal-agents,model-catalog}: 220 pass. DesktopuseResolveOpenAsChat/useAgentLaunchPreferences: 40 pass.bun run typecheckinpackages/shared,biome checkon the changed files: clean.- Locally,
opencode modelswith Venice/OpenRouter/NanoGPT authed lists 1,115 models for those providers — what the picker will now offer for such an agent. I did not run the full dev desktop app, so no screenshot.
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (CI fails on lint warnings too) — scoped to the changed package - "Allow edits from maintainers" is checked on fork PRs
- I have signed the CLA (the bot asks on your first PR)
🤖 Generated with Claude Code
Summary by cubic
Custom agents that run a known CLI now inherit that CLI's model picker and launch flag.
Previously, a custom agent like opencode --model venice/z-ai-glm-5-3 was stored as custom, so its launcher showed a single Default row and dropped any model override. Now, resolveAgentLaunchPresetId resolves custom agents whose executable matches a supported preset to that preset — giving them the CLI's model catalog (including live opencode acp discovery) and its --model flag at launch.
- Matches the executable basename,
.exestripped, against presets with a real model flag. - Leaves builtin presets and custom agents on unknown CLIs unchanged; excludes
polygraphsince its flag is--agent. - Adds tests for known CLI resolution, absolute paths,
.exevariants, and unchanged cases.
Summary by CodeRabbit
- Bug Fixes
- Custom agents using recognized command-line tools now receive the corresponding model options, including when the executable is specified with a path or an uppercase
.EXEsuffix. - Unknown commands and built-in agents continue to use their configured model settings.
- Custom agents using recognized command-line tools now receive the corresponding model options, including when the executable is specified with a path or an uppercase