huskies: merge 650_bug_watchdog_turns_used_and_budget_used_usd_accumulate_across_all_sessions_restart_counts_against_limits_from_prior_runs

This commit is contained in:
dave
2026-04-26 16:24:10 +00:00
parent 148c88bd40
commit 365b907ba4
5 changed files with 542 additions and 175 deletions
+33
View File
@@ -112,6 +112,39 @@ impl AgentPool {
tx
}
/// Test helper: inject an agent with a specific log session ID.
/// Used by watchdog tests to simulate per-session counting.
pub fn inject_test_agent_with_session(
&self,
story_id: &str,
agent_name: &str,
status: AgentStatus,
log_session_id: &str,
) -> broadcast::Sender<AgentEvent> {
let (tx, _) = broadcast::channel::<AgentEvent>(64);
let key = composite_key(story_id, agent_name);
let mut agents = self.agents.lock().unwrap();
agents.insert(
key,
StoryAgent {
agent_name: agent_name.to_string(),
status,
worktree_info: None,
session_id: None,
tx: tx.clone(),
task_handle: None,
event_log: Arc::new(Mutex::new(Vec::new())),
completion: None,
project_root: None,
log_session_id: Some(log_session_id.to_string()),
merge_failure_reported: false,
throttled: false,
termination_reason: None,
},
);
tx
}
/// Inject a Running agent with a pre-built (possibly finished) task handle.
/// Used by watchdog tests to simulate an orphaned agent.
pub fn inject_test_agent_with_handle(