huskies: merge 981
This commit is contained in:
@@ -64,6 +64,44 @@ fn inject_gate_failure_section(args: &mut Vec<String>, gate_output: &str) {
|
||||
args.push(section);
|
||||
}
|
||||
|
||||
/// Cap `--max-turns` and `--max-budget-usd` for merge-gate fixup sessions (story 981).
|
||||
///
|
||||
/// When [`ContentKey::MergeFixupPending`] is set the fixup coder must not run
|
||||
/// longer than 20 turns or spend more than $1. If the agent config already
|
||||
/// specifies lower values those are preserved; otherwise the fixup caps take
|
||||
/// precedence by overriding the args in place.
|
||||
pub(super) fn maybe_cap_for_merge_fixup(args: &mut Vec<String>, story_id: &str) {
|
||||
if crate::db::read_content(crate::db::ContentKey::MergeFixupPending(story_id)).is_none() {
|
||||
return;
|
||||
}
|
||||
// Override --max-turns: set to 20 unless already lower.
|
||||
const FIXUP_MAX_TURNS: u32 = 20;
|
||||
if let Some(pos) = args.iter().position(|a| a == "--max-turns") {
|
||||
if let Some(val) = args.get_mut(pos + 1) {
|
||||
let current: u32 = val.parse().unwrap_or(u32::MAX);
|
||||
if current > FIXUP_MAX_TURNS {
|
||||
*val = FIXUP_MAX_TURNS.to_string();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
args.push("--max-turns".to_string());
|
||||
args.push(FIXUP_MAX_TURNS.to_string());
|
||||
}
|
||||
// Override --max-budget-usd: set to 1.0 unless already lower.
|
||||
const FIXUP_MAX_BUDGET: f64 = 1.0;
|
||||
if let Some(pos) = args.iter().position(|a| a == "--max-budget-usd") {
|
||||
if let Some(val) = args.get_mut(pos + 1) {
|
||||
let current: f64 = val.parse().unwrap_or(f64::MAX);
|
||||
if current > FIXUP_MAX_BUDGET {
|
||||
*val = FIXUP_MAX_BUDGET.to_string();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
args.push("--max-budget-usd".to_string());
|
||||
args.push(FIXUP_MAX_BUDGET.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
/// On retry spawns (retry_count > 0), read the stored gate_output from the DB
|
||||
/// and inject it into `--append-system-prompt` so the agent always sees the
|
||||
/// prior failure context, even when session-resuming (story 881).
|
||||
@@ -216,6 +254,8 @@ pub(super) async fn run_agent_spawn(
|
||||
// On retry spawns (retry_count > 0), inject prior gate failure output into
|
||||
// --append-system-prompt so the agent always sees the failure context (story 881).
|
||||
maybe_inject_gate_failure(&mut args, &sid);
|
||||
// Cap turns and budget for merge-gate fixup sessions (story 981).
|
||||
maybe_cap_for_merge_fixup(&mut args, &sid);
|
||||
|
||||
// Append project-local prompt content (.huskies/AGENT.md) to the
|
||||
// baked-in prompt so every agent role sees project-specific guidance
|
||||
|
||||
Reference in New Issue
Block a user