( agent: WorkspaceAgent, )
| 65 | * Classifies all health issues for an individual agent. |
| 66 | */ |
| 67 | export function getAgentHealthIssues( |
| 68 | agent: WorkspaceAgent, |
| 69 | ): AgentHealthIssue[] { |
| 70 | const issues: AgentHealthIssue[] = []; |
| 71 | |
| 72 | if (agent.status === "disconnected") { |
| 73 | issues.push({ |
| 74 | title: agentConnectionMessages.disconnected.title, |
| 75 | detail: agentConnectionMessages.disconnected.detail, |
| 76 | severity: "warning", |
| 77 | prominent: false, |
| 78 | }); |
| 79 | } |
| 80 | |
| 81 | if (agent.status === "timeout") { |
| 82 | issues.push({ |
| 83 | title: agentConnectionMessages.timeout.title, |
| 84 | detail: agentConnectionMessages.timeout.detail, |
| 85 | severity: "warning", |
| 86 | prominent: false, |
| 87 | }); |
| 88 | } |
| 89 | |
| 90 | if ( |
| 91 | agent.lifecycle_state === "shutting_down" || |
| 92 | agent.lifecycle_state === "shutdown_error" || |
| 93 | agent.lifecycle_state === "shutdown_timeout" |
| 94 | ) { |
| 95 | issues.push({ |
| 96 | title: "Workspace agent is shutting down", |
| 97 | detail: "The workspace is not available while agents shut down.", |
| 98 | severity: "info", |
| 99 | prominent: false, |
| 100 | }); |
| 101 | } |
| 102 | |
| 103 | // Ignore `start_error` and `start_timeout`, as these will eventually be |
| 104 | // removed from agent health. Instead, figure out if a script failed to start |
| 105 | // by looking directly at the scripts. |
| 106 | for (const script of agent.scripts) { |
| 107 | switch (script.status) { |
| 108 | case "timed_out": |
| 109 | issues.push({ |
| 110 | title: `"${script.display_name}" is taking longer than expected`, |
| 111 | detail: `"${script.display_name}" has exceeded the expected time. Check the agent logs for details.`, |
| 112 | severity: "warning", |
| 113 | prominent: false, |
| 114 | }); |
| 115 | break; |
| 116 | case "exit_failure": |
| 117 | if (script.exit_code) { |
| 118 | issues.push({ |
| 119 | title: `"${script.display_name}" failed`, |
| 120 | detail: `"${script.display_name}" exited with ${script.exit_code}. Check the agent logs for details.`, |
| 121 | severity: "warning", |
| 122 | prominent: false, |
| 123 | }); |
| 124 | } else { |
no test coverage detected