|
| 1 | +# Agent Data Flow and Visualization Breakdown |
| 2 | + |
| 3 | +This document illustrates the data flow for agent visualization, highlighting the point of failure and the proposed fix. |
| 4 | + |
| 5 | +## System Components |
| 6 | + |
| 7 | +* **BotsClient**: A Rust service responsible for connecting to the MCP server via WebSocket and fetching agent data. |
| 8 | +* **GraphServiceActor**: A Rust actor that manages the graph data structure used for rendering in the frontend. |
| 9 | +* **MCP Server**: A Node.js application running in a Docker container that manages the agent lifecycle. |
| 10 | + |
| 11 | +## Data Flow Diagram |
| 12 | + |
| 13 | +The following diagram shows the sequence of events for fetching and displaying agent data. The failure point is clearly marked. |
| 14 | + |
| 15 | +```mermaid |
| 16 | +sequenceDiagram |
| 17 | + participant Client as Frontend Client |
| 18 | + participant BotsClient as BotsClient Service |
| 19 | + participant GraphServiceActor as GraphServiceActor |
| 20 | + participant MCPServer as MCP Server |
| 21 | +
|
| 22 | + Client->>BotsClient: Initiate connection to agent system |
| 23 | + BotsClient->>MCPServer: WebSocket connection established |
| 24 | + MCPServer-->>BotsClient: Connection confirmed |
| 25 | +
|
| 26 | + loop Data Fetch (every 5 seconds) |
| 27 | + BotsClient->>MCPServer: Request agent list (tools/call agent_list) |
| 28 | + MCPServer-->>BotsClient: Agent list data (JSON) |
| 29 | + end |
| 30 | +
|
| 31 | + Note over BotsClient: Agent data is received and parsed successfully. |
| 32 | +
|
| 33 | + critical ❌ FAILURE POINT: Data Not Forwarded |
| 34 | + BotsClient-->>GraphServiceActor: **MISSING:** UpdateBotsGraph message is never sent. |
| 35 | + end |
| 36 | +
|
| 37 | + Note over GraphServiceActor: GraphServiceActor has no knowledge of the agents. |
| 38 | +
|
| 39 | + loop Render Cycle (60 FPS) |
| 40 | + Client->>GraphServiceActor: Request graph data for rendering |
| 41 | + GraphServiceActor-->>Client: Returns an empty or outdated graph. |
| 42 | + end |
| 43 | +
|
| 44 | + Note over Client: No agents are rendered on the screen. |
| 45 | +
|
| 46 | +``` |
| 47 | + |
| 48 | +## The Fix: `consolidated_agent_graph_fix.patch` |
| 49 | + |
| 50 | +The provided patch resolves this issue by adding the missing communication link. |
| 51 | + |
| 52 | +```mermaid |
| 53 | +sequenceDiagram |
| 54 | + participant Client as Frontend Client |
| 55 | + participant BotsClient as BotsClient Service |
| 56 | + participant GraphServiceActor as GraphServiceActor |
| 57 | + participant MCPServer as MCP Server |
| 58 | +
|
| 59 | + Client->>BotsClient: Initiate connection to agent system |
| 60 | + BotsClient->>MCPServer: WebSocket connection established |
| 61 | + MCPServer-->>BotsClient: Connection confirmed |
| 62 | +
|
| 63 | + loop Data Fetch (every 5 seconds) |
| 64 | + BotsClient->>MCPServer: Request agent list (tools/call agent_list) |
| 65 | + MCPServer-->>BotsClient: Agent list data (JSON) |
| 66 | + end |
| 67 | +
|
| 68 | + Note over BotsClient: Agent data is received and parsed successfully. |
| 69 | +
|
| 70 | + rect rgb(200, 255, 200) |
| 71 | + Note over BotsClient, GraphServiceActor: ✅ FIX APPLIED |
| 72 | + BotsClient->>GraphServiceActor: **FIX:** Sends UpdateBotsGraph message with agent data. |
| 73 | + end |
| 74 | +
|
| 75 | + Note over GraphServiceActor: GraphServiceActor now has the latest agent data. |
| 76 | +
|
| 77 | + loop Render Cycle (60 FPS) |
| 78 | + Client->>GraphServiceActor: Request graph data for rendering |
| 79 | + GraphServiceActor-->>Client: Returns graph with all agents. |
| 80 | + end |
| 81 | +
|
| 82 | + Note over Client: Agents are correctly rendered on the screen. |
0 commit comments