Establish a behavioral baseline for the agent and continuously monitor for deviations that may indicate compromise, misconfiguration, or abuse.
Always-on monitoring via hooks:
PostToolUse — log every tool invocationUserPromptSubmit — log input patternsPostSkillExecution — log skill resultsMetricBaseline UnitAlert ThresholdCommand exec frequencyper hour>2σ from 7-day avgFile access patternsunique paths/hour>2σNetwork request volumerequests/hour>2σSkill invocation frequencyper skill per hour>2σToken consumption ratetokens/hour>2σError rateerrors/hour>2σMemory write patternswrites/hour>2σCross-session messagesmessages/hour>2σNew file creation ratefiles/hour>2σUnique external domainsdomains/hour>2σ
Collect — append each action to .security/baseline/metrics.jsonl
Baseline — rolling 7-day average and standard deviation per metric
Compare — current window (1 hour) vs baseline
Classify:
NORMAL — within 1σELEVATED — between 1σ and 2σANOMALOUS — between 2σ and 3σCRITICAL — above 3σ or matches known attack signatureAlert — based on classification
ClassificationActionNORMALNo actionELEVATEDLog to anomaly.jsonlANOMALOUSLog + notify human via preferred channelCRITICALLog + notify + recommend pause (human decides)
.security/false-positives.jsonl