Skip to content

Commit 4462e6a

Browse files
author
Alex
committed
fix(multi_agent): wire flush_usage into pool shutdown
Validation gap: flush_usage() was never called from any code path, meaning usage records accumulated in memory but were never persisted. Now pool.shutdown() flushes all agents before clearing. Defect V001 from validation. Refs #1075
1 parent b4564c3 commit 4462e6a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • crates/terraphim_multi_agent/src

crates/terraphim_multi_agent/src/pool.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,20 @@ impl AgentPool {
452452
pub async fn shutdown(&self) -> MultiAgentResult<()> {
453453
log::info!("Shutting down agent pool");
454454

455-
// Clear all agents
456455
{
457456
let mut available = self.available_agents.write().await;
458-
available.clear();
457+
for agent in available.drain(..) {
458+
agent.agent.flush_usage().await;
459+
}
459460
}
460461

461462
{
462463
let mut busy = self.busy_agents.write().await;
463-
busy.clear();
464+
for (_id, agent) in busy.drain() {
465+
agent.agent.flush_usage().await;
466+
}
464467
}
465468

466-
// Update final stats
467469
{
468470
let mut stats = self.stats.write().await;
469471
stats.current_pool_size = 0;

0 commit comments

Comments
 (0)