Skip to content

feature(agent): pre-computed baseline-delta finding strings#249

Open
nghiadaulau wants to merge 1 commit into
VersusControl:mainfrom
nghiadaulau:feat/agent-baseline-delta
Open

feature(agent): pre-computed baseline-delta finding strings#249
nghiadaulau wants to merge 1 commit into
VersusControl:mainfrom
nghiadaulau:feat/agent-baseline-delta

Conversation

@nghiadaulau

Copy link
Copy Markdown
Member

Summary

Agent incidents (and the detect prompt) showed raw frequency and
ewma_baseline, leaving an operator — or the model — to divide the two to
judge how abnormal a spike is. This adds AgentResult.BaselineDelta(), a
ready human phrase:

240 this tick vs baseline 6.1/tick (39× normal)

New patterns with no baseline yet read 240 this tick (no baseline yet).

Why

The magnitude ("39× normal") is the single most useful number on an agent
alert, and asking the LLM to compute it invites arithmetic mistakes in the
narrative. Computing it once in code and citing it everywhere keeps the
channel message and the model's reasoning consistent.

Changes

  • pkg/coreAgentResult.BaselineDelta() (one source of truth shared by
    the templates and the prompt; integer rounding at ≥10×, one decimal
    below).
  • pkg/services/agent.go — additive BaselineDelta content key.
  • pkg/agent/ai/detect/prompt.gobaseline_delta line so the model
    cites the phrase verbatim rather than dividing.
  • All six default agent channel templates render it in place of the terse
    (baseline X) parenthetical. Frequency / Baseline keys are unchanged
    for custom templates.

Testing

  • pkg/core table-driven test: big spike rounds to an integer multiple, a
    small multiple keeps one decimal, the 10× threshold, and the
    no-baseline / zero-frequency edges.
  • gofmt, go vet, go build ./...,
    go test -race ./pkg/core ./pkg/services ./pkg/agent/ai/detect green.

Checklist

  • Table-driven test for the new helper
  • Additive content key; existing fields unchanged
  • All six channel templates updated
  • House conventions (feature: prefix); docs + CHANGELOG

Agent incidents and the detect prompt showed raw frequency and EWMA
baseline, leaving an operator — or the model — to divide them to judge how
abnormal a spike is. Add AgentResult.BaselineDelta(), a ready human phrase
like "240 this tick vs baseline 6.1/tick (39× normal)" (new patterns read
"240 this tick (no baseline yet)").

- pkg/core: BaselineDelta() on AgentResult (one source of truth for the
  channel templates and the detect prompt — avoids duplicating the math).
- services/agent.go: new additive BaselineDelta content key.
- detect prompt: baseline_delta line so the model cites the magnitude
  verbatim instead of computing it.
- All six default agent channel templates render it in place of the terse
  "(baseline X)" parenthetical. Frequency / Baseline keys are unchanged for
  custom templates.

Tests: table-driven BaselineDelta() (big spike rounds to integer, small
multiple keeps a decimal, no-baseline and zero-frequency edge cases).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant