feat: add guard extension point for third-party security scanners#1165
Closed
PaoloC68 wants to merge 5 commits intoagent0ai:developmentfrom
Closed
feat: add guard extension point for third-party security scanners#1165PaoloC68 wants to merge 5 commits intoagent0ai:developmentfrom
PaoloC68 wants to merge 5 commits intoagent0ai:developmentfrom
Conversation
Collaborator
|
Hello, this is not something that should be implemented in agent.py directly, we're building the plugin system for this. |
Author
|
Fair point — you're right that this doesn't belong in agent.py. The guard system already works as a standalone plugin with zero core changes:
No modifications to agent.py, extension.py, or skills_import.py required. I'll publish it to the plugin index instead. Thanks for the feedback. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a guard extension point that lets third-party security scanners (e.g. Cisco AI Skill Scanner) block dangerous tools and prompts before they execute. This builds on top of the existing extension system and the newly merged plugin architecture (#998) — zero new abstractions, just the plumbing that lets plugins say "stop".
Problem
Agent Zero can install and run arbitrary skills, but there is currently no hook where a security tool can inspect and block:
Related issues: #1074, #1071, #943, #851
What Changed
1. Mutable
eventdict incall_extensions()(python/helpers/extension.py)eventdict with metadata (extension_point,agent, plus all kwargs)importlib.metadataentry points (group:agent_zero.guards)2. Blocking logic in
agent.py(two sites only)tool_execute_before: if any handler setsevent["blocked"] = True, the tool is skipped and aResponseis returned withevent["block_reason"]message_loop_prompts_after: if any handler setsevent["blocked"] = True, the LLM call is skipped and a warning is injected into the message history3.
skill_installextension point (python/helpers/skills_import.py)skill_nameandskill_path4. Guard utilities (
python/helpers/guard_utils.py)save_scan_status(skill_name, status)/get_scan_status(skill_name)— JSON file per skill inusr/skill_scans/SAFE,NEEDS_REVIEW,BLOCKED5. Example guard extensions (drop-in, no config needed)
python/extensions/tool_execute_before/_05_scan_status_guard.py— blocks tools linked to skills withBLOCKEDscan statuspython/extensions/message_loop_prompts_after/_05_prompt_length_guard.py— detects prompt injection patterns and oversized prompts6. Test suite (
tests/test_guard_system.py)Changes
agent.pytool_execute_beforeandmessage_loop_prompts_afterpython/helpers/extension.pypython/helpers/guard_utils.pypython/helpers/skills_import.pyskill_installextension point hookpython/extensions/tool_execute_before/_05_scan_status_guard.pypython/extensions/message_loop_prompts_after/_05_prompt_length_guard.pytests/test_guard_system.pyDesign Decisions
event["blocked"].tool_execute_beforeandmessage_loop_prompts_after. Minimal surface, maximum impact.[project.entry-points."agent_zero.guards"]— discovered automatically._05_prefix runs before default_10_extensions, following existing convention.Testing
All 16 tests pass. Rebased cleanly onto latest
development(one conflict inextension.pyresolved — kept upstream's_CACHE_AREA+extensibledecorator alongside guard's_guard_cache).