AgentGuard supports three protection modes that can be initialized with the mode
Parameter Configuration:
- throw: Error thrown on overrun, for cases where manual handling is required. Developers can catch errors with try-catch and customize the handling logic.
- notify: Sends notifications when overruns occur (e.g., via a configured webhook), but does not terminate the process. Ideal for scenarios where you need to keep running but need to be reminded.
- kill: Direct process termination in case of cost overruns, suitable for environments with strict budget control.
Configuration example:const guard = await agentGuard.init({ limit: 100, mode: 'throw', webhook: 'https://hooks.slack.com/...' });
. Additionally, the protection model and budget cap can be used by guard.setLimit()
Dynamic adjustment.
This answer comes from the articleAgentGuard: A Tool for Monitoring AI Agent Costs in Real Time and Preventing OverspendingThe