feature(agent): pre-computed baseline-delta finding strings#249
Open
nghiadaulau wants to merge 1 commit into
Open
feature(agent): pre-computed baseline-delta finding strings#249nghiadaulau wants to merge 1 commit into
nghiadaulau wants to merge 1 commit into
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agent incidents (and the detect prompt) showed raw
frequencyandewma_baseline, leaving an operator — or the model — to divide the two tojudge how abnormal a spike is. This adds
AgentResult.BaselineDelta(), aready human phrase:
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/core—AgentResult.BaselineDelta()(one source of truth shared bythe templates and the prompt; integer rounding at ≥10×, one decimal
below).
pkg/services/agent.go— additiveBaselineDeltacontent key.pkg/agent/ai/detect/prompt.go—baseline_deltaline so the modelcites the phrase verbatim rather than dividing.
(baseline X)parenthetical.Frequency/Baselinekeys are unchangedfor custom templates.
Testing
pkg/coretable-driven test: big spike rounds to an integer multiple, asmall multiple keeps one decimal, the
10×threshold, and theno-baseline / zero-frequency edges.
gofmt,go vet,go build ./...,go test -race ./pkg/core ./pkg/services ./pkg/agent/ai/detectgreen.Checklist
feature:prefix); docs + CHANGELOG