[GH-ISSUE #173] Support per-hat backend args (e.g. --model) #69

Closed
opened 2026-02-27 10:22:03 +03:00 by kerem · 4 comments
Owner

Originally created by @Teo-Asinari on GitHub (Feb 12, 2026).
Original GitHub issue: https://github.com/mikeyobrien/ralph-orchestrator/issues/173

Feature Request: Per-Hat Backend Arguments

Problem

Ralph supports per-hat backend overrides, but there's no way to pass additional CLI arguments to the backend on a per-hat basis. This makes it impossible to control model selection per hat when using Claude Code as the backend.

Use Case

When using Claude Code, users may want different hats to run on different models:

  • Planner/Reviewer hats → Opus (stronger reasoning)
  • Builder/Committer hats → Sonnet (faster, cheaper)

Currently the only option is ralph run -- --model sonnet, which applies globally to all hats.

Proposed Solution

Add a backend_args field to the hat schema:

hats:
  planner:
    backend: "claude"
    backend_args: ["--model", "opus"]
    triggers: ["build.start"]
    # ...

  builder:
    backend: "claude"
    backend_args: ["--model", "sonnet"]
    triggers: ["tasks.ready"]
    # ...

These args would be appended to the backend command when invoking that hat's session.

Alternatives Considered

  • Custom backends: Registering the same CLI as multiple custom backends with different commands (e.g. claude --model opus vs claude --model sonnet). Works but is verbose and fragile.
  • Environment variables: Claude Code has CLAUDE_CODE_SUBAGENT_MODEL (undocumented) but this only affects subagents within a session, not the top-level model.
  • Global -- <CUSTOM_ARGS>: Applies to all hats, no per-hat control.

Impact

This would make Ralph backend-agnostic model routing possible, useful for cost optimization and performance tuning across hat workflows.

Originally created by @Teo-Asinari on GitHub (Feb 12, 2026). Original GitHub issue: https://github.com/mikeyobrien/ralph-orchestrator/issues/173 ## Feature Request: Per-Hat Backend Arguments ### Problem Ralph supports per-hat `backend` overrides, but there's no way to pass additional CLI arguments to the backend on a per-hat basis. This makes it impossible to control model selection per hat when using Claude Code as the backend. ### Use Case When using Claude Code, users may want different hats to run on different models: - **Planner/Reviewer hats** → Opus (stronger reasoning) - **Builder/Committer hats** → Sonnet (faster, cheaper) Currently the only option is `ralph run -- --model sonnet`, which applies globally to all hats. ### Proposed Solution Add a `backend_args` field to the hat schema: ```yaml hats: planner: backend: "claude" backend_args: ["--model", "opus"] triggers: ["build.start"] # ... builder: backend: "claude" backend_args: ["--model", "sonnet"] triggers: ["tasks.ready"] # ... ``` These args would be appended to the backend command when invoking that hat's session. ### Alternatives Considered - **Custom backends**: Registering the same CLI as multiple custom backends with different commands (e.g. `claude --model opus` vs `claude --model sonnet`). Works but is verbose and fragile. - **Environment variables**: Claude Code has `CLAUDE_CODE_SUBAGENT_MODEL` (undocumented) but this only affects subagents within a session, not the top-level model. - **Global `-- <CUSTOM_ARGS>`**: Applies to all hats, no per-hat control. ### Impact This would make Ralph backend-agnostic model routing possible, useful for cost optimization and performance tuning across hat workflows.
kerem closed this issue 2026-02-27 10:22:03 +03:00
Author
Owner

@francocalvo commented on GitHub (Feb 19, 2026):

Is this not the same as herE?
https://github.com/mikeyobrien/ralph-orchestrator/issues/147

<!-- gh-comment-id:3929489257 --> @francocalvo commented on GitHub (Feb 19, 2026): Is this not the same as herE? https://github.com/mikeyobrien/ralph-orchestrator/issues/147
Author
Owner

@mikeyobrien commented on GitHub (Feb 20, 2026):

Should be functional as described in #147 otherwise there is a regression.

<!-- gh-comment-id:3937145559 --> @mikeyobrien commented on GitHub (Feb 20, 2026): Should be functional as described in #147 otherwise there is a regression.
Author
Owner

@francocalvo commented on GitHub (Feb 23, 2026):

@mikeyobrien
I think there is a bug, yes. https://github.com/mikeyobrien/ralph-orchestrator/issues/178

<!-- gh-comment-id:3945623647 --> @francocalvo commented on GitHub (Feb 23, 2026): @mikeyobrien I think there is a bug, yes. https://github.com/mikeyobrien/ralph-orchestrator/issues/178
Author
Owner

@mikeyobrien commented on GitHub (Feb 25, 2026):

Validated this is implemented and working.

What is in place:

  • Per-hat backend args are supported in config via backend_args and shorthand args.
  • Hat-level args are applied at execution time in the loop runner.
  • Existing backend-args config tests are passing in ralph-core.

Also consistent with issue #147 behavior.
Closing as completed.

<!-- gh-comment-id:3960131410 --> @mikeyobrien commented on GitHub (Feb 25, 2026): Validated this is implemented and working. What is in place: - Per-hat backend args are supported in config via backend_args and shorthand args. - Hat-level args are applied at execution time in the loop runner. - Existing backend-args config tests are passing in ralph-core. Also consistent with issue #147 behavior. Closing as completed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ralph-orchestrator#69
No description provided.