Skip to main content
This tutorial covers @xpert-ai/plugin-agent-behavior-monitor from xpert-plugins, used to detect and handle abnormal agent behavior during runtime.

What It Detects

  • prompt_injection: prompt injection on user input (LLM judge)
  • sensitive_instruction: risky/forbidden instructions on user input (LLM judge)
  • high_frequency: high-frequency tool calls (counter-based)
  • repeat_failure: repeated tool failures (counter-based)

Available Actions

  • alert_only: record hit and continue
  • block: block current stage and return alert message
  • end_run: terminate the run and return alert message

Install and Enable

  1. Install the plugin package in your host project:
  1. Enable the plugin through environment variables:
  1. Follow Publish & Use to ensure the host loads the plugin.

Minimal Configuration Examples

1) Prompt Injection Blocking

Recommended test input:

2) High-Frequency Tool Call Blocking

Key Fields

  • evidenceMaxLength: max evidence length stored for each hit (default 240)
  • ringBufferSize: runtime trace ring buffer size (default 120)
  • target: derived from ruleType automatically
  • Input rules (prompt_injection, sensitive_instruction) require judgeModel

Audit and Debugging

Each run writes a snapshot. Check:
  • ringBuffer: events like llm_judge, tool_call, tool_error
  • hits: matched rules
  • summary: total hits, blocked count, terminated flag