Call-owning middleware · PyPI 0.1.0 · Alpha · Apache-2.0
ag2-acgs for AG2 (AutoGen).
Adds tool execution middleware and human-approval gating to AG2 multi-agent conversations.
Package Specification · Inspected HEAD bbc8d87
- Framework maintainer
- AG2 · ag2.ai
- Upstream repository
- ag2ai/ag2
- PyPI release
- ag2-acgs==0.1.0
- Python requirement
- >=3.10
- Framework constraint
- ag2>=1.2.0,<2
- Governance engine pin
- acgs-lite>=3.0.1,<4
- Integration mechanic
- Call-owning middleware (wraps tool call)
- Hook entry point
- ACGSMiddleware.on_tool_execution
01 · Local Setup & Quickstart
Attach governance to one tool-calling agent.
Install the pinned release from PyPI alongside acgs-lite>=3.0.1,<4. Rule evaluation uses deterministic keyword and regex matching locally in Python—no external model or network call is made by the governance check.
Shell · PyPI installation
pip install "ag2-acgs==0.1.0"Python · AG2 (AutoGen) integration
src/ag2_acgs/middleware.py#L140from ag2 import Agent
from ag2_acgs import ACGSGuard
guard = ACGSGuard()
agent = Agent(
"assistant",
config=config,
tools=[send_email],
middleware=[guard.middleware],
)02 · Verdict & Review Mapping
How ACGS-Lite verdicts map to AG2 (AutoGen).
When a tool call is proposed, the adapter formats the tool name and arguments via format_tool_call and evaluates them against the configured Constitution. Blocking rules always take precedence over review rules.
Calls matching no blocking or review rules run through BaseMiddleware.on_tool_execution.
Skips execution and returns the ACGS violation message to the agent as the tool output.
Prompts human input via context.ask(ToolApprovalRequest(...)); runs only on 'yes', 'y', or '1'.
03 · Public API Surface
Exported symbols and source entry points.
Each adapter keeps its public surface minimal and re-exports the shared GovernanceDecision, Verdict, and ToolCallFormatter types alongside the framework-specific hook or middleware class.
__all__ exports · ag2-acgs
src/ag2_acgs/middleware.py#L140 ↗ACGSGuardACGSMiddlewareACGSConfigurationErrorUngovernedToolsErrorAPPROVALSDECISION_METADATA_KEYGovernanceDecisionToolCallFormatterVerdictformat_tool_callPrimary hook surface: ACGSMiddleware.on_tool_execution. Custom ToolCallFormatter functions may be supplied if your tool arguments require custom canonical serialization before rule matching.
04 · Scope & Bypass Boundaries
What this adapter does and does not cover.
Verify these framework-specific boundaries when integrating ag2-acgs into an evaluation workflow.
- 01
Fails with UngovernedToolsError before the turn starts if provider-hosted tools, TaskConfig sub-tasks, or sub-agents without ACGS are detected.
- 02
Invalid JSON tool arguments or human-input timeouts fail closed and deny the call.
- 03
In the current
0.1.xadapter series, rule evaluation runs throughacgs-lite'sToolCallGovernorpath. If your workflow requiresSignedReceipt,ExecutionGrant, or SQLiteEffectStorereservations, wire those contracts explicitly at the tool executor boundary.
Put one real workflow under your control.
Choose one tool. Define what it may do. Inspect what happens when a request crosses the boundary.