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

Method runtime_snapshot

core/src/ahp/executor.rs:302–331  ·  view source on GitHub ↗

Return the current runtime counters observed by AHP.

(&self)

Source from the content-addressed store, hash-verified

300
301 /// Return the current runtime counters observed by AHP.
302 pub fn runtime_snapshot(&self) -> AhpRuntimeSnapshot {
303 let active_tools = self.runtime_state.active_tools();
304 let pending_actions = self.runtime_state.pending_actions();
305 let queue_depth = self.runtime_state.queue_depth();
306 let tokens_used = self.runtime_state.tokens_used();
307 let total_events_processed = self.total_events.load(Ordering::Relaxed);
308 let error_count = self.error_count.load(Ordering::Relaxed) as usize;
309 let uptime_ms = self.start_time.elapsed().as_millis() as u64;
310 let current_state = if pending_actions > 0 {
311 "waiting"
312 } else if active_tools > 0 {
313 "running_tools"
314 } else if self.get_idle_duration_ms() >= self.idle_threshold_ms {
315 "idle"
316 } else {
317 "active"
318 }
319 .to_string();
320
321 AhpRuntimeSnapshot {
322 active_tools,
323 pending_actions,
324 queue_depth,
325 tokens_used,
326 total_events_processed,
327 error_count,
328 uptime_ms,
329 current_state,
330 }
331 }
332
333 /// Get idle duration in milliseconds.
334 pub fn get_idle_duration_ms(&self) -> u64 {

Calls 6

pending_actionsMethod · 0.80
queue_depthMethod · 0.80
tokens_usedMethod · 0.80
get_idle_duration_msMethod · 0.80
active_toolsMethod · 0.45
loadMethod · 0.45