Subagents: task tool (explore on cheap model, general), child sessions, usage roll-up, stats
ci / check (pull_request) Canceled after 0s
ci / check (push) Canceled after 0s

This commit is contained in:
hermes committed 2026-10-02 11:57:59 +00:00
1 parent 6b980591ed
commit 359a5058d7
14 files changed
+525 -2

No files matched your search

+39 -1
View File
@@ -75,6 +75,8 @@ struct Config {
/// Auto-compact threshold in estimated tokens.
compact_at: Option<usize>,
max_tokens: Option<u32>,
/// Model for read-only `task` subagents; default: the provider's cheapest tier (Haiku / Luna).
explore_model: Option<String>,
/// Replaces the built-in system prompt (AGENTS.md etc. are still appended).
system_prompt: Option<String>,
lsp: Option<LspCfg>,
@@ -118,6 +120,7 @@ impl Config {
codex_model: o.codex_model.or(c.codex_model),
compact_at: o.compact_at.or(c.compact_at),
max_tokens: o.max_tokens.or(c.max_tokens),
explore_model: o.explore_model.or(c.explore_model),
system_prompt: o.system_prompt.or(c.system_prompt),
lsp: o.lsp.or(c.lsp),
extensions: [c.extensions, o.extensions].concat(),
@@ -284,7 +287,8 @@ 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::report(&Session::open(&session)?));
print!("{}", hx_core::stats::sub_report(&session));
return Ok(());
}
Some(Cmd::Prefix) => {
@@ -341,6 +345,7 @@ async fn main() -> Result<()> {
];
rows.extend(skill_rows);
let mut specs = reg.specs();
specs.push(hx_core::subagent::spec());
specs.sort_by_key(|t| {
std::cmp::Reverse(serde_json::to_string(t).map_or(0, |s| s.len()))
});
@@ -539,6 +544,39 @@ async fn main() -> Result<()> {
.collect();
mgr.warm(probe).await;
}
{
// children get the parent's tools as of now (no `task`, so no recursion)
let mut general = agent.tools.clone();
general.retain(|n| n != "ask_user");
let mut explore = agent.tools.clone();
explore.retain(|n| hx_core::subagent::EXPLORE_TOOLS.contains(&n));
let home = context::hx_home();
let role = |model: String, tools, base: &str| hx_core::subagent::Role {
provider: provider(kind).expect("provider worked above"),
model,
tools,
system: context::system_prompt(Some(base), &home, &cwd),
};
let cheap = cfg
.explore_model
.clone()
.or_else(|| hx_ai::models::cheap_for(kind, &models))
.unwrap_or_else(|| agent.model().to_string());
let mut task = hx_core::subagent::Task::new(
role(cheap, explore, hx_core::subagent::EXPLORE_PROMPT),
role(
agent.model().to_string(),
general,
hx_core::subagent::GENERAL_PROMPT,
),
path.with_extension("sub"),
3,
);
if let Some(l) = &lens_ref {
task.hooks.push(Arc::new(ArcHook(l.clone())));
}
agent.tools.add(task);
}
let specs = command_specs(&mcp, &cwd, &models, &kinds);
if cli.mode == Mode::Rpc {
let r = rpc::serve(