Code Examples6 Verified Scenarios

Real-World Enterprise Examples

Copy-pasteable, production-ready Python examples illustrating agent security boundaries, policy enforcement, approval tickets, and multi-framework integration.

1

Read-Only Research Assistant

RESOURCEweb_search
PERMISSIONweb:search
VERDICTALLOW
AUDITLogged to memory
scenario_research_assistant.py
from sictack import SecureAgent, Config, Policy, ToolCall

# 1. Define read-only policy
policy = Policy(
    name="research-assistant-policy",
    allowed_permissions=["web:search", "doc:read"],
    denied_permissions=["db:write", "network:exfiltrate"],
)

# 2. Initialize Agent
agent = SecureAgent(
    agent_id="researcher-01",
    permissions=["web:search", "doc:read"],
    config=Config(default_policy=policy),
)

# 3. Register safe simulated tool
def mock_search(query: str) -> str:
    return f"Synthesized research findings for: {query}"

agent.register_tool(name="web_search", handler=mock_search, permission="web:search")

# 4. Execute tool call
call = ToolCall(tool_name="web_search", arguments={"query": "quantum computing architectures"})
result = agent.execute(call)
print("Research Result:", result)
# -> Research Result: Synthesized research findings for: quantum computing architectures
2

Restricted File-Access Agent

RESOURCE/etc/hosts
PERMISSIONfile:write_system
VERDICTDENY
EXCEPTIONPermissionDeniedError
scenario_file_access.py
from sictack import SecureAgent, Config, Policy, ToolCall
from sictack.exceptions import PermissionDeniedError

# Policy only permits reading from public documentation directory
policy = Policy(
    name="file-access-policy",
    allowed_permissions=["file:read_public"],
    denied_permissions=["file:write_system"],
)

agent = SecureAgent(
    agent_id="file-agent-02",
    permissions=["file:read_public"],
    config=Config(default_policy=policy),
)

def safe_file_reader(path: str) -> str:
    # Simulated safe read
    return f"Content of {path}: [Dataset loaded]"

def system_file_writer(path: str, content: str) -> str:
    return "Written"

agent.register_tool("read_public_file", safe_file_reader, permission="file:read_public")
agent.register_tool("write_system_file", system_file_writer, permission="file:write_system")

# Permitted execution
allowed_call = ToolCall(tool_name="read_public_file", arguments={"path": "public_quarterly_report.pdf"})
print(agent.execute(allowed_call))
# -> Content of public_quarterly_report.pdf: [Dataset loaded]

# Blocked execution (Zero-trust denial)
try:
    blocked_call = ToolCall(tool_name="write_system_file", arguments={"path": "/etc/hosts", "content": "..."})
    agent.execute(blocked_call)
except PermissionDeniedError as e:
    print(f"Blocked by policy: {e}")
    # -> Blocked by policy: Tool write_system_file is denied by policy
3

Email Agent with Human Sign-Off

RESOURCEsend_external_email
PERMISSIONemail:send_external
INITIAL VERDICTREQUIRE_APPROVAL
TOKEN LIFECYCLESingle-use consumed
scenario_email_approval.py
from sictack import SecureAgent, Config, Policy, ToolCall
from sictack.exceptions import ApprovalRequiredError

policy = Policy(
    name="customer-outreach-policy",
    allowed_permissions=["email:draft"],
    require_approval_permissions=["email:send_external"],
)

agent = SecureAgent(
    agent_id="email-agent-03",
    permissions=["email:draft", "email:send_external"],
    config=Config(default_policy=policy),
)

def dispatch_email(recipient: str, subject: str, body: str) -> str:
    return f"Message delivered to {recipient}"

agent.register_tool("send_external_email", dispatch_email, permission="email:send_external")

outreach_call = ToolCall(
    tool_name="send_external_email",
    arguments={"recipient": "client@partner.com", "subject": "Contract Addendum", "body": "Please review."}
)

# Step 1: Execution automatically suspends for human review
try:
    agent.execute(outreach_call)
except ApprovalRequiredError as e:
    ticket_id = e.approval_id
    print(f"Suspended. Approval ID: {ticket_id}")

    # Step 2: Human operator inspects parameters and approves
    agent.approve(ticket_id)

    # Step 3: Resumed execution with single-use authorization token
    confirmation = agent.execute_with_approval(outreach_call, approval_id=ticket_id)
    print("Dispatch result:", confirmation)
    # -> Dispatch result: Message delivered to client@partner.com
4

LangChain Tool Protection

scenario_langchain.py
from sictack import SecureAgent, Config, Policy
from sictack.integrations.langchain import secure_langchain_tool

policy = Policy(
    name="langchain-guard-policy",
    allowed_permissions=["calc:add"],
    denied_permissions=["shell:exec"],
)
agent = SecureAgent(agent_id="langchain-math-bot", permissions=["calc:add"], config=Config(default_policy=policy))

def add_numbers(a: int, b: int) -> int:
    return a + b

# Wrapped as a LangChain Runnable tool with handle_tool_error=True
safe_math_tool = secure_langchain_tool(
    tool_or_func=add_numbers,
    agent=agent,
    permission="calc:add",
    handle_tool_error=True,
)

print(safe_math_tool.invoke({"a": 25, "b": 15}))
# -> 40
5

LangGraph Stateful Review Workflow

scenario_langgraph.py
from sictack import SecureAgent, Config, Policy
from sictack.integrations.langgraph import SecureGraphNode

policy = Policy(
    name="graph-triage-policy",
    allowed_permissions=["validate_ticket"],
    require_approval_permissions=["refund_customer"],
)
agent = SecureAgent(agent_id="support-graph-agent", permissions=["validate_ticket", "refund_customer"], config=Config(default_policy=policy))

def refund_node(state: dict) -> dict:
    return {"refunded": True, "amount": state["amount"]}

secure_refund = SecureGraphNode(
    name="refund_customer",
    func=refund_node,
    agent=agent,
    permission="refund_customer",
)

# In LangGraph workflows, calling the node returns a branched state dictionary
output = secure_refund({"ticket_id": "TCK-9912", "amount": 150.0})
print("Branch Status:", output["_sictack_status"])  # (also emits legacy '_intentlock_status')
# -> Branch Status: REQUIRE_APPROVAL
print("Pending Node:", output["_pending_node"])
# -> Pending Node: refund_customer
6

MCP JSON-RPC Server Gateway

scenario_mcp.py
from sictack import SecureAgent, Config, Policy
from sictack.integrations.mcp import MCPSecurityProxy

policy = Policy(
    name="mcp-gateway-policy",
    allowed_permissions=["query_cluster"],
    denied_permissions=["terminate_pod"],
)
agent = SecureAgent(agent_id="mcp-infra-agent", permissions=["query_cluster"], config=Config(default_policy=policy))

proxy = MCPSecurityProxy(agent=agent, agent_id="mcp-infra-agent")
proxy.register_mcp_tool("query_cluster", lambda region: f"Cluster {region}: Healthy", permission="query_cluster")
proxy.register_mcp_tool("terminate_pod", lambda pod_id: f"Terminated {pod_id}", permission="terminate_pod")

# Simulating incoming JSON-RPC tools/call request
rpc_payload = {
    "jsonrpc": "2.0",
    "id": "rpc-101",
    "method": "tools/call",
    "params": {"name": "query_cluster", "arguments": {"region": "us-east-1"}}
}
response = proxy.handle_jsonrpc(rpc_payload)
print(response["result"]["content"][0]["text"])
# -> Cluster us-east-1: Healthy