feat(guards): implement guard enforcement for denylist, budget caps, and tool call limits #5012

Open
opened 2026-04-09 00:47:58 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: feat(guards): implement guard enforcement for denylist, budget caps, and tool call limits
  • Branch: feat/m6/guard-enforcement-core
  • Milestone: v3.5.0
  • Parent Epic: #4951

Background and Context

The CleverAgents system needs to enforce guards during plan execution to prevent unsafe operations. Guards include: denylist (blocked tool patterns), budget caps (max cost/tokens), and tool call limits (max calls per execution).

Expected Behavior

  • GuardEnforcer.check_tool_call(tool_name, args) raises GuardViolationError if tool is denylisted
  • GuardEnforcer.check_budget(current_cost) raises BudgetExceededError if budget cap exceeded
  • GuardEnforcer.check_tool_call_limit(call_count) raises ToolCallLimitError if limit exceeded
  • Guards are enforced during plan execution before each tool call

Acceptance Criteria

  • GuardEnforcer service implemented in src/cleveragents/guards/
  • Denylist enforcement: tool calls matching denylist patterns are blocked
  • Budget cap enforcement: execution stops when budget exceeded
  • Tool call limit enforcement: execution stops when limit exceeded
  • GuardEnforcer is wired into plan execution pipeline
  • Unit tests (Behave) cover all guard types
  • Integration test (Robot) verifies guard enforcement end-to-end

Subtasks

  • Implement GuardEnforcer service class
  • Implement denylist pattern matching
  • Implement budget cap enforcement
  • Implement tool call limit enforcement
  • Wire GuardEnforcer into plan execution pipeline
  • Tests (Behave): Add scenarios for each guard type
  • Tests (Robot): Add integration test
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Supervisor: Epic Planning | Agent: epic-planner

## Metadata - **Commit Message**: `feat(guards): implement guard enforcement for denylist, budget caps, and tool call limits` - **Branch**: `feat/m6/guard-enforcement-core` - **Milestone**: v3.5.0 - **Parent Epic**: #4951 ## Background and Context The CleverAgents system needs to enforce guards during plan execution to prevent unsafe operations. Guards include: denylist (blocked tool patterns), budget caps (max cost/tokens), and tool call limits (max calls per execution). ## Expected Behavior - `GuardEnforcer.check_tool_call(tool_name, args)` raises `GuardViolationError` if tool is denylisted - `GuardEnforcer.check_budget(current_cost)` raises `BudgetExceededError` if budget cap exceeded - `GuardEnforcer.check_tool_call_limit(call_count)` raises `ToolCallLimitError` if limit exceeded - Guards are enforced during plan execution before each tool call ## Acceptance Criteria - [ ] `GuardEnforcer` service implemented in `src/cleveragents/guards/` - [ ] Denylist enforcement: tool calls matching denylist patterns are blocked - [ ] Budget cap enforcement: execution stops when budget exceeded - [ ] Tool call limit enforcement: execution stops when limit exceeded - [ ] `GuardEnforcer` is wired into plan execution pipeline - [ ] Unit tests (Behave) cover all guard types - [ ] Integration test (Robot) verifies guard enforcement end-to-end ## Subtasks - [ ] Implement `GuardEnforcer` service class - [ ] Implement denylist pattern matching - [ ] Implement budget cap enforcement - [ ] Implement tool call limit enforcement - [ ] Wire `GuardEnforcer` into plan execution pipeline - [ ] Tests (Behave): Add scenarios for each guard type - [ ] Tests (Robot): Add integration test - [ ] Verify coverage >=97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Supervisor: Epic Planning | Agent: epic-planner
HAL9000 added this to the v3.5.0 milestone 2026-04-09 00:48:27 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High — Guard enforcement is critical for safe autonomous execution; denylist, budget caps, and tool call limits prevent unsafe operations
  • Milestone: v3.5.0
  • Story Points: 8 — XL — Implementing GuardEnforcer service with 3 guard types and wiring into plan execution pipeline
  • MoSCoW: Must Have — Guard enforcement is required for the Autonomy Hardening milestone; without it, the system cannot safely execute plans autonomously
  • Parent Epic: #4951

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: High — Guard enforcement is critical for safe autonomous execution; denylist, budget caps, and tool call limits prevent unsafe operations - **Milestone**: v3.5.0 - **Story Points**: 8 — XL — Implementing GuardEnforcer service with 3 guard types and wiring into plan execution pipeline - **MoSCoW**: Must Have — Guard enforcement is required for the Autonomy Hardening milestone; without it, the system cannot safely execute plans autonomously - **Parent Epic**: #4951 --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#5012
No description provided.