AgentMonitor: A Plug-and-Play Framework for Predictive and Secure Multi-Agent Systems

Chi-Min Chan, Jianxuan Yu, Weize Chen, Chunyang Jiang, Xinyu Liu, Weijie Shi, Zhiyuan Liu, Wei Xue, Yike Guo

Abstract

The rapid advancement of large language models (LLMs) has led to the rise of LLM-based agents. Recent research shows that multi-agent systems (MAS), where each agent plays a specific role, can outperform individual LLMs. However, configuring an MAS for a task remains challenging, with performance only observable post-execution. Inspired by scaling laws in LLM development, we investigate whether MAS performance can be predicted beforehand. We introduce AgentMonitor, a framework that integrates at the agent level to capture inputs and outputs, transforming them into statistics for training a regression model to predict task performance. Additionally, it can further apply real-time corrections to address security risks posed by malicious agents, mitigating negative impacts and enhancing MAS security. Experiments demonstrate that an XGBoost model achieves a Spearman correlation of 0.89 in-domain and 0.58 in more challenging scenarios. Furthermore, using AgentMonitor reduces harmful content by 6.2% and increases helpful content by 1.8% on average, enhancing safety and reliability.

Introduction

Large Language Model (LLM) agents are increasingly organized into collaborative Multi-Agent Systems (MAS) to solve complex tasks. However, two major hurdles remain: predictability and security. Currently, configuring a MAS is a process of trial and error because performance is only observable after execution. This makes designing an optimal architecture resource-intensive and inefficient. Furthermore, MAS are vulnerable; a single malicious agent—whether through prompt injection or inherent misalignment—can spread harmful content or derail the entire team’s objective.

The challenge of predicting MAS performance: a system with a 'dummy' agent where task outcomes are unknown prior to execution.

AgentMonitor addresses these issues by determining if we can predict how well a MAS will perform before it finishes a task and if we can intercept and correct harmful behaviors without redesigning the entire system.

Methodology

AgentMonitor is a non-invasive framework that wraps around existing agents, much like Parameter-Efficient Fine-Tuning (PEFT) wraps around a model. It captures every input and output at each step of the communication pipeline.

Performance Prediction

The framework transforms captured interactions into "indicators," including LLM-judged scores (Personal and Collective) and graph-theoretic metrics such as PageRank and Transitivity. These indicators are fed into an XGBoost regression model to predict the final task score. An ablation study showed that observing only 10% of total execution data allows for a 0.82 correlation with the final result, enabling developers to terminate underperforming configurations early.

On-the-fly Correction

AgentMonitor uses a "post-edit" feature where a secondary, more aligned LLM reviews and modifies agent responses in real-time to ensure they remain helpful and harmless.

A standard multi-agent architecture (Reviewer-Coder-Tester) showing high performance across multiple tasks.

Results and Key Insights

The researchers evaluated AgentMonitor across performance benchmarks (HumanEval, MMLU, GSM8K, MINT) and safety benchmarks (Beavertails, MaliciousInstruct, AdvBench) using models like Llama3 and ChatGPT.

  • High Predictability: In "in-domain" settings, the framework achieved a 0.89 Spearman rank correlation between predicted and actual scores. In cross-task scenarios, it maintained a correlation of 0.58.
  • Structural Importance: Communication structure matters. Metrics like "Transitivity" help the model understand if information is flowing efficiently between agents.
  • Safety Improvements: When a malicious agent was introduced, AgentMonitor reduced harmful content by 6.2% and increased helpfulness by 1.8% on average.
  • Non-Invasiveness: The framework can be integrated with a single line of code, making it highly practical for existing engineering workflows.

Conclusion

While AgentMonitor significantly improves MAS predictability and security, challenges remain. The "alignment tax" means that making responses safer can sometimes slightly reduce utility. Additionally, real-time post-editing adds computational latency. Future work will explore dynamic activation of the monitor to balance safety and performance. Overall, AgentMonitor provides a critical foundation for understanding the "scaling laws" of multi-agent collaboration.

Summary updated

BibTeX
@misc{chan2024agentmonitor,
  author = {Chi-Min Chan and Jianxuan Yu and Weize Chen and Chunyang Jiang and Xinyu Liu and Weijie Shi and Zhiyuan Liu and Wei Xue and Yike Guo},
  title = {{AgentMonitor: A Plug-and-Play Framework for Predictive and Secure Multi-Agent Systems}},
  year = {2024},
  eprint = {2408.14972},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.14972},
}
Figure