# Deadlock Detector AI Agent Connect

> Detects circular dependencies and resource deadlocks in multi-agent systems.

## Overview
- **Category:** agent-orchestration
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_jIQtpasXuC0yJJh1Rf0CPFanZ1l13iZIsZSmVlxf/ai-agent-connect
- **Tags:** deadlock, graph-theory, resource-allocation, multi-agent, system-health

## Description

This MCP server provides deterministic deadlock detection for multi-agent environments using Wait-for Graph analysis. It identifies circular dependencies using DFS coloring and provides actionable insights for system recovery. Use `detect_deadlock` to find specific deadlock cycles, `select_victim` to determine which agent to preempt based on work done and priority, and `analyze_system_health` to monitor resource utilization and starvation risks.

## Tools

### analyze_system_health
Provides high-level metrics regarding how resources are being used and identifying agents at risk of starvation

### detect_deadlock
Identifies if a deadlock exists within the current resource allocation state and provides the specific path of the deadlock

### select_victim
Determines which agent should be preempted to resolve an identified deadlock

## Prompt Examples

**Prompt:** 
```
Are there any deadlocks in the current resource allocation graph?
```

**Response:** 
```
Yes, a deadlock has been detected involving agents: Agent_A, Agent_B, and Agent_C.
```

**Prompt:** 
```
Which agent should I preempt to resolve the current deadlock?
```

**Response:** 
```
Agent_B should be preempted because it has the least work done.
```

**Prompt:** 
```
What is the current resource utilization and are any agents starving?
```

**Response:** 
```
Resource R1 utilization is 100%. Agent_D is at risk of starvation as it has been waiting for over 30 seconds.
```

## Frequently Asked Questions

**How does the tool identify a deadlock?**
The `detect_deadlock` tool uses Depth-First Search (DFS) with coloring to traverse the Wait-for Graph. A deadlock is confirmed when a GRAY node is encountered during traversal.

**How is the victim selected to break a deadlock?**
The `select_victim` tool chooses the agent with the least amount of work done. If there is a tie, it selects the agent with the lowest priority.

**Can I monitor resource starvation?**
Yes, `analyze_system_health` identifies agents at risk of starvation if they have been waiting for a resource for more than 30 seconds.
