Prerequisites
- Python 3.10 or higher
- AgentGate server running (self-hosted or cloud)
- An API key (or run in development mode without one)
1. Installation
pip install agentgate-pdp
To run the AgentGate server locally:
git clone https://github.com/ElamOlame31/agentgate-public cd agentgate-public pip install -r requirements.txt python run.py
2. Register your agent
Registration declares the agent's identity, purpose, and authorized scope. AgentGate uses this declaration to verify every subsequent action. The declared_purpose string is embedded at registration and compared against every action via cosine similarity.
from agentgate import AgentGate
gate = AgentGate("http://localhost:8000", api_key="your-key")
# Register the agent with its declared scope
gate.register(
agent_id="report_bot_001",
name="ReportBot",
declared_purpose="Read and summarize quarterly business reports for the executive team",
authorized_resources=["/reports/*", "/documents/public/*"],
authorized_actions=["read", "search"],
delegation_depth=0, # 0 = not a sub-agent
processes_external_content=False,# True = enable prompt injection scanning
requires_human_approval=False, # True = always ESCALATE to human
)4. LangChain integration
AgentGateToolkit wraps your LangChain tools transparently. The agent framework sees normal LangChain tools — but every call is intercepted.
from integrations.langchain_agentgate import AgentGateToolkit
from langchain_core.tools import tool
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent
# Define your tools as normal
@tool
def read_document(path: str) -> str:
"""Read a document from the company file system."""
return open(path).read()
@tool
def list_documents(directory: str) -> str:
"""List all documents in a directory."""
import os
return str(os.listdir(directory))
# AgentGateToolkit registers the agent AND wraps tools in one call
toolkit = AgentGateToolkit(
agentgate_url="http://localhost:8000",
agent_id="langchain_report_bot",
name="LangChainReportBot",
declared_purpose="Read and summarize quarterly business reports for the executive team",
authorized_resources=["/documents/*"],
authorized_actions=["read", "search"],
api_key="your-key",
)
# wrap() returns drop-in replacements — every call goes through AgentGate
safe_tools = toolkit.wrap([read_document, list_documents])
llm = ChatAnthropic(model="claude-haiku-4-5-20251001", max_tokens=512)
agent = create_react_agent(llm, safe_tools)
# Run the agent — tool calls are intercepted transparently
result = agent.invoke({
"messages": [{"role": "user", "content": "Summarize Q3 and Q4 reports"}]
})5. AutoGen integration
# AutoGen integration — similar pattern
from integrations.autogen_agentgate import AgentGateToolkit as AutoGenToolkit
toolkit = AutoGenToolkit(
agentgate_url="http://localhost:8000",
agent_id="autogen_bot_001",
name="AutoGenResearchBot",
declared_purpose="Research and summarize public financial reports",
authorized_resources=["/public/*"],
authorized_actions=["read", "search"],
api_key="your-key",
)
# Wrap your AutoGen tools the same wayException reference
AgentGateDeniedRaised when decision is DENY (if raise_on_deny=True). Contains action, resource, explanation.
AgentGateEscalatedRaised when decision is ESCALATE (if raise_on_escalate=True).
AgentGateNotRegisteredRaised if .authorize() is called before .register().
AgentGatePendingRaised when decision is PENDING and auto_resolve_pending=False.
AgentGateUnavailableRaised if the AgentGate server is unreachable.
Full documentation, changelog, and source code on GitHub.
ElamOlame31/agentgate-public