A common pitfall when using Large Language Models (LLMs) for system operations is assigning them both "deterministic data retrieval" and "uncertain logical reasoning." Huo Yonghao, a third-year student at the Faculty of Information Science, Hosei University, experienced this firsthand while developing "AI Alert Watcher" during a four-week internship at LINE Yahoo. The tool was designed to receive Kafka alerts from Grafana, perform preliminary investigations, and push results to Slack.
The initial version used a typical Agent pattern: the LLM autonomously decided which data sources to query via Grafana MCP (Model Context Protocol), wrote PromQL statements, interpreted logs, and generated final reports. However, real-world integration revealed severe fragility. When the LLM guessed incorrect data source IDs, messed up MCP tool parameters, or got stuck in long metadata searches, the entire HTTP request would fail due to timeouts. Worse, if the LLM's JSON output deviated slightly from the schema, the parser would error out, resulting in no notification in Slack—operators wouldn't even know an investigation had started. Additionally, the LLM sometimes misinterpreted "No Data" as "Normal," or claimed it had "investigated" despite execution logs showing no actual data retrieval.
Facing only five days of remaining development time, Huo and his mentor re-evaluated the operators' true needs: regardless of the alert type, there were four core metrics that always needed checking—Traffic (inflow volume), HOST (server response status), Critical Cluster Issues (e.g., Offline Partitions), and Consumer Lag. Since this information was fixed, there was no need for the LLM to "think" about how to retrieve it.
Consequently, Watcher underwent a key architectural refactor, splitting the investigation into two independent stages. Stage 1 was executed by the Watcher code itself, using predefined PromQL queries to fetch the four core metrics. This process bypassed the LLM entirely, making it immune to model hallucinations, format errors, or API timeouts. Stage 2 then handed off to the LLM, which used Grafana MCP to read Loki logs, correlate other metrics, or look for specific clues like OOM/GC events based on the facts retrieved in Stage 1.
This "Deterministic + Exploratory" separation significantly improved robustness. First, even if the Stage 2 LLM call failed completely, the four core facts from Stage 1 would still be formatted and sent to Slack, ensuring operators saw the basic status. Second, troubleshooting became clear: no notification meant a Webhook issue; basic data without AI analysis meant an LLM stage issue; missing data meant a Prometheus query issue.
In implementation details, Huo introduced several critical improvements. For instance, Webhook processing was made asynchronous (returning HTTP 202 immediately) to avoid gateway timeouts from waiting for the LLM. He strictly distinguished four states of Prometheus return values: observed (value present), no data (empty result), failed (query error), and conflicting, preventing monitoring blind spots from being reported as healthy. Furthermore, he stopped trusting the LLM's natural language descriptions and instead checked OpenCode execution history logs to verify whether Grafana tools were actually called successfully and returned non-empty results.