### Set up virtual environment and install dependencies Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/contrib/agentcore-samples/attenu-guard/README.md Creates a virtual environment with uv, activates it, and installs the development requirements. Use this before running the offline example. ```bash uv venv source .venv/bin/activate # Windows: .venv\Scripts\activate uv pip install -r requirements-dev.txt ``` -------------------------------- ### Setup: Install dependencies and copy environment file Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/contrib/adk-samples/attenu-guard/README.md Run `uv sync` to install dependencies. Copy `.env.example` to `.env` only for a live run; the default run requires no API key or cloud project. ```bash uv sync cp .env.example .env # only needed for a live run ``` -------------------------------- ### Clone and run the poisoned summarizer example Source: https://github.com/attenu-io/attenu-guard/blob/main/README.md Clone the repository and run the example without installation; the examples bootstrap the src/ path themselves. ```bash git clone https://github.com/attenu-io/attenu-guard && cd attenu-guard ``` ```bash python3 examples/poisoned_summarizer.py ``` -------------------------------- ### Install and run live_smoke.py over HTTP Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/a2a/README.md Installs the HTTP server dependencies and runs the live smoke test with RUN_LIVE=1. Starts a Starlette A2A server and posts JSON-RPC over HTTP. ```bash pip install "a2a-sdk[http-server]" uvicorn RUN_LIVE=1 python examples/integrations/a2a/live_smoke.py ``` -------------------------------- ### Install and run demo.py Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/a2a/README.md Installs the required packages and runs the in-process demo. Requires a2a-sdk>=1.1 and attenu-guard. ```bash pip install "a2a-sdk>=1.1" attenu-guard python examples/integrations/a2a/demo.py ``` -------------------------------- ### Setup and run LangGraph continuity script Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/runs/audit-continuity-2026-09-04.md Creates a Python 3.12 virtual environment, installs attenu-guard with crypto extras and pinned versions of LangChain, LangGraph, and Deep Agents, then runs the continuity script. ```bash python3.12 -m venv v-langgraph && v-langgraph/bin/pip install 'attenu-guard[crypto]' \ langchain==1.3.17 langchain-core==1.6.0 langgraph==1.2.11 deepagents==0.7.6 v-*/bin/python docs/runs/scripts/langgraph_continuity.py ``` -------------------------------- ### Install and run the Haystack integration demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/haystack/README.md Install the package with the Haystack extra, then run the offline demo (no API key required) and the integration tests. ```bash pip install 'attenu-guard[haystack]' python examples/integrations/haystack/demo.py # offline, no API key pytest tests/integrations/test_haystack.py ``` -------------------------------- ### Install and run Langflow with Attenu Guard component Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/langflow/README.md Install attenu-guard, create the custom component directory, copy the component file, and run Langflow with LANGFLOW_COMPONENTS_PATH set to the custom_components directory. ```bash pip install attenu-guard mkdir -p custom_components/attenu && touch custom_components/attenu/__init__.py cp examples/integrations/langflow/attenu_guard_component.py custom_components/attenu/ LANGFLOW_COMPONENTS_PATH=$(pwd)/custom_components langflow run ``` -------------------------------- ### Setup and run CrewAI continuity script Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/runs/audit-continuity-2026-09-04.md Creates a Python 3.12 virtual environment, installs attenu-guard with crypto extras and CrewAI 1.15.18, then runs the continuity script. ```bash python3.12 -m venv v-crewai && v-crewai/bin/pip install 'attenu-guard[crypto]' crewai==1.15.18 v-*/bin/python docs/runs/scripts/crewai_continuity.py ``` -------------------------------- ### Install and run the integration demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/smolagents/README.md Install the required packages and run the offline demo or the test suite. The demo requires no API key and the tests run offline. ```bash pip install "smolagents==1.26.0" attenu-guard python examples/integrations/smolagents/demo.py # offline, no API key pytest -q tests/integrations/test_smolagents.py # 17 tests, offline ``` -------------------------------- ### Install dependencies for OpenAI Agents integration Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/openai_agents/README.md Install attenu-guard with crypto extra and openai-agents 0.22.0 from a repository checkout. ```bash pip install -e '.[crypto]' pip install openai-agents==0.22.0 ``` -------------------------------- ### Install attenu-guard with Haystack extras Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/haystack/deepset-catalog-entry.md Install the package with the Haystack integration extras using pip. ```bash pip install 'attenu-guard[haystack]' ``` -------------------------------- ### Install and run openai-agents integration Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/INTEGRATIONS.md Install the package with the openai-agents extra, run the demo script, and execute the integration tests. The extras list includes langchain, deepagents, openai-agents, google-adk, pydantic-ai, crewai, autogen, claude-agent-sdk, smolagents, strands, llama-index, semantic-kernel, agno, haystack, camel, a2a, and openhands. ```bash pip install -e '.[openai-agents]' # extras: langchain, deepagents, openai-agents, google-adk, # pydantic-ai, crewai, autogen, claude-agent-sdk, smolagents, # strands, llama-index, semantic-kernel, agno, # haystack, camel, a2a, openhands python examples/integrations/openai_agents/demo.py python -m pytest -q tests/integrations/test_openai_agents.py ``` -------------------------------- ### Install and run Google ADK integration demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/google_adk/README.md Install the required packages and run the demo script and tests. The demo requires no API key. ```bash pip install "google-adk==2.7.1" attenu-guard python examples/integrations/google_adk/demo.py # no API key needed pytest tests/integrations/test_google_adk.py ``` -------------------------------- ### Install and run CAMEL integration demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/camel/README.md Install required packages and run the demo and tests. Note that camel-ai 0.2.90 requires mcp<2; with mcp 2.x, camel.toolkits fails to import. ```bash pip install "camel-ai==0.2.90" "mcp<2" attenu-guard python examples/integrations/camel/demo.py # offline, no API key pytest -q tests/integrations/test_camel.py # 25 tests, offline ``` -------------------------------- ### Set up venv and run Google ADK continuity script Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/runs/audit-continuity-2026-09-04.md Creates a Python 3.12 virtual environment, installs attenu-guard with crypto extras and google-adk 2.7.1, then runs the continuity script. The wildcard v-*/bin/python matches the created venv. ```bash python3.12 -m venv v-adk && v-adk/bin/pip install 'attenu-guard[crypto]' google-adk==2.7.1 v-*/bin/python docs/runs/scripts/google_adk_continuity.py ``` -------------------------------- ### Install and run demo Source: https://github.com/attenu-io/attenu-guard/blob/main/README.md Install the package and run the built-in demo that shows one delegation, one poisoned instruction, the export refused, and the chain verified. ```bash pip install attenu-guard attenu-guard demo # one delegation, one poisoned instruction, the export refused, the chain verified ``` -------------------------------- ### Install attenu-guard with framework extra Source: https://github.com/attenu-io/attenu-guard/blob/main/AGENTS.md Install the library with the adapter for a specific agent framework. The framework name is a placeholder for the actual framework (e.g., langgraph, crewai). ```bash pip install 'attenu-guard[]' ``` -------------------------------- ### Install dependencies for LangGraph integration Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/langgraph/README.md Install the package with crypto extra and pin langgraph to version 1.2.11. ```bash pip install -e '.[crypto]' pip install langgraph==1.2.11 ``` -------------------------------- ### Clone and run verification commands Source: https://github.com/attenu-io/attenu-guard/blob/main/README.md Commands to clone the repository and run the property suite, red-team harness, poisoned summarizer example, and demo. Requires pip install attenu-guard for the demo command. ```bash git clone https://github.com/attenu-io/attenu-guard && cd attenu-guard python3 tests/run_properties.py # 4,000 random delegation trees per invariant, zero deps python3 tests/red_team.py # 17 adversarial attacks, black- & white-box; 0 must break python3 examples/poisoned_summarizer.py attenu-guard demo # needs pip install attenu-guard ``` -------------------------------- ### Set up venv and run OpenAI Agents continuity script Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/runs/audit-continuity-2026-09-04.md Creates a Python 3.12 virtual environment, installs attenu-guard with crypto extras and openai-agents 0.22.0, then runs the continuity script. The script output is shown in the following text block. ```bash python3.12 -m venv v-openai && v-openai/bin/pip install 'attenu-guard[crypto]' openai-agents==0.22.0 v-*/bin/python docs/runs/scripts/openai_agents_continuity.py ``` -------------------------------- ### Run bounded_by_parent.py with demo.py Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/baselines/langgraph/output-2026-09-28.txt Command to run the baseline example from the repo root in a fresh Python 3.12 venv with the listed packages installed. No network or API key is needed; the model is scripted. ```bash PYTHONPATH=src python examples/baselines/langgraph/bounded_by_parent.py examples/integrations/langgraph/subagent_middleware/demo.py ``` -------------------------------- ### Run the dev loop commands Source: https://github.com/attenu-io/attenu-guard/blob/main/CONTRIBUTING.md Run the zero-dependency invariant check, the full hypothesis suite, and the poisoned summarizer example. Requires installing the test extras with `pip install -e '.[test]'` for pytest. ```bash python tests/run_properties.py # zero-dep invariant check ``` ```bash pytest # full hypothesis suite (pip install -e '.[test]') ``` ```bash python examples/poisoned_summarizer.py ``` -------------------------------- ### Install and run Langflow integration tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/langflow/README.md Install the package and run the offline test suite. The suite contains 25 tests and does not require network access. ```bash pip install attenu-guard lfx # or the full langflow pytest -q tests/integrations/test_langflow.py # 25 tests, offline ``` -------------------------------- ### Set up virtual environment and run Claude Code continuity script Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/runs/audit-continuity-2026-09-04.md Creates a Python 3.12 virtual environment, installs the attenu-guard package with crypto extras, and runs the continuity script with the source directory on PYTHONPATH. ```bash python3.12 -m venv v-cc && v-cc/bin/pip install 'attenu-guard[crypto]' PYTHONPATH=src v-*/bin/python docs/runs/scripts/claude_code_continuity.py ``` -------------------------------- ### Run the one-policy integration demo and tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/openai_agents/one_policy/README.md Install the openai-agents extra, run the demo, and run the 19 tests. The commented live smoke test requires RUN_LIVE=1 and an OPENAI_API_KEY. Exit codes: 0 all expectations held, 1 an expectation failed, 3 the premise of step 1 changed. ```bash pip install 'attenu-guard[openai-agents]' python examples/integrations/openai_agents/one_policy/demo.py python -m pytest -q tests/integrations/test_openai_agents_one_policy.py # 19 tests # RUN_LIVE=1 OPENAI_API_KEY=... python examples/integrations/openai_agents/one_policy/live_smoke.py ``` -------------------------------- ### Install dependencies for CrewAI integration Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/crewai/README.md Install the package from the repository checkout and pin CrewAI to version 1.15.16. ```bash pip install -e . pip install crewai==1.15.16 ``` -------------------------------- ### Example per-entry line for a witness-signed containment failure Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/verify/README.md Shown output for a bundle where the process appended an allow outside its node's authority, in chain order, and the witness signed it. Each line is `key=value` tokens split by single spaces; the key is the text before the first `=`, so `scope=failed=containment` is the scope "failed=containment". A value never contains a space; a value starting with `"` is a JSON string, and an entry without a seq prints `seq=null`. ```text seq=4 event=allow node=witness-custody-run:n1 scope=web.search state=witness-signed observed=indeterminate witness= failed=containment ``` -------------------------------- ### Install Pillow and run render_demo_gif.py Source: https://github.com/attenu-io/attenu-guard/blob/main/tools/README.md Regenerates docs/assets/demo.gif from the real `attenu-guard demo` output. Requires Pillow; ffmpeg is optional and only used as an alternate encoder if the GIF exceeds the size budget. ```bash pip install pillow # required python tools/render_demo_gif.py # writes docs/assets/demo.gif ``` -------------------------------- ### scenarios.py JSON schema example Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/V0.2-SPEC.md Declarative runner accepts JSON natively and YAML if importable. The schema mirrors the DEVX-REVIEW YAML. The example shows root authority, delegations, and assertions with expected allow/deny outcomes and reason codes. ```json { "root": {"agent":"planner","authority":{"scopes":["crm.read","crm.write"], "ceilings":[{"key":"max_rows","max":1000}],"ttl":3600}}, "delegations": [ {"as":"summarizer","attenuate":{"scopes":["crm.read"], "ceilings":[{"key":"max_rows","max":100}]}} ], "assertions": [ {"node":"summarizer","check":{"scope":"crm.read","context":{"rows":50}},"expect":"allow"}, {"node":"summarizer","check":{"scope":"crm.write"},"expect":"deny","because":"scope_not_granted"}, {"node":"summarizer","check":{"scope":"crm.read","context":{"rows":5000}},"expect":"deny","because":"ceiling_exceeded"} ] } ``` -------------------------------- ### Install attenu-guard with AG2 extra Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/ag2/README.md Install the package with the AG2 extra. Tested against ag2 1.0.2 on Python 3.12. ```bash pip install 'attenu-guard[ag2]' ``` -------------------------------- ### Install and run the ADK peer transfer demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/google_adk/peer_transfer/README.md Install the package with the google-adk extra and run the demo script. The commented line shows how to run the live smoke test with an API key. Expected output includes transfer success, authority_denied export, and verification results; exit code 3 indicates the premise of step 1 changed. ```bash pip install 'attenu-guard[google-adk]' python examples/integrations/google_adk/peer_transfer/demo.py # RUN_LIVE=1 GOOGLE_API_KEY=... python examples/integrations/google_adk/peer_transfer/live_smoke.py ``` -------------------------------- ### Install and run the MCP server verifier demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/mcp/server_verifier/README.md Install the attenu-guard MCP extra and run the demo. The demo verifies a delegation chain offline and prints expected results. Use RUN_LIVE=1 to run the same server over stdio. Exit code 3 indicates the SDK now carries an authority field. ```bash pip install 'attenu-guard[mcp]' # mcp>=1.28; verified on 1.28.1 and 2.3.0 python examples/integrations/mcp/server_verifier/demo.py # RUN_LIVE=1 python examples/integrations/mcp/server_verifier/live_smoke.py # the same server over stdio ``` -------------------------------- ### Demo output: delegate with nothing installed Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/commerce-agents/README.md Output from Act 3 of the demo showing a delegate with no tools installed. The 'side effects' line is the oracle, read from store-side and body-side state, not from tool results. ```text -- nothing installed -- read get_pending_changes -> ran [{"change_id": "chg-0001", "kind": "listing_update", "status": "staged", "summary": "R write stage_price_update -> ran (fenced payload) present present_change_preview -> ran Displayed to the operator. nested note_finding -> ran (fenced payload) side effects: staged=['chg-0002'] presented=['chg-0001'] peer_delegate_ran=True ``` -------------------------------- ### Run the hooks receipt demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/claude_code/hooks_receipt/README.md Install attenu-guard and run the demo, hook derivation, and optional live smoke test. The demo feeds the hook the exact PreToolUse JSON Claude Code sends, one subprocess per call, and runs a tool body only when the hook did not deny it. Exit codes: 0 all expectations held, 1 an expectation failed, 3 the pinned hook contract changed. ```bash pip install attenu-guard python examples/integrations/claude_code/hooks_receipt/demo.py python examples/integrations/claude_code/hooks_receipt/hook.py --derive . # print the derivation # RUN_LIVE=1 python examples/integrations/claude_code/hooks_receipt/live_smoke.py ``` -------------------------------- ### Clone repos and install dependencies Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/commerce-agents/README.md commerce-agents is not on any package index, so it installs from a clone. Requires Python 3 and pip. ```bash git clone --depth 1 https://github.com/anthropics/commerce-agents.git git clone --depth 1 https://github.com/attenu-io/attenu-guard.git python3 -m venv .venv && . .venv/bin/activate pip install -q -e ./commerce-agents/commerce-common \ -e ./commerce-agents/merchant-agent/core \ -e ./commerce-agents/merchant-agent/runtime-messages-api \ -e ./attenu-guard python attenu-guard/examples/integrations/commerce-agents/demo.py attenu-guard verify ./attenu-commerce-bundle.json --hs256-key 64656d6f2d6b6579 ``` -------------------------------- ### Install and run the Strands integration demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/strands/README.md Install the required packages and run the demo script. Requires Python >= 3.10 and strands-agents 1.52.0 or later. No AWS credentials or API key are needed because ScriptedModel emits Bedrock-shaped StreamEvent dicts. ```bash pip install "strands-agents>=1.52" attenu-guard python examples/integrations/strands/demo.py ``` -------------------------------- ### Run the offline example Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/contrib/agentcore-samples/attenu-guard/README.md Executes the offline run using local_run.py. The ScriptedModel substitutes the real model, making the run deterministic, free, and safe for CI. ```bash python local_run.py ``` -------------------------------- ### Act 3 output: held calls with install() active Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/commerce-agents/README.md Output from the same delegate with install() active. Shows a read that ran and three held calls (write, present, nested) with reason scope_not_granted, plus side effects showing none occurred. ```text -- attenu-guard installed -- read get_pending_changes -> ran [{"change_id": "chg-0001", "kind": "listing_update", "status": "staged", "summary": "R write stage_price_update -> HELD[authority] That call is outside this agent's authority: denied: scope_not_granted requested=prici present present_change_preview -> HELD[authority] That call is outside this agent's authority: denied: scope_not_granted requested=prese nested note_finding -> HELD[authority] That call is outside this agent's authority: denied: scope_not_granted requested=deleg side effects: staged=none presented=none peer_delegate_ran=False ``` -------------------------------- ### Install attenu-guard with agent-framework extra Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/agent_framework/README.md Install the package with the agent-framework extra to enable integration with Microsoft Agent Framework. Tested against agent-framework 1.15.0 on Python 3.12. ```bash pip install 'attenu-guard[agent-framework]' ``` -------------------------------- ### Install and run the Omnigent policy handler demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/omnigent/policy_handler/README.md Install attenu-guard with the omnigent extra and run the demo script. The commented line shows how to run the live smoke test with RUN_LIVE=1 and an Omnigent agent YAML path. ```bash pip install 'attenu-guard[omnigent]' # omnigent 0.11.0 at the time of writing python examples/integrations/omnigent/policy_handler/demo.py # RUN_LIVE=1 OMNIGENT_AGENT=path/to/agent.yaml python examples/integrations/omnigent/policy_handler/live_smoke.py ``` -------------------------------- ### Install and run the subagent middleware demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/langgraph/subagent_middleware/README.md Install the package with the deepagents extra and run the demo script. Optionally run the live smoke test with an Anthropic API key. Expected output includes GRANTED/DENY log lines and RESULT: OK. Exit codes: 0 for success, 1 for failed expectation, 3 for upstream premise change. ```bash pip install 'attenu-guard[deepagents]' python examples/integrations/langgraph/subagent_middleware/demo.py # RUN_LIVE=1 ANTHROPIC_API_KEY=... python examples/integrations/langgraph/subagent_middleware/live_smoke.py ``` -------------------------------- ### Install dependencies for Attenu Guard with CAMEL Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/camel/cookbook.mdx Install camel-ai 0.2.90, mcp<2, and attenu-guard>=0.10,<0.11. Requires mcp<2 because camel-ai 0.2.90 fails to import camel.toolkits with mcp 2.x. ```python %pip install "camel-ai==0.2.90" "mcp<2" "attenu-guard>=0.10,<0.11" ``` -------------------------------- ### Run integration tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/commerce-agents/README.md Tests need pytest and the same three editable installs. They skip, rather than fail, where commerce-agents is not importable. ```bash python -m pytest -q attenu-guard/tests/integrations/test_commerce_agents.py ``` -------------------------------- ### Example subagent frontmatter in sample_project/.claude/agents/ Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/claude_code/hooks_receipt/README.md A subagent definition with frontmatter specifying name, description, tools, and model. This is used by the recipe to derive permissions; the subagent's authority is meet(session, derived) so it cannot exceed the session's. ```markdown --- name: reviewer description: Reviews code already in the repository. Reads and searches only; never edits, never runs commands, never reaches the network. tools: Read, Grep, Glob model: sonnet --- You are a code reviewer. Read the files under review, search for related call sites, and report what you find. You do not change files and you do not run commands. ``` -------------------------------- ### Run integration demo, tests, and live smoke Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/claude_sdk/README.md Commands to run the offline demo, the offline test suite, and the live smoke test that spends tokens. The live smoke requires Claude Code CLI installed and logged in, using its session instead of an API key. ```bash python examples/integrations/claude_sdk/demo.py # offline, no key ``` ```bash pytest -q tests/integrations/test_claude_sdk.py # 29 tests, offline ``` ```bash RUN_LIVE=1 python examples/integrations/claude_sdk/live_smoke.py # spends tokens ``` -------------------------------- ### Three-minute repro: clone, install, run demo, verify bundle Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/omnigent/policy_handler/README.md Runs the ten-step dispatch script twice (no policy vs. Omnigent FunctionPolicy with this handler) and verifies the signed bundle from the file alone. No API key or harness needed; measured at 20 s from a fresh clone with a warm pip cache. ```bash git clone --depth 1 https://github.com/attenu-io/attenu-guard && cd attenu-guard python3 -m venv .venv && . .venv/bin/activate && pip install -q 'attenu-guard[omnigent]' python examples/integrations/omnigent/policy_handler/demo.py attenu-guard verify attenu-omnigent-bundle.json --hs256-key 64656d6f2d6b6579 # step 4 again, Omnigent absent ``` -------------------------------- ### Run live demo and CLI/web app Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/contrib/adk-samples/attenu-guard/README.md Run the demo live against a real model after setting `MODEL_NAME` and credentials in `.env`. The `adk run` and `adk web` commands load the module-level `app` object, which is the `App` with the plugin attached, so CLI-driven runs are guarded. That object is built once at import, so all sessions share one root permission set and one ledger; call `build_app()` per run for isolated decisions. ```bash uv run python demo.py --live uv run adk run app # or: uv run adk web ``` -------------------------------- ### Wire GuardedAgentToolkit into a Camel ChatAgent Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/camel/README.md Shows how to integrate attenu-guard with a Camel ChatAgent. The root Guard is issued for the orchestrator, and a GuardedAgentToolkit wraps a child authority. The parent agent gets both the root toolkit and the child toolkit's tools. Note that guard_toolkit refuses unpriced tools unless on_unmapped="allow" is passed, and the sub-agent is not given the delegation toolkit. ```python from attenu_guard import Authority, EgressRank, Guard, RowLimit from attenu_guard.adapters.camel import GuardedAgentToolkit, GuardRef, guard_toolkit CRM_SCOPES = {"crm_query": "crm.read", "crm_export": "crm.export"} CONTEXT_FNS = {"crm_query": lambda rows: {"rows": rows}, "crm_export": lambda destination: {"egress": "any"}} def child_tools(ref): # built fresh per delegation return guard_toolkit(ref, CrmToolkit(), CRM_SCOPES, context_fns=CONTEXT_FNS) root = Guard.issue("orchestrator", Authority(scopes={"crm.*", "mail.send"}, ceilings=[RowLimit(100_000), EgressRank("any")], ttl=3600), task="Q3 board report") toolkit = GuardedAgentToolkit( parent_guard=root, authority=Authority(scopes={"crm.read"}, ceilings=[RowLimit(5_000), EgressRank("none")], ttl=900), child_tools=child_tools) parent = ChatAgent( system_message="You orchestrate the Q3 board report.", model=model, tools=[*guard_toolkit(GuardRef(root), CrmToolkit(), CRM_SCOPES, context_fns=CONTEXT_FNS), *toolkit.get_tools()], toolkits_to_register_agent=[toolkit]) ``` -------------------------------- ### Delegate with meet semantics and enforce checks Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/SUB-AGENT-PERMISSIONS.md Shows how attenu-guard computes a child's authority as the meet of the parent's and the request's, then enforces it. The orchestrator holds broad authority; the child gets narrowed scopes, tighter ceilings, and a shorter TTL. `check()` returns a Decision, while `enforce()` raises AuthorityDenied for disallowed actions. ```python from attenu_guard import Authority, Guard, RowLimit, EgressRank # The orchestrator holds broad authority. orchestrator = Guard.issue("orchestrator", Authority( scopes={"crm.*", "mail.send"}, ceilings=[RowLimit(100_000), EgressRank("any")], ttl=3600)) # It delegates a narrow task. The child gets the *meet* of what the parent # held and what the task needs — computed and enforced, not suggested. summarizer = orchestrator.delegate("summarizer", Authority( scopes={"crm.read"}, ceilings=[RowLimit(5_000), EgressRank("none")], ttl=900), task="summarize Q3 pipeline") decision = summarizer.check("crm.read", context={"rows": 4_200}) # Decision(allowed=True) summarizer.enforce("crm.export", context={"egress": "any"}) # raises AuthorityDenied ``` -------------------------------- ### Deploy and invoke with AgentCore CLI Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/contrib/agentcore-samples/attenu-guard/README.md Standard Runtime flow: configure with the entrypoint file, launch, then invoke with a JSON payload. `input.json` holds the same payload if you prefer to pass a file. These commands have not been executed for this sample; expect to adjust the IAM role and region for your own account. ```bash agentcore configure -e strands_attenu_guard.py agentcore launch agentcore invoke '{"prompt": "Investigate the 5xx spike overnight."}' ``` -------------------------------- ### Python entrypoint for AgentCore Runtime (strands_attenu_guard.py) Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/contrib/agentcore-samples/attenu-guard/README.md Hand this file to `agentcore configure`. It builds a session per invocation and returns the answer with the decisions from that run, so a caller sees what was refused without reading container logs. Uses `build_session(...)` with no models, leaving Strands on its Bedrock default. `ATTENU_GUARD_LEDGER` sets where the ledger is written inside the container; it defaults to a path under `/tmp`. ```python from bedrock_agentcore.runtime import BedrockAgentCoreApp from agents import build_session, denials, reset app = BedrockAgentCoreApp() @app.entrypoint def agent_invocation(payload, context): prompt = payload.get("prompt", DEFAULT_PROMPT) reset() orchestrator, _analyst, guard = build_session( task=prompt, audit_path=LEDGER_PATH, audit_overwrite=True ) result = orchestrator(prompt) return { "result": str(result.message), "denials": denials(guard), "ledger_events": len(guard.root_guard.audit_log().entries), } if __name__ == "__main__": app.run() ``` -------------------------------- ### Import openai-agents adapter symbols Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/INTEGRATIONS.md Import the GuardRegistry, DelegationGuardHooks, and guarded_tool from the openai-agents adapter. Each integration directory's README lists the exact hooks, the tested version, and an env-gated live_smoke.py (RUN_LIVE=1 plus your provider key) that replays the same story against a real model. ```python from attenu_guard.adapters.openai_agents import GuardRegistry, DelegationGuardHooks, guarded_tool ``` -------------------------------- ### Verify bundle without the key (pipx run attenu-guard verify) Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/verify/README.md Runs verification without the signing key. Chain, subset, and containment are still checked; the anchor is not, so "OK" means consistent but cannot exclude a full rewrite by a key holder. Ask the operator for the public half (`.attenu/product.json` → `anchor_pub`, `--pubkey ` for Ed25519, or the KMS public key for ES256). ```bash pipx run attenu-guard verify clean.bundle.json # integrity=True monotonicity=True containment=True anchor=not checked ``` -------------------------------- ### Run the Pydantic AI integration demo and tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/pydantic_ai/README.md Commands to run the offline demo (no API key required) and the integration tests. The demo uses `GuardedToolsetCapability`; to use the hook layer, pass `DelegationGuard` from `attenu_guard.adapters.pydantic_ai` as `build_scenario(..., guard=DelegationGuard)`. ```bash python examples/integrations/pydantic_ai/demo.py # offline, no API key pytest tests/integrations/test_pydantic_ai.py ``` -------------------------------- ### Run OpenAI Agents integration demo and tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/openai_agents/README.md Run the offline demo, the test suite (46 tests), and the live smoke test with an API key. The live smoke test is env-gated and never runs in CI. ```bash python examples/integrations/openai_agents/demo.py # offline, no API key python -m pytest -q tests/integrations/test_openai_agents.py \ tests/integrations/test_openai_agents_one_policy.py \ tests/integrations/test_openai_agents_recipe_demo.py # 46 tests, offline RUN_LIVE=1 OPENAI_API_KEY=... python examples/integrations/openai_agents/live_smoke.py ``` -------------------------------- ### Regenerate test vectors with generate.py Source: https://github.com/attenu-io/attenu-guard/blob/main/tests/vectors/README.md Run this command to regenerate the test vector files in both the tests/vectors directory and the installed package. It is stdlib-only, requires no network or installs, and is deterministic. Never hand-edit the generated files. ```bash python3 tests/vectors/generate.py ``` -------------------------------- ### Expected output of demo and verify Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/commerce-agents/README.md The demo writes the bundle to the working directory, so run the last line from the same place (or give it the path it printed). Output shows integrity, monotonicity, containment, anchor, nodes, and actions_checked. ```text integrity=True monotonicity=True containment=True anchor=verified nodes=4 actions_checked=8 OK ``` -------------------------------- ### load(tokens, root_pubkeys, signer) Source: https://github.com/attenu-io/attenu-guard/blob/main/docs/V0.2-SPEC.md Loads and verifies a list of Delegation Tokens against root public keys. Runs the offline verification algorithm, checking signatures, parent hash commitments, depth, subsumption, and expiration. ```APIDOC ## load(tokens, root_pubkeys, signer) ### Description Loads and verifies a list of Delegation Tokens against root public keys. Runs the offline verification algorithm, checking signatures, parent hash commitments, depth, subsumption, and expiration. ### Method load ### Parameters - **tokens** (list[str]) - The list of Delegation Tokens to verify. - **root_pubkeys** - The root public keys used for verification. - **signer** (Signer) - The signer to use for verification. ### Returns - **VerifiedChain** - The verified chain exposing the leaf Authority. ### Errors - **WireError** - Raised on any verification failure. ``` -------------------------------- ### Run offline demo and tests for LangGraph integration Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/langgraph/README.md Run the offline demo and the test suite. The demo requires no API key. The tests cover the integration and related middleware. ```bash python examples/integrations/langgraph/demo.py # offline, no API key python -m pytest -q tests/integrations/test_langgraph.py \ tests/integrations/test_deepagents.py \ tests/integrations/test_langgraph_subagent_middleware.py \ tests/integrations/test_langgraph_recipe_demo.py # offline ``` -------------------------------- ### Run Semantic Kernel demo and tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/semantic_kernel/README.md Commands to run the demo script (no API key needed) and the integration tests. ```bash python examples/integrations/semantic_kernel/demo.py # no API key needed python -m pytest tests/integrations/test_semantic_kernel.py ``` -------------------------------- ### Verify a bundle with attenu-guard verify Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/verify/README.md Run the verifier on a clean bundle using an HS256 key. Output shows integrity, monotonicity, containment, anchor, nodes, and actions_checked all passing. ```bash pipx run attenu-guard verify clean.bundle.json --hs256-key 73616d706c652d6b6579 ``` ```text integrity=True monotonicity=True containment=True anchor=verified nodes=3 actions_checked=2 OK ``` -------------------------------- ### Run baseline.py Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/baselines/openai_agents/output-2026-09-28.txt Command to execute the baseline script from the repository root in a fresh Python 3.12 virtual environment with the specified packages installed. ```bash python examples/baselines/openai_agents/baseline.py ``` -------------------------------- ### Run Agent Framework demo and tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/agent_framework/README.md Commands to run the demo script and integration tests. The demo requires no API key. ```bash python examples/integrations/agent_framework/demo.py # no API key needed pytest tests/integrations/test_agent_framework.py ``` -------------------------------- ### Run the AutoGen integration demo and tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/autogen/README.md Run the demo script (no API key needed) and the integration tests. The demo executes a poisoned-summarizer script twice to show the guard's effect. ```bash python examples/integrations/autogen/demo.py # no API key needed pytest tests/integrations/test_autogen.py ``` -------------------------------- ### Run the Agno integration demo and tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/agno/README.md Commands to run the offline demo and the 23 offline tests for the Agno integration. The demo requires no API key. ```bash python examples/integrations/agno/demo.py # offline, no API key ``` ```bash python -m pytest tests/integrations/test_agno.py # 23 tests, offline ``` -------------------------------- ### Run the LlamaIndex demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/llama_index/README.md Run the demo script to see the full workflow: handoffs, tool invocation, denials, revocation, and audit verification. No API key is needed. ```bash python examples/integrations/llama_index/demo.py # no API key needed ``` -------------------------------- ### Self-score verifier against envelope vectors Source: https://github.com/attenu-io/attenu-guard/blob/main/tests/vectors/README.md Iterates all envelope vector cases, asserting acceptance, states, and minimal failure set. Requires `pip install attenu-guard` and a `my_verifier` function returning a report with `accepted`, `states`, and `failures`. ```python from attenu_guard import vectors for case in vectors.load_envelope_vectors()["cases"]: report = my_verifier(case["bundle"], case["signer"], case["witness_keys"]) assert report.accepted == (case["expect"] == "accept"), case["name"] assert report.states == case["expect_states"], case["name"] # every entry for expected in case["expect_failures"]: # reason AND position assert expected in report.failures, (case["name"], expected) ``` -------------------------------- ### Run baseline.py for CrewAI baseline Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/baselines/crewai/output-2026-09-28.txt Command executed from the repository root in a fresh Python 3.12 virtual environment with crewai 1.15.22 and its dependencies installed from PyPI. No network or API key is needed because the model is scripted. ```bash python examples/baselines/crewai/baseline.py ``` -------------------------------- ### Verify tampered and widened bundles with attenu-guard verify Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/verify/README.md Two failure cases: a rewritten denial (integrity=False) and a wrong grant (monotonicity=False). Both are findings pointing at different people. ```bash pipx run attenu-guard verify tampered.bundle.json --hs256-key 73616d706c652d6b6579 # integrity=False … anchor=FAILED — a denial was rewritten into an allow after the fact ``` ```bash pipx run attenu-guard verify widened.bundle.json --hs256-key 73616d706c652d6b6579 # integrity=True monotonicity=False … anchor=verified — a correctly signed ledger in which a child was # granted more than its parent: what an insider holding the key could write, and the invariant still catches it ``` -------------------------------- ### Run CrewAI integration demo and tests Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/crewai/README.md Run the offline demo, the 47 offline tests, and an optional live smoke test with an OpenAI API key. ```bash python examples/integrations/crewai/demo.py # offline, no API key python -m pytest -q tests/integrations/test_crewai.py \ tests/integrations/test_crewai_conformance.py \ tests/integrations/test_crewai_recipe_demo.py # 47 tests, offline RUN_LIVE=1 OPENAI_API_KEY=... python examples/integrations/crewai/live_smoke.py ``` -------------------------------- ### Scoring script for bundle vectors Source: https://github.com/attenu-io/attenu-guard/blob/main/tests/vectors/README.md Iterates over all bundle vector cases, runs your verifier, and asserts acceptance and the minimal set of expected failures. Requires `pip install attenu-guard`. The `expect_failures` list must be a subset of `report.failures`; extra failures are allowed. ```python from attenu_guard import vectors for case in vectors.load_bundle_vectors()["cases"]: report = my_verifier(case["bundle"], case["signer"]) # your implementation assert report.accepted == (case["expect"] == "accept"), case["name"] for expected in case["expect_failures"]: # reason AND position assert expected in report.failures, (case["name"], expected) ``` -------------------------------- ### Score vectors under -02 rules with attenu_guard Source: https://github.com/attenu-io/attenu-guard/blob/main/tests/vectors-02/README.md Loads every -02 vector and asserts the outcome matches the expected accept or reject reason. Requires pip install attenu-guard. Uses the HS256 single-signer public-test-key profile from the signer block. ```python from attenu_guard import vectors, wire for name, data in vectors.load_vectors_02().items(): signer = wire.HS256TestSigner(bytes.fromhex(data["signer"]["secret_hex"]), kid=data["signer"]["kid"]) try: wire.load(data["tokens"], signer, now=data["now"], draft="02", accepted_algs=data["verifier"]["accepted_algs"], audience=data["verifier"]["audience"]) outcome = "accept" except wire.WireError as e: outcome = e.reason assert outcome == (data.get("expect") or data["expect_reject_reason"]), name ``` -------------------------------- ### Run baseline.py for google-adk Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/baselines/google_adk/output-2026-09-28.txt Command to run the baseline script from the repository root in a fresh Python 3.12 venv with google-adk 2.10.0 and google-genai 2.25.0 installed. No network or API key is needed; the model is scripted. ```bash python examples/baselines/google_adk/baseline.py ``` -------------------------------- ### Expected output from LangGraph integration demo Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/integrations/langgraph/README.md Abridged output from the demo run. The full transcript includes raw audit-log lines in section 6. The bundle path and pubkey vary per run. ```text 1. The authority the orchestrator holds orchestrator Authority(scopes=['crm.*', 'mail.send'], ...) will delegate Authority(scopes=['crm.read'], ...) summarizer.is_narrower_than(orchestrator): True 2. What a greedy delegation request gets (met down, never up) requested Authority(scopes=['crm.*', 'mail.send', 'payments.transfer'], ...) granted Authority(scopes=['crm.*', 'mail.send'], ...) narrower than parent? True 'payments.transfer' granted? False 3. Running the graph: crm_query allowed, crm_export denied before its body runs ok node 'summarize' ran DENIED node 'export' denied: scope_not_granted ... node bodies that actually ran: ['summarize(rows=4200)'] -> AuthorityDenied propagates straight out of graph.invoke(); the LangGraph run never reaches export's body. 4. Execution binding: genuine WRAPPER_SYNC, no attestation flag capture: wrapper_sync summarize() mutated its OWN argument in place, after the call was authorized: state['expected_rows'] became -1 inside the call (it was 4200 when authorized) authorized_params_hash == invoked_params_hash: True This is NOT a tautology: the snapshot is taken BEFORE the call and re-used for BOTH hashes rather than re-read from the (now-mutated) argument afterward -- an adapter that instead re-read `state` post-call would commit a DIFFERENT invoked_params_hash here. What it proves: the parameters committed to the ledger are the ones captured before the call, so a body that mutates its own input cannot rewrite the evidence of what it was authorized to do. What it does NOT prove: this is ONE observation reused twice, not two independent readings compared -- it cannot detect a mutation made between the snapshot and the invocation (a user-supplied `context_fn` runs in that window). It says nothing about what summarize() did with the arguments, and nothing about a call path that reaches crm_query without going through this node. 5. Revocation: a call that was legal a moment ago, denied before revoke: summarize({'expected_rows': 10}) allowed? True DENIED denied: revoked: node has been revoked -> guard_node's wrapper is a plain callable: LangGraph was never required to exercise it, on this call or on the graph run above. 6. The ledger, checked without this process (9 raw audit-log lines printed here: seq 0-8, one per root/spawn/kill/ allow/outcome/deny event) 9 events, hash chain: True bundle: (fresh temp dir)/evidence-bundle.json verifying it with the packaged command: attenu-guard verify evidence-bundle.json --pubkey ... integrity=True monotonicity=True containment=True anchor=verified nodes=3 actions_checked=1 OK reviewer view: 3 nodes 7. BASELINE: the same two node functions, no guard installed node bodies that actually ran: ['summarize(rows=4200)', 'export'] CRM exported without a guard installed? True LangGraph itself carries no authority across a node call: a plain callable node runs whatever its body says, with no relation at all to what any other node in the graph is allowed to do. RESULT: OK ``` -------------------------------- ### Run offline demo with scripted model Source: https://github.com/attenu-io/attenu-guard/blob/main/examples/contrib/adk-samples/attenu-guard/README.md Run the demo offline using a scripted model that replays a fixed list of function calls. The Runner, flows, callbacks, and plugin manager are real; only the model is substituted. ```bash uv run python demo.py ``` -------------------------------- ### Run the test suite Source: https://github.com/attenu-io/attenu-guard/blob/main/AGENTS.md Run the property-based tests with the source on the Python path. CI runs the full matrix including other test files under tests/. ```bash PYTHONPATH=src python3 tests/run_properties.py ``` -------------------------------- ### Load and verify delegation token vectors with attenu_guard Source: https://github.com/attenu-io/attenu-guard/blob/main/tests/vectors/README.md Use this snippet to score an independent verifier against the packaged delegation token vectors. It iterates over all vectors, calls your verifier with the token data, signer, and current time, and asserts the outcome matches the expected result or rejection reason. Requires pip install attenu-guard. ```python from attenu_guard import vectors for name, data in vectors.load_vectors().items(): outcome = my_verifier(data["tokens"], data["signer"], data["now"]) assert outcome == (data.get("expect") or data["expect_reject_reason"]) ```