MCPcopy Create free account
hub / github.com/AI45Lab/Code / check_timeouts

Method check_timeouts

core/src/hitl.rs:312–358  ·  view source on GitHub ↗

Check for and handle timed out confirmations Returns the number of confirmations that timed out.

(&self)

Source from the content-addressed store, hash-verified

310 ///
311 /// Returns the number of confirmations that timed out.
312 pub async fn check_timeouts(&self) -> usize {
313 let policy = self.policy.read().await;
314 let timeout_action = policy.timeout_action;
315 drop(policy);
316
317 let mut timed_out = Vec::new();
318
319 // Find timed out confirmations
320 {
321 let pending_map = self.pending.read().await;
322 for (tool_id, pending) in pending_map.iter() {
323 if pending.is_timed_out() {
324 timed_out.push(tool_id.clone());
325 }
326 }
327 }
328
329 // Handle timed out confirmations
330 for tool_id in &timed_out {
331 let pending = {
332 let mut pending_map = self.pending.write().await;
333 pending_map.remove(tool_id)
334 };
335
336 if let Some(confirmation) = pending {
337 let (approved, action_taken) = match timeout_action {
338 TimeoutAction::Reject => (false, "rejected"),
339 TimeoutAction::AutoApprove => (true, "auto_approved"),
340 };
341
342 // Emit timeout event
343 let _ = self.event_tx.send(AgentEvent::ConfirmationTimeout {
344 tool_id: tool_id.clone(),
345 action_taken: action_taken.to_string(),
346 });
347
348 // Send the response
349 let response = ConfirmationResponse {
350 approved,
351 reason: Some(format!("Confirmation timed out, action: {}", action_taken)),
352 };
353 let _ = confirmation.response_tx.send(response);
354 }
355 }
356
357 timed_out.len()
358 }
359
360 /// Get the number of pending confirmations
361 pub async fn pending_count(&self) -> usize {

Callers 3

test_timeout_rejectFunction · 0.45

Calls 6

writeMethod · 0.80
removeMethod · 0.80
is_timed_outMethod · 0.45
cloneMethod · 0.45
sendMethod · 0.45
lenMethod · 0.45

Tested by 3

test_timeout_rejectFunction · 0.36