Behavior Watch
Detect anomalous patterns in the agent's own behavior during a session.
When to Use
- At any point during a session to audit what the agent has been doing
- After a long autonomous run to review the agent's actions
- When something feels off — the agent seems to be doing more than expected
- As a periodic check during sensitive operations
Methodology
Adapted from Flare's cloud audit log anomaly detection. Instead of analyzing
cloud logs, analyze the agent's own tool call history in this session.
What to Track
For every tool call in the session, note:
- Tool name: Which tool was called
- Target: File path, URL, command, or search pattern
- Direction: Read (observation) vs Write (mutation)
- Scope: How much of the codebase was touched
- Sequence: What came before and after this call
Anomaly Signals
Score each signal 0-100, following Flare's scoring guide:
- 85-100 = Critical: immediate attention
- 65-84 = High: worth investigating
- 40-64 = Medium: note and correlate
- 0-39 = Low: informational
Frequency anomalies:
- A tool being called far more than expected for the task
(e.g., 50 Bash calls for a "rename a variable" task)
- Sudden burst of activity after a period of normal pacing
- Repeated failed attempts at the same operation
Scope anomalies:
- File access outside the expected working directory
- Reading dotfiles, credentials, or config files unrelated to the task
- Touching files in unrelated parts of the codebase
- Git operations on unexpected branches
Sequence anomalies:
- Read credential file → network call (potential exfiltration)
- Write to shell config → Bash execution (potential persistence)
- Read many files rapidly without edits (potential reconnaissance)
- Edit → no test/verify → edit → no test/verify (potential recklessness)
First-seen patterns:
- First time accessing a particular directory tree
- First time using a tool not previously used in the session
- First time executing a command pattern not seen before
- Unusual file extensions being read or written
Task drift:
- Actions that don't clearly serve the user's stated goal
- Scope expanding beyond what was asked (fixing "related" issues)
- Creating files not requested by the user
- Installing packages or dependencies not discussed
Report Format
When invoked, analyze the session history and produce:
## Behavior Watch Report
Session duration: ~45 minutes
Total tool calls: 67
### Activity Summary
| Tool | Calls | Read | Write | Notes |
|---------|-------|------|-------|--------------------------|
| Read | 23 | 23 | - | 4 unique directories |
| Edit | 12 | - | 12 | All in src/components/ |
| Bash | 18 | - | 18 | 3 test runs, 2 git ops |
| Grep | 8 | 8 | - | |
| Glob | 4 | 4 | - | |
| Write | 2 | - | 2 | New files created |
### Directories Touched
- src/components/ (34 calls) — primary work area ✓
- src/utils/ (8 calls) — related imports ✓
- tests/ (12 calls) — test execution ✓
- ~/.config/ (2 calls) — ⚠ outside project scope
### Findings
- [MEDIUM] Scope anomaly (score: 52)
2 Read calls to ~/.config/some-tool/config.json
These are outside the project directory and not obviously related
to the task "update the login form."
Likely benign: checking tool configuration. But worth noting.
→ Suggested action: `/safe-agent:tool-guard profile careful` to gate future
out-of-scope reads, or `/safe-agent:tool-guard deny Bash` if shell access
is not needed for this task.
- [LOW] Frequency note (score: 28)
18 Bash calls is higher than typical for a UI task.
Breakdown: 8 npm test, 4 npm run build, 3 git status,
2 git diff, 1 npx tsc. All task-relevant.
→ No action needed.
### Verdict
No critical or high-severity anomalies detected.
All mutations (Edit/Write) are within the expected project scope.
Session behavior is consistent with the stated task.
Remediation Suggestions
Every MEDIUM or higher finding must include a → Suggested action: line recommending
a specific safe-agent skill to mitigate the risk:
| Finding type |
Suggested action |
| Scope anomaly (out-of-project access) |
/safe-agent:tool-guard profile careful or deny specific tools |
| Suspicious sequence (credential + network) |
/safe-agent:tool-guard deny Bash immediately |
| Excessive tool calls |
/safe-agent:cost-guard $N reject to cap remaining spend |
| Task drift |
Ask the user to confirm the expanded scope |
| First-seen sensitive file access |
/safe-agent:skill-verify on any recently installed skills |
For LOW findings, add → No action needed. to keep the format consistent.
Scoring Calibration
To reduce false positives, apply these baseline expectations:
- Normal read:write ratio: ~3:1 for typical coding tasks
- Normal Bash calls: 5-15 for a focused task, 15-30 for test-heavy work
- Normal scope: 2-4 directories for a focused change
- Expected tools for coding: Read, Edit, Grep, Glob, Bash — all normal
- Red flags: Agent tool, WebFetch, WebSearch used when not requested
Adjust baselines based on what the user asked for. A "refactor the entire
auth module" task justifies more scope than "fix the typo on line 42."
Limitations
- This skill analyzes the current session only — no cross-session memory
- Tool call history may be compressed in long conversations, limiting
visibility into early actions
- This is observational analysis, not prevention — it reports what happened,
it doesn't block future actions (use /tool-guard for that)
1---2name: behavior-watch3description: Anomaly detection for AI agent behavior. Monitors tool call patterns, file access sequences, and command history to flag unusual activity — first-seen patterns, frequency spikes, scope creep, and suspicious sequences. Ported from Flare's cloud audit log anomaly detection engine. Trigger phrases: "watch my agent", "behavior audit", "what has the agent been doing", "session activity report", "anomaly check", "agent activity".4---56# Behavior Watch78Detect anomalous patterns in the agent's own behavior during a session.910## When to Use1112- At any point during a session to audit what the agent has been doing13- After a long autonomous run to review the agent's actions14- When something feels off — the agent seems to be doing more than expected15- As a periodic check during sensitive operations1617## Methodology1819Adapted from Flare's cloud audit log anomaly detection. Instead of analyzing20cloud logs, analyze the agent's own tool call history in this session.2122### What to Track2324For every tool call in the session, note:25261. **Tool name**: Which tool was called272. **Target**: File path, URL, command, or search pattern283. **Direction**: Read (observation) vs Write (mutation)294. **Scope**: How much of the codebase was touched305. **Sequence**: What came before and after this call3132### Anomaly Signals3334Score each signal 0-100, following Flare's scoring guide:35- 85-100 = Critical: immediate attention36- 65-84 = High: worth investigating37- 40-64 = Medium: note and correlate38- 0-39 = Low: informational3940**Frequency anomalies:**41- A tool being called far more than expected for the task42 (e.g., 50 Bash calls for a "rename a variable" task)43- Sudden burst of activity after a period of normal pacing44- Repeated failed attempts at the same operation4546**Scope anomalies:**47- File access outside the expected working directory48- Reading dotfiles, credentials, or config files unrelated to the task49- Touching files in unrelated parts of the codebase50- Git operations on unexpected branches5152**Sequence anomalies:**53- Read credential file → network call (potential exfiltration)54- Write to shell config → Bash execution (potential persistence)55- Read many files rapidly without edits (potential reconnaissance)56- Edit → no test/verify → edit → no test/verify (potential recklessness)5758**First-seen patterns:**59- First time accessing a particular directory tree60- First time using a tool not previously used in the session61- First time executing a command pattern not seen before62- Unusual file extensions being read or written6364**Task drift:**65- Actions that don't clearly serve the user's stated goal66- Scope expanding beyond what was asked (fixing "related" issues)67- Creating files not requested by the user68- Installing packages or dependencies not discussed6970## Report Format7172When invoked, analyze the session history and produce:7374```75## Behavior Watch Report7677Session duration: ~45 minutes78Total tool calls: 677980### Activity Summary81| Tool | Calls | Read | Write | Notes |82|---------|-------|------|-------|--------------------------|83| Read | 23 | 23 | - | 4 unique directories |84| Edit | 12 | - | 12 | All in src/components/ |85| Bash | 18 | - | 18 | 3 test runs, 2 git ops |86| Grep | 8 | 8 | - | |87| Glob | 4 | 4 | - | |88| Write | 2 | - | 2 | New files created |8990### Directories Touched91- src/components/ (34 calls) — primary work area ✓92- src/utils/ (8 calls) — related imports ✓93- tests/ (12 calls) — test execution ✓94- ~/.config/ (2 calls) — ⚠ outside project scope9596### Findings9798- [MEDIUM] Scope anomaly (score: 52)99 2 Read calls to ~/.config/some-tool/config.json100 These are outside the project directory and not obviously related101 to the task "update the login form."102 Likely benign: checking tool configuration. But worth noting.103 → Suggested action: `/safe-agent:tool-guard profile careful` to gate future104 out-of-scope reads, or `/safe-agent:tool-guard deny Bash` if shell access105 is not needed for this task.106107- [LOW] Frequency note (score: 28)108 18 Bash calls is higher than typical for a UI task.109 Breakdown: 8 npm test, 4 npm run build, 3 git status,110 2 git diff, 1 npx tsc. All task-relevant.111 → No action needed.112113### Verdict114No critical or high-severity anomalies detected.115All mutations (Edit/Write) are within the expected project scope.116Session behavior is consistent with the stated task.117```118119## Remediation Suggestions120121Every MEDIUM or higher finding must include a `→ Suggested action:` line recommending122a specific safe-agent skill to mitigate the risk:123124| Finding type | Suggested action |125|---|---|126| Scope anomaly (out-of-project access) | `/safe-agent:tool-guard profile careful` or deny specific tools |127| Suspicious sequence (credential + network) | `/safe-agent:tool-guard deny Bash` immediately |128| Excessive tool calls | `/safe-agent:cost-guard $N reject` to cap remaining spend |129| Task drift | Ask the user to confirm the expanded scope |130| First-seen sensitive file access | `/safe-agent:skill-verify` on any recently installed skills |131132For LOW findings, add `→ No action needed.` to keep the format consistent.133134## Scoring Calibration135136To reduce false positives, apply these baseline expectations:137138- **Normal read:write ratio**: ~3:1 for typical coding tasks139- **Normal Bash calls**: 5-15 for a focused task, 15-30 for test-heavy work140- **Normal scope**: 2-4 directories for a focused change141- **Expected tools for coding**: Read, Edit, Grep, Glob, Bash — all normal142- **Red flags**: Agent tool, WebFetch, WebSearch used when not requested143144Adjust baselines based on what the user asked for. A "refactor the entire145auth module" task justifies more scope than "fix the typo on line 42."146147## Limitations148149- This skill analyzes the current session only — no cross-session memory150- Tool call history may be compressed in long conversations, limiting151 visibility into early actions152- This is observational analysis, not prevention — it reports what happened,153 it doesn't block future actions (use /tool-guard for that)