Skip to content

feat: v0.15.0 — per-operation enforcement in watch mode - #31

Merged
Siddhant-K-code merged 2 commits into
mainfrom
feat/v0.15.0-per-operation-enforcement
Apr 11, 2026
Merged

Siddhant-K-code merged 2 commits into
mainfrom
feat/v0.15.0-per-operation-enforcement

Conversation

@Siddhant-K-code

Copy link
Copy Markdown
Owner

Closes #21

What

Extends watch.py with per-operation enforcement rules that can alert or block specific tool calls without killing the entire session.

How it works

OperationRule matches on tool name + glob pattern:

{
  "operation_rules": [
    {"tool": "bash",  "pattern": "rm *",   "action": "block", "reason": "no deletions"},
    {"tool": "write", "pattern": "*.env",  "action": "alert"},
    {"tool": "*",     "pattern": "*/prod/*","action": "alert", "reason": "prod access"}
  ]
}

Rules fire at most once per unique (tool, pattern, target) combination to avoid alert fatigue.

Also integrates TokenBudgetWatcher into the watch loop — fires when cumulative input tokens cross max_context_pct (default 90%) of the model's context window.

Tests

tests/test_watch_operations.py — 12 tests.

Ona and others added 2 commits April 11, 2026 16:31
Adds OperationRule dataclass and per-operation check in check_event().
Rules match tool name + glob pattern and can alert or block specific
operations (e.g. block bash 'rm *', alert write '*.env'). Rules are
configured via operation_rules in .agent-watch.json.

Also integrates TokenBudgetWatcher into watch mode: fires when context
window usage crosses max_context_pct threshold (default 90%).

CLI: --max-context-pct flag on agent-strace watch

Closes #21

Co-authored-by: Ona <no-reply@ona.com>
TokenBudgetWatcher is introduced in v0.21.0. The watch.py integration
uses a try/except ImportError so the per-operation enforcement branch
passes CI independently. Token budget tests that require the module are
deferred to the v0.21.0 branch.

Co-authored-by: Ona <no-reply@ona.com>
@Siddhant-K-code
Siddhant-K-code merged commit 3630a27 into main Apr 11, 2026
4 checks passed
@Siddhant-K-code
Siddhant-K-code deleted the feat/v0.15.0-per-operation-enforcement branch April 11, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v0.15.0: Per-operation enforcement in watch mode - reject tool calls without killing the session

1 participant