auto model: per-prompt model/effort routing across providers, @override per turn
This commit is contained in:
1 parent
f1343295d4
commit
b8fc96a3d2
13 files changed
+1201
-17
No files matched your search
@@ -2,7 +2,7 @@
|
||||
## Every setting is commented out and shows its default or an example; uncomment to change it.
|
||||
|
||||
# provider = "claude" # claude | codex | custom; default: the first logged-in provider
|
||||
# model = "claude-sonnet-5-5" # model for the chosen provider
|
||||
# model = "claude-sonnet-5-5" # model for the chosen provider; "auto" = pick per prompt (see [auto])
|
||||
# claude_model = "claude-sonnet-5-5" # default: the account's latest Sonnet
|
||||
# codex_model = "gpt-5.6-sol" # default: Codex's top-listed model
|
||||
# explore_model = "claude-haiku-4-5" # read-only `task` subagents; default: cheapest tier of the provider
|
||||
@@ -25,6 +25,13 @@
|
||||
# ro = ["~/.cargo", "~/.rustup", "~/.local", "~/.nvm", "~/.npm"] # readable parts of $HOME
|
||||
# env_allow = ["PATH", "HOME", "TERM", "LC_*", "CARGO_*"] # trailing * = prefix
|
||||
|
||||
## Auto model (/model auto): pin a tier to a model, even of another provider.
|
||||
# [auto]
|
||||
# fast = "claude-haiku-4-5"
|
||||
# balanced = "claude-sonnet-5-5"
|
||||
# deep = "gpt-5.6-sol"
|
||||
# down_after = 3 # light prompts in a row before dropping to a cheaper tier
|
||||
|
||||
## OpenAI-compatible endpoint (Ollama, vLLM, LM Studio, OpenRouter), used with provider = "custom".
|
||||
# [openai_compat]
|
||||
# base_url = "http://localhost:11434/v1"
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user