Skip to content

feat: add first-class --model option and agentModel config#156

Open
genevera wants to merge 1 commit into
kunchenguid:mainfrom
genevera:feat/first-class-model-option
Open

feat: add first-class --model option and agentModel config#156
genevera wants to merge 1 commit into
kunchenguid:mainfrom
genevera:feat/first-class-model-option

Conversation

@genevera

Copy link
Copy Markdown

Summary

Adds a --model CLI flag and an agentModel config section that maps agent names to model strings, implementing the first-class model option discussed in #83.

What changed

Config (config.ts)

  • Added agentModel: Partial<Record<AgentName, string>> to the Config interface
  • Added normalizeAgentModel() with validation (non-empty strings, valid agent names)
  • Added serializeAgentModel() for YAML config persistence
  • Reserved --model/-m in isReservedAgentArg() for OpenCode (hard error: "Use --model CLI flag or agentModel config instead")

Factory (factory.ts)

  • Added model?: string to CreateAgentOptions
  • Passes model to every agent constructor

Agents

  • claude/codex/copilot/pi: --model <model> added to CLI spawn args
  • opencode: Model parsed as { providerID, modelID } from provider/model string, sent in the prompt_async HTTP request body
  • rovodev: Model sent in the setChatMessage request body
  • acp: Model stored for future ACP runtime integration

CLI (cli.ts)

  • Added --model <model> flag
  • Resolves model from --model flag, falling back to config.agentModel[config.agent]

Usage

# ~/.gnhf/config.yml
agent: opencode
agentModel:
  opencode: anthropic/claude-sonnet-4-20250514

Or via CLI:

gnhf --model anthropic/claude-sonnet-4-20250514 "refactor the auth module"

Tests

All 659 tests pass. Lint, typecheck, and format are clean.

…ent model selection

Adds a --model CLI flag and an agentModel config section that maps
agent names to model strings. Each agent handles the model string
in its native format: CLI agents receive --model as a spawn arg,
OpenCode receives it as { providerID, modelID } in the HTTP body,
and RovoDev receives it in the chat message body.

--model and -m are reserved args for OpenCode in agentArgsOverride
to steer users toward the first-class option instead.
@genevera

Copy link
Copy Markdown
Author

Fixes #83

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.

1 participant