Agent Guardrails Wrapper

    1

    The reasoning layer proposes; the wrapper disposes. Mechanical floors for agents that can spend money.

    $29

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Agent Guardrails Wrapper

    Example session with this skill installed

    Audit my agent's order execution tool and design a mechanical wrapper that enforces a 2% daily loss cap and a kill switch.

    • Read your context and instructions
    • Compiled the agent guardrails wrapper

    I have audited the execute_order tool in src/trading/executor.py. The current implementation relies on a system prompt to stay within risk limits, which is a significant side-channel vulnerability.

    Agent Guardrail Architecture

    The following implementation moves the risk logic out of the model's reasoning loop and into a deterministic wrapper.

    
    # src/safety/wrapper.py
    import time
    from typing import Dict, Any
    
    class ExecutionWrapper:
        def __init__(self, daily_loss_limit: float, kill_switch_path: str):
            self.daily_loss_limit = daily_loss_limit
            self.kill_switch_path = kill_switch_path
            self.start_equity = self._get_fresh_equity()
    
        def _get_fresh_equity(self) -> float:
            # Implementation of "Fresh-read precondition"
            pass
    
        def check_gate(self, request_size: float) -> bool:
            # Check 1: Kill Switch (Mechanical)
            if self._is_kill_switch_engaged():
                return False, "REJECTED: Kill switch active"
            
            # Check 2: Loss Floor (Deterministic)
            current_equity = self._get_fresh_equity()
            if (self.start_equity - current_equity) > self.daily_loss_limit:
                return False, "REJECTED: Daily loss cap hit"
                
            return True, "ALLOWED"
    
        def _is_kill_switch_engaged(self) -> bool:
            with open(self.kill_switch_path, 'r') as f:
                return f.read().strip() == "STOP"
    
    # The reasoning layer proposes; the wrapper disposes
    def guarded_execute(agent_request: Dict[str, Any]):
        wrapper = ExecutionWrapper(daily_loss_limit=2000.0, kill_switch_path="/var/run/agent.stop")
        is_allowed, reason = wrapper.check_gate(agent_request['size'])
        
        if is_allowed:
            return raw_execute_order(agent_request)
        else:
            return {"status": "error", "message": reason}
    

    Next steps

    1. Move the raw_execute_order function to a private module so the agent cannot call it directly via tool-use.
    2. Initialize the ExecutionWrapper with a fresh-read from your broker API on every request to prevent state decay.
    3. Set up a cron-based watchdog to check the /var/run/agent.stop file if the heartbeats in your journal cease.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    If your agent can spend money, place trades, deploy code, or take irreversible actions, politeness is not a gate. This skill defines guarded-by-construction: exactly one mechanical entry point for consequential actions; refusal lists enumerated in code (price bands, loss-streak caps, equity floors, kill switch, mandate state) with fail-closed behavior on missing state; formula-computed limits the model cannot influence; open positions inheriting the same wrapper; and the standing rule that verification decays with the code — any change to the guarded path voids the audit. Runtime resilience covers supervisor restarts, heartbeat-based DOWN detection, an external backstop outside the failure domain with honestly stated blind intervals, and journaled boots. Includes the Goodhart pressure discipline: when the goal is unreachable through disciplined play, reframe the objective — because a far-out goal pressures the agent toward forcing the exact actions its edge depends on refusing. What's inside: SKILL.md (the architecture law), reference/audit-checklist.md (static audit from live code, dynamic fire-the-gates tests, red-flag list), examples/worked-example.md (a static audit excerpt that finds an unguarded side path).

    Architecture requires a separate failure domain for backstops. Audit reports are only valid for the specific code version analyzed.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 5 days ago

    Permissions

    Read Files
    Terminal / Shell
    Listed5 days ago

    What's inside

    Frequently Asked Questions

    Unlike system prompts that models can bypass via jailbreaking, this skill implements a deterministic code layer. It ensures that if a model proposes an action violating your hard rules (like a loss cap), the execution is physically blocked by the wrapper before it hits the API or environment.

    This skill is framework-agnostic and works with any autonomous system built in Python or TypeScript, including LangChain, AutoGPT, and CrewAI. It focuses on the interface between the agent's reasoning and your execution tools, making it compatible with any LLM backend.

    You will receive the architectural blueprints, the deterministic refusal logic templates, and the watchdog monitoring scripts. It also includes an audit checklist to help you identify and close 'side channels' where an agent might bypass your safety checks.

    The watchdog is a self-healing monitor that tracks the agent's 'heartbeat.' If the agent stalls, loops, or crashes, the watchdog detects the failure and performs a clean-state relaunch to ensure the system remains operational without manual intervention.

    No, this skill provides the code architecture and logic for the wrapper, but you are responsible for the hosting environment. The safety guarantees depend on your execution environment respecting the hard floors and kill switches defined in the wrapper code.

    New in Security