auto model: per-prompt model/effort routing across providers, @override per turn

This commit is contained in:
hermes committed 2026-10-26 21:52:50 +00:00
1 parent f1343295d4
commit b8fc96a3d2
13 files changed
+1201 -17

No files matched your search

+25 -3
View File
@@ -141,6 +141,8 @@ struct Config {
mouse: Option<bool>,
/// Reuse the last model chosen with /model or /provider (default true).
remember_model: Option<bool>,
/// `/model auto`: tier pins (`fast`, `balanced`, `deep` = model ids) and `down_after`.
auto: Option<hx_core::route::Cfg>,
/// "ask" (default) or "yolo": whether bash/write/edit prompt in the TUI.
permissions: Option<String>,
/// Replaces the built-in system prompt (AGENTS.md etc. are still appended).
@@ -212,6 +214,7 @@ impl Config {
codemode: o.codemode.or(c.codemode),
mouse: o.mouse.or(c.mouse),
remember_model: o.remember_model.or(c.remember_model),
auto: o.auto.or(c.auto),
permissions: o.permissions.or(c.permissions),
system_prompt: o.system_prompt.or(c.system_prompt),
sandbox: o.sandbox.or(c.sandbox),
@@ -560,6 +563,10 @@ async fn main() -> Result<()> {
Some(Cmd::Logout { provider }) => return Ok(auth::logout(provider)?),
Some(Cmd::Stats { session }) => {
print!("{}", hx_core::stats::report(&Session::open(&session)?));
print!(
"{}",
hx_core::stats::model_report(&Session::open(&session)?)
);
print!("{}", hx_core::stats::task_report(&Session::open(&session)?));
print!("{}", hx_core::stats::sub_report(&session));
return Ok(());
@@ -808,9 +815,18 @@ async fn main() -> Result<()> {
// the remembered model applies only to the provider it was chosen on
let last = last.filter(|l| l.provider == kind);
let last_effort = last.as_ref().and_then(|l| l.effort);
// auto mode: `--model auto` / `model = "auto"`, else whatever was on last time
let want_auto = match cli.model.as_deref().or(cfg.model.as_deref()) {
Some(m) => m == "auto",
None => last.as_ref().is_some_and(|l| l.auto),
};
let (cli_model, cfg_model) = (
cli.model.clone().filter(|m| m != "auto"),
cfg.model.clone().filter(|m| m != "auto"),
);
let last_model = last.map(|l| l.model);
let search = web_search(&cfg);
let model = cli.model.or(cfg.model).or(last_model).unwrap_or_else(|| {
let model = cli_model.or(cfg_model).or(last_model).unwrap_or_else(|| {
match kind {
Kind::Claude => cfg.claude_model.clone(),
Kind::Codex => cfg.codex_model.clone(),
@@ -855,7 +871,9 @@ async fn main() -> Result<()> {
provider: kind,
model: model.clone(),
effort: Some(effort),
auto: want_auto,
};
let auto_cfg = cfg.auto.clone().unwrap_or_default();
if hx_core::herdr::init() {
hx_core::herdr::set_session(&path);
agent.bus.add(hx_core::herdr::Hook);
@@ -1012,7 +1030,9 @@ async fn main() -> Result<()> {
files: hx_tui::project_files(&cwd),
session_dir: dir,
switcher: Switcher::new(kind, models.clone(), Box::new(provider))
.remember_in(last_path.clone(), start.clone()),
.auto_cfg(auto_cfg.clone())
.remember_in(last_path.clone(), start.clone())
.auto_on(want_auto),
},
)
.await;
@@ -1035,7 +1055,9 @@ async fn main() -> Result<()> {
hx_tui::run(hx_tui::Setup {
agent,
switcher: Switcher::new(kind, models.clone(), Box::new(provider))
.remember_in(last_path, start),
.auto_cfg(auto_cfg)
.remember_in(last_path, start)
.auto_on(want_auto),
pricing,
specs,
open_sessions,