huskies: merge 1015

This commit is contained in:
dave
2026-05-13 23:33:30 +00:00
parent 69b207872a
commit 5ed1438ab9
22 changed files with 227 additions and 73 deletions
+2 -4
View File
@@ -120,11 +120,9 @@ pub(in crate::agents::pool) fn find_free_agent_for_stage<'a>(
// model matches. This keeps opus agents reserved for explicit requests.
if *stage == PipelineStage::Coder
&& let Some(ref default_model) = config.default_coder_model
&& agent_config.model.as_ref() != Some(default_model)
{
let agent_model = agent_config.model.as_deref().unwrap_or("");
if agent_model != default_model {
continue;
}
continue;
}
let is_busy = agents.values().any(|a| {
a.agent_name == agent_config.name
@@ -67,7 +67,10 @@ pub(crate) fn compute_budget_from_single_log(path: &Path) -> f64 {
&& let Some(message) = data.get("message")
&& let Some(usage) = message.get("usage")
{
let model = message.get("model").and_then(|v| v.as_str());
let model = message
.get("model")
.and_then(|v| v.as_str())
.map(crate::agents::AgentModel::from_api_str);
let token_usage = TokenUsage {
input_tokens: usage
.get("input_tokens")
@@ -87,7 +90,7 @@ pub(crate) fn compute_budget_from_single_log(path: &Path) -> f64 {
.unwrap_or(0),
total_cost_usd: 0.0,
};
cost += token_usage.estimate_cost_usd(model);
cost += token_usage.estimate_cost_usd(model.as_ref());
}
}
cost
+3 -3
View File
@@ -364,13 +364,13 @@ impl AgentPool {
let effective_session_id = session_id_to_resume.or_else(|| {
let model = config
.find_agent(&resolved_name)
.and_then(|a| a.model.clone())
.unwrap_or_default();
.and_then(|a| a.model.as_ref().map(|m| m.as_str()))
.unwrap_or("");
crate::agents::session_store::lookup_session(
project_root,
story_id,
&resolved_name,
&model,
model,
)
});
+11 -8
View File
@@ -384,8 +384,7 @@ pub(super) async fn run_agent_spawn(
// passed to RuntimeContext for eager session recording (bug 967).
let agent_model = config_clone
.find_agent(&aname)
.and_then(|a| a.model.clone())
.unwrap_or_default();
.and_then(|a| a.model.clone());
let run_result = match runtime_name {
"claude-code" => {
@@ -463,11 +462,15 @@ pub(super) async fn run_agent_spawn(
&& let Some(agent) = agents.get(&key_clone)
&& let Some(ref pr) = agent.project_root
{
let model = config_clone
let model_for_record = config_clone
.find_agent(&aname)
.and_then(|a| a.model.clone());
let record =
crate::agents::token_usage::build_record(&sid, &aname, model, usage.clone());
let record = crate::agents::token_usage::build_record(
&sid,
&aname,
model_for_record,
usage.clone(),
);
if let Err(e) = crate::agents::token_usage::append_record(pr, &record) {
slog_error!(
"[agents] Failed to persist token usage for \
@@ -480,13 +483,13 @@ pub(super) async fn run_agent_spawn(
if let Some(ref sess_id) = result.session_id {
let model = config_clone
.find_agent(&aname)
.and_then(|a| a.model.clone())
.unwrap_or_default();
.and_then(|a| a.model.as_ref().map(|m| m.as_str()))
.unwrap_or("");
crate::agents::session_store::record_session(
&project_root_clone,
&sid,
&aname,
&model,
model,
sess_id,
);
}