auto model selection + @override per turn #173

Merged
hermes merged 1 commits from feat/auto-model into main 2026-10-26 21:53:37 +00:00
Collaborator

/model auto (also model = "auto", --model auto) chooses model + thinking level per prompt across logged-in providers. @opus ..., @codex ..., @fast ..., @deep ..., @<id part> force one turn.

Behavior

  • Router hx-core/src/route.rs, no LLM call: prompt scored (length, keywords, trace, failed tool result in last turn, long session) -> tier fast/balanced/deep -> model by family name (Haiku/Luna, Sonnet/Terra, Opus/Sol). [auto] config pins tiers to any model, down_after (default 3).
  • Cache-aware: step up at once, step down after N light prompts; "ja"/"continue" keep the tier. Provider stays unless the other has the exact tier, a pin says otherwise, or the current one reported a used-up quota window (Quota event, avoided until reset).
  • Override: leading @word; a file of that name wins (@notes.md). Outside auto the previous model/effort is restored after the turn; in auto the router just picks again. Overrides are not saved to last.json.
  • /model <id> / /provider turn auto off; auto state is saved in last.json.
  • Each choice shows an info line with the reason; footer shows auto->model.
  • Cross-provider history: Anthropic body drops thinking blocks from Codex (JSON reasoning item) or unsigned, keeps signed Claude thinking, sanitizes tool ids (call|item -> [A-Za-z0-9_-]); emptied message gets a placeholder so cache-breakpoint indexes stay aligned.
  • hx stats: new models: block (requests/tokens/cache per model, switches and cache written right after a switch). Only printed with 2+ models.

Tests: 8 router unit tests, 4 switcher tests (auto, override+restore, quota avoid), anthropic foreign-history test, stats test, tui_smoke (auto, forced, pin). sh tests/all.sh green.

Not verified: real Codex<->Claude switch (no Codex login on dev box; Codex side only covered by existing body mapping, which already drops unknown thinking); real quota avoidance; heuristics are untuned guesses, use the why lines and hx stats on real sessions to tune. claude_cli provider: switching tier works via --model per turn, tested only against fake claude (resume session id is kept across models).

`/model auto` (also `model = "auto"`, `--model auto`) chooses model + thinking level per prompt across logged-in providers. `@opus ...`, `@codex ...`, `@fast ...`, `@deep ...`, `@<id part>` force one turn. **Behavior** - Router `hx-core/src/route.rs`, no LLM call: prompt scored (length, keywords, trace, failed tool result in last turn, long session) -> tier fast/balanced/deep -> model by family name (Haiku/Luna, Sonnet/Terra, Opus/Sol). `[auto]` config pins tiers to any model, `down_after` (default 3). - Cache-aware: step up at once, step down after N light prompts; "ja"/"continue" keep the tier. Provider stays unless the other has the exact tier, a pin says otherwise, or the current one reported a used-up quota window (`Quota` event, avoided until reset). - Override: leading `@word`; a file of that name wins (`@notes.md`). Outside auto the previous model/effort is restored after the turn; in auto the router just picks again. Overrides are not saved to last.json. - `/model <id>` / `/provider` turn auto off; auto state is saved in last.json. - Each choice shows an info line with the reason; footer shows `auto->model`. - Cross-provider history: Anthropic body drops thinking blocks from Codex (JSON reasoning item) or unsigned, keeps signed Claude thinking, sanitizes tool ids (`call|item` -> `[A-Za-z0-9_-]`); emptied message gets a placeholder so cache-breakpoint indexes stay aligned. - `hx stats`: new `models:` block (requests/tokens/cache per model, switches and cache written right after a switch). Only printed with 2+ models. **Tests**: 8 router unit tests, 4 switcher tests (auto, override+restore, quota avoid), anthropic foreign-history test, stats test, tui_smoke (auto, forced, pin). `sh tests/all.sh` green. **Not verified**: real Codex<->Claude switch (no Codex login on dev box; Codex side only covered by existing body mapping, which already drops unknown thinking); real quota avoidance; heuristics are untuned guesses, use the `why` lines and `hx stats` on real sessions to tune. claude_cli provider: switching tier works via `--model` per turn, tested only against fake claude (resume session id is kept across models).
hermes added 1 commit 2026-10-26 21:52:52 +00:00
hermes merged commit 15a5034709 into main 2026-10-26 21:53:37 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/hx#173