API reference
Core
AgentGuard — inter-agent security firewall for multi-agent AI systems.
- class agentguard.AgentGuard(risk_threshold=0.85, enable_trust_attestation=True, enable_capability_enforcement=True, audit_log_path='./audit.jsonl', mode='enforce', task_objective=None, enable_consistency_check=True, consistency_threshold=0.1, consistency_ml_risk_floor=0.75, model_path=None, require_ml_model=False, enable_otel_export=False, include_message_preview=True, max_message_bytes=1048576)[source]
Bases:
objectInter-agent security middleware entry point.
- Parameters:
risk_threshold (float)
enable_trust_attestation (bool)
enable_capability_enforcement (bool)
audit_log_path (str | None)
mode (str)
task_objective (str | None)
enable_consistency_check (bool)
consistency_threshold (float)
consistency_ml_risk_floor (float)
model_path (str | None)
require_ml_model (bool)
enable_otel_export (bool)
include_message_preview (bool)
max_message_bytes (int)
- check_data_source(agent_id, data_source)[source]
Validate data-source access; False when blocked in enforce mode.
- check_endpoint(agent_id, endpoint)[source]
Validate an external endpoint; False when blocked in enforce mode.
- check_output_tokens(agent_id, token_count)[source]
Validate output size; False when blocked in enforce mode.
- check_tool_call(agent_id, tool_name, *, endpoint=None)[source]
Validate a tool call; False when blocked in enforce mode.
- get_manifest(agent_id)[source]
Return the registered capability manifest for an agent, if any.
- Parameters:
agent_id (str)
- Return type:
CapabilityManifest | None
- inspect_content(sender_id, recipient_id, message)[source]
Inspect unsigned content (rules + ML + consistency, no trust check).
Use this at boundaries where messages cannot carry Ed25519 signatures — user input, framework middleware hooks, or third-party content. The decision is audited like any other inspection.
- Parameters:
- Return type:
- inspect_message(sender_id, recipient_id, message, payload_bytes, *, signature=None)[source]
Run inspection, trust, and size checks on a message.
- inspect_tool_output(tool_name, output, agent_id)[source]
Inspect a tool return value for poisoning; audits the decision.
- Parameters:
- Return type:
- register_agent(agent_id, manifest)[source]
Register agent identity, trust keys, and capability manifest.
- Parameters:
agent_id (str)
manifest (CapabilityManifest)
- Return type:
None
- register_delegated_agent(parent_agent_id, child_manifest)[source]
Register a sub-agent with monotonic capability attenuation.
- Parameters:
parent_agent_id (str)
child_manifest (CapabilityManifest)
- Return type:
- sign_payload(sender_id, payload_bytes, *, recipient_id, nonce=None)[source]
Sign an inter-agent envelope (sender, recipient, nonce, payload).
The returned wire signature binds the recipient and a unique nonce so a previously signed payload cannot be redirected or silently replayed. Pass the bytes unchanged to
inspect_message()assignature.
- exception agentguard.AgentGuardException(action, sender_id, recipient_id, risk_score, trust_result, capability_result, failure_reason)[source]
Bases:
ExceptionRaised when AgentGuard blocks or quarantines an inter-agent message.
- Parameters:
- Return type:
None
- class agentguard.CapabilityManifest(agent_id, permitted_tools=<factory>, forbidden_tools=<factory>, allowed_data_sources=<factory>, permitted_endpoints=<factory>, max_output_tokens=4096, external_contact=False, can_spawn_agents=False, max_delegation_depth=0)[source]
Bases:
objectDeclarative runtime capability scope for an agent.
- Parameters:
- attenuate(other)[source]
Return monotonic attenuation: intersection of both manifests.
- Parameters:
other (CapabilityManifest) – Sub-agent manifest to attenuate against this manifest.
- Returns:
New manifest with reduced (never expanded) permissions.
- Return type:
- classmethod from_dict(data)[source]
Build a manifest from an already-validated dictionary.
- Parameters:
- Return type:
- classmethod from_yaml(path)[source]
Load and validate a manifest from a YAML file.
- Parameters:
path (str) – Path to the YAML manifest file.
- Returns:
Validated CapabilityManifest instance.
- Raises:
jsonschema.ValidationError – If validation fails.
ValueError – If YAML content is invalid.
- Return type:
- is_data_source_allowed(data_source)[source]
Return True if the data source is explicitly listed.
An empty
allowed_data_sourceslist is deny-by-default so that attenuation intersections cannot accidentally expand access.
- is_endpoint_permitted(endpoint)[source]
Return True if external contact is allowed and the endpoint matches.
Matching is URL-aware: scheme, host, and port must match an allow-list entry exactly; the path is matched as a segment-safe prefix (
/v1permits/v1/reportsbut not/v1evil).
Firewall
AgentGuard firewall — public entry point.
- class agentguard.firewall.AgentGuard(risk_threshold=0.85, enable_trust_attestation=True, enable_capability_enforcement=True, audit_log_path='./audit.jsonl', mode='enforce', task_objective=None, enable_consistency_check=True, consistency_threshold=0.1, consistency_ml_risk_floor=0.75, model_path=None, require_ml_model=False, enable_otel_export=False, include_message_preview=True, max_message_bytes=1048576)[source]
Bases:
objectInter-agent security middleware entry point.
- Parameters:
risk_threshold (float)
enable_trust_attestation (bool)
enable_capability_enforcement (bool)
audit_log_path (str | None)
mode (str)
task_objective (str | None)
enable_consistency_check (bool)
consistency_threshold (float)
consistency_ml_risk_floor (float)
model_path (str | None)
require_ml_model (bool)
enable_otel_export (bool)
include_message_preview (bool)
max_message_bytes (int)
- check_data_source(agent_id, data_source)[source]
Validate data-source access; False when blocked in enforce mode.
- check_endpoint(agent_id, endpoint)[source]
Validate an external endpoint; False when blocked in enforce mode.
- check_output_tokens(agent_id, token_count)[source]
Validate output size; False when blocked in enforce mode.
- check_tool_call(agent_id, tool_name, *, endpoint=None)[source]
Validate a tool call; False when blocked in enforce mode.
- get_manifest(agent_id)[source]
Return the registered capability manifest for an agent, if any.
- Parameters:
agent_id (str)
- Return type:
CapabilityManifest | None
- inspect_content(sender_id, recipient_id, message)[source]
Inspect unsigned content (rules + ML + consistency, no trust check).
Use this at boundaries where messages cannot carry Ed25519 signatures — user input, framework middleware hooks, or third-party content. The decision is audited like any other inspection.
- Parameters:
- Return type:
- inspect_message(sender_id, recipient_id, message, payload_bytes, *, signature=None)[source]
Run inspection, trust, and size checks on a message.
- inspect_tool_output(tool_name, output, agent_id)[source]
Inspect a tool return value for poisoning; audits the decision.
- Parameters:
- Return type:
- register_agent(agent_id, manifest)[source]
Register agent identity, trust keys, and capability manifest.
- Parameters:
agent_id (str)
manifest (CapabilityManifest)
- Return type:
None
- register_delegated_agent(parent_agent_id, child_manifest)[source]
Register a sub-agent with monotonic capability attenuation.
- Parameters:
parent_agent_id (str)
child_manifest (CapabilityManifest)
- Return type:
- sign_payload(sender_id, payload_bytes, *, recipient_id, nonce=None)[source]
Sign an inter-agent envelope (sender, recipient, nonce, payload).
The returned wire signature binds the recipient and a unique nonce so a previously signed payload cannot be redirected or silently replayed. Pass the bytes unchanged to
inspect_message()assignature.
Capability manifests
YAML capability manifest loading and validation.
- class agentguard.capability.manifest.CapabilityManifest(agent_id, permitted_tools=<factory>, forbidden_tools=<factory>, allowed_data_sources=<factory>, permitted_endpoints=<factory>, max_output_tokens=4096, external_contact=False, can_spawn_agents=False, max_delegation_depth=0)[source]
Bases:
objectDeclarative runtime capability scope for an agent.
- Parameters:
- attenuate(other)[source]
Return monotonic attenuation: intersection of both manifests.
- Parameters:
other (CapabilityManifest) – Sub-agent manifest to attenuate against this manifest.
- Returns:
New manifest with reduced (never expanded) permissions.
- Return type:
- classmethod from_dict(data)[source]
Build a manifest from an already-validated dictionary.
- Parameters:
- Return type:
- classmethod from_yaml(path)[source]
Load and validate a manifest from a YAML file.
- Parameters:
path (str) – Path to the YAML manifest file.
- Returns:
Validated CapabilityManifest instance.
- Raises:
jsonschema.ValidationError – If validation fails.
ValueError – If YAML content is invalid.
- Return type:
- is_data_source_allowed(data_source)[source]
Return True if the data source is explicitly listed.
An empty
allowed_data_sourceslist is deny-by-default so that attenuation intersections cannot accidentally expand access.
- is_endpoint_permitted(endpoint)[source]
Return True if external contact is allowed and the endpoint matches.
Matching is URL-aware: scheme, host, and port must match an allow-list entry exactly; the path is matched as a segment-safe prefix (
/v1permits/v1/reportsbut not/v1evil).
ML scorer
Production ML risk scorer using ONNX DeBERTa model.
- class agentguard.inspector.ml_scorer.MLRiskScorer[source]
Bases:
objectONNX inference wrapper for inter-agent injection risk scoring.
- exception agentguard.inspector.ml_scorer.ModelIntegrityError[source]
Bases:
ExceptionRaised when ONNX model hash does not match the pinned value.
- exception agentguard.inspector.ml_scorer.ModelNotLoadedWarning[source]
Bases:
UserWarningEmitted when score() is called without a loaded model.
MCP output inspection
MCP tool output inspection before agent ingestion.
- class agentguard.mcp.output_inspector.MCPInspectionResult(safe, risk_score, flagged_patterns, tool_name, calling_agent_id)[source]
Bases:
objectResult of inspecting an MCP tool return value.
- Parameters:
- class agentguard.mcp.output_inspector.MCPOutputInspector(rule_filter, ml_scorer, threshold=0.85)[source]
Bases:
objectInspects MCP server tool outputs for injection payloads.
- Parameters:
rule_filter (InjectionRuleFilter)
ml_scorer (MLRiskScorer)
threshold (float)
- inspect_output(tool_name, output, calling_agent_id)[source]
Score MCP tool output for injection risk.
- Parameters:
- Return type:
- exception agentguard.mcp.output_inspector.MCPPoisoningException(*, tool_name, agent_id, risk_score, flagged_patterns, action='QUARANTINE', sender_id='', recipient_id='', trust_result='SKIP', capability_result='SKIP', failure_reason=None)[source]
Bases:
AgentGuardExceptionRaised when MCP tool output contains an injection payload.