fix(insights): add logging to diagnose why AI network observations never persist
The parse function silently returned {:ok, []} on any decode failure or
observation rejection. Log warnings for both cases so we can see what the
LLM is actually returning.
This commit is contained in:
parent
78f7745c3c
commit
a05907b76d
1 changed files with 15 additions and 4 deletions
|
|
@ -10,6 +10,8 @@ defmodule Towerops.LLM.NetworkInsightPrompt do
|
|||
comments on findings the rule-based workers already produced.
|
||||
"""
|
||||
|
||||
require Logger
|
||||
|
||||
@valid_urgencies ~w(critical warning info)
|
||||
|
||||
@system """
|
||||
|
|
@ -71,12 +73,21 @@ defmodule Towerops.LLM.NetworkInsightPrompt do
|
|||
observations =
|
||||
case decode(cleaned) do
|
||||
{:ok, %{"observations" => list}} when is_list(list) ->
|
||||
list
|
||||
|> Enum.map(&normalize_observation/1)
|
||||
|> Enum.reject(&is_nil/1)
|
||||
|> Enum.take(@max_observations)
|
||||
raw_count = length(list)
|
||||
normalized = list |> Enum.map(&normalize_observation/1) |> Enum.reject(&is_nil/1)
|
||||
rejected = raw_count - length(normalized)
|
||||
|
||||
if rejected > 0 do
|
||||
Logger.warning("AI network insight: #{rejected}/#{raw_count} observations rejected by normalize_observation")
|
||||
end
|
||||
|
||||
Enum.take(normalized, @max_observations)
|
||||
|
||||
_ ->
|
||||
Logger.warning(
|
||||
"AI network insight: could not decode LLM response, content preview: #{String.slice(cleaned, 0, 200)}"
|
||||
)
|
||||
|
||||
[]
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue