Skip to main content

Agentshield

Red-team your tool-using LLM agent in CI: run it against prompt-injection and exfiltration scenarios in a sandbox, score every tool call against a policy, and fail the pull request when it leaks.

CI Gate Docker License: MIT Python 3.11 | 3.12 OpenSSF Scorecard

30-second quickstart

git clone https://github.com/adityasharma1307/agentshield.git && cd agentshield
python -m venv .venv && . .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install .

# A careful agent passes: exit 0
python -m agentshield run --agent examples.careful_agent.agent:agent \
  --suite src/agentshield/scenarios/suites --policy src/agentshield/scoring/default_policy.yaml

# A leaky agent follows planted instructions and leaks a canary: exit 1, failing rules listed
python -m agentshield run --agent examples.leaky_agent.agent:agent \
  --suite src/agentshield/scenarios/suites --policy src/agentshield/scoring/default_policy.yaml

Run it with python -m from the checkout so the examples package is importable. To gate your own agent, point --agent at your_module:your_agent, or use the GitHub Action:

- uses: adityasharma1307/agentshield@main
  with:
    agent: your_package.agent:agent
    suites: src/agentshield/scenarios/suites
    policy: src/agentshield/scoring/default_policy.yaml
    fail_on: high

What it does

  • Adapters. One interface, AgentUnderTest.step, returns the agent's next tool calls or its final answer, and the agent never executes tools itself. Adapters cover HTTP, the OpenAI SDK, and LangGraph.
  • Sandbox. Every tool call goes through a mock ToolRegistry (search, read_file, send_email, http_get, db_query), each with a deterministic trap variant. Step and time limits apply.
  • Scenarios. 22 adversarial scenarios cover injection, exfiltration, scope creep, policy violation, and tool jailbreak. agentshield scenarios lists them.
  • Scoring. A declarative YAML policy is applied to the ordered trace. The default policy is tagged for the EU AI Act, the NIST AI RMF, India's DPDP Act, and UAE and DIFC data law.
  • Reports and gating. Reports are signed and checked with agentshield verify. The Docker GitHub Action fails a pull request at or above a chosen severity. An optional FastAPI service and React dashboard are included.

CI replays recorded fixtures and never calls a model provider. Local example-agent results are in RESULTS.md.

Threat model in brief

The agent under test, and everything a scenario feeds it, are treated as hostile. Agentshield measures whether the agent stays inside the policy, and it keeps scenario side effects off the host:

  • Holds today: tools are mocks only, tool output is deterministic, step and wall-clock limits apply, and the trace is complete, including rejected calls. Spans carry argument hashes, not raw arguments.
  • Network containment needs subprocess mode with firejail installed. In the default inprocess mode, a handler that opens its own socket is not stopped. Each run reports which boundary it actually had.
  • Out of scope: the model provider (prompts leave the machine), adapter code the operator chose to install, and binding a qknot signature to a person.

Read the full threat model before pointing a live agent at this tree. To report a vulnerability, see SECURITY.md.

Install

Python 3.11 or newer. From PyPI, the distribution is named agsh. The import package and the command are both agentshield:

pip install agsh
agentshield --version

Extras use the same name, for example pip install "agsh[openai]". agentshield on PyPI is an unrelated project.

To work on the code, install from a checkout of this repository:

python -m venv .venv

On Windows, activate with .venv\Scripts\activate. On macOS and Linux, activate with source .venv/bin/activate.

python -m pip install -e ".[dev,docs]"
agentshield --version

The OpenAI, LangGraph, OpenTelemetry, and service clients are optional: agsh[openai], agsh[langgraph], agsh[otel], and agsh[service] (or .[openai] and so on from a checkout). The core install does not import them.

Documentation

mkdocs build --strict builds the site after the docs extra is installed.

Development

ruff check .
ruff format --check .
mypy
pytest

Contributor workflow, versioning, and the changelog rule are in CONTRIBUTING.md.

License

MIT

Metadata

Release files for agsh 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agsh 0.1.0
File Size Uploaded Provenance Actions
agsh-0.1.0.tar.gz 133.6 kB With provenance Details for agsh-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agsh 0.1.0
File Interpreter ABI Platform Actions
agsh-0.1.0-py3-none-any.whl Python 3 none any Details for agsh-0.1.0-py3-none-any.whl

Total release size: 208.1 kB

Release files / agsh-0.1.0.tar.gz

Download URL agsh-0.1.0.tar.gz
Size 133.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7aee6a545ec257297d237594cc7926f01b298faf2004d85e8631add2cb7198ef
BLAKE2b-256 checksum
How to use checksums
d4c873d82ea55198e7b59269bb485c7a3e65d57a06e6a79d7f584fc3c647f088
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / agsh-0.1.0-py3-none-any.whl

Download URL agsh-0.1.0-py3-none-any.whl
Size 74.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d61d512e403ed488ad259f88b2c0368766e0ff90fd28fec37708651b823cbb58
BLAKE2b-256 checksum
How to use checksums
11ddfd25535e3d9dd781a68383dc762448cba985356b791a926075e711f04bde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for agsh 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for agsh-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page