Skip to content

feat: /model --once one-turn model override (salvages #29923) - #67113

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-b17e0576
Jul 18, 2026
Merged

feat: /model --once one-turn model override (salvages #29923)#67113
teknium1 merged 2 commits into
mainfrom
hermes/hermes-b17e0576

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

/model <name> --once switches the model for the next turn only and restores the previous model afterward — on success, error, and interrupt alike, with nothing persisted anywhere. Salvages PR #29923 (@deusyu, fixes the design ask in #29914's user-explicit lane) with both review defects fixed on top.

Changes

  • Salvaged from Add per-turn and per-image model overrides #29923 (authorship preserved): parse_model_flags_detailed() + ModelFlagParseResult (legacy 5-tuple parse_model_flags kept for existing call sites), resolve_persist_behavior(is_once=...) opt-out, CLI/TUI/gateway --once lanes with restore-in-finally, --global+--once rejected, model-switch note tells the model the override is one-turn
  • Fix 1 (gateway, review defect): --once now excluded from the session-store write-through — previously a gateway restart before the finally-restore rehydrated the "one-turn" model permanently
  • Fix 2 (TUI, review defect): _sync_agent_model_with_config skipped while a one-turn restore is pending — previously the config sync clobbered the once-override back to the config model before the turn ran
  • Scope trim per review discussion: the per-call image_generate override lane stays out (split to fix(image_generate): honor per-call provider/model overrides and warn-fallback unknown FAL overrides #59815)
  • Docs: --once in configuring-models.md with an honest prompt-cache cost note

Design notes

  • Restore path reuses the proven /moa one-shot skeleton (snapshot → install → restore-in-finally); gateway restore is idempotent (double-restore no-op)
  • Cache cost documented rather than hidden: a one-shot switch breaks the provider cached prefix twice; wins for short sessions and cheap→expensive escalation
  • Stays inside the standing policy line: user-explicit --once only, no automatic/agent-callable routing

Validation

Result
PR's own tests + both new regression guards 410 passed across 6 files
Sibling model-command test files (stale-base sweep) 29 passed
E2E (real imports) parse → persist-decision → gateway restore state machine: prior-override restore, clear-on-absent, double-restore idempotency, Unicode-dash —once
Write-through guard --once never awaits set_model_override; --session still does

Infographic

model-once

deusyu and others added 2 commits July 18, 2026 13:00
Adds --once to /model across CLI, TUI, and gateway: switch model for the
next turn only, restoring the previous model in a finally block so
success, exception, and interrupt all revert. Parsing extends
parse_model_flags_detailed(); resolve_persist_behavior() treats --once
as a persistence opt-out; --global + --once is rejected.

Salvaged from PR #29923 (image-generation lane split to #59815 per
review; conflict resolution against current main by the maintainers).
Fixes the two review defects that kept PR #29923 open, plus docs:

- gateway: exclude --once from the session-store write-through. The
  once-override lived only in memory before, but the write-through
  persisted it, so a gateway restart before the finally-restore
  rehydrated a supposedly one-turn model permanently.
- TUI: skip _sync_agent_model_with_config while a one-turn restore is
  pending. The once-model is deliberately not pinned as a session
  model_override, so the config sync saw a model mismatch and clobbered
  the once-override back to the config model before the turn ran.
- tests: real _handle_model_command drive asserting --once never
  touches set_model_override while --session still does; restore-pop
  idempotency.
- docs: /model --once in configuring-models.md with an honest
  prompt-cache cost note (one-shot switch breaks the cached prefix
  twice; wins for short sessions and cheap-to-expensive escalation).
@alt-glitch alt-glitch added type/feature New feature or request comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have needs-decision Awaiting maintainer decision before any implementation sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to open #29923: this core-team salvage keeps the one-turn CLI/TUI/gateway lane but adds restore and non-persistence safeguards, while #59815 remains the split image-override lane. Maintainer consolidation is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants