Skip to main content

dtap-claudecode-target

A superred Target that runs the Claude Code agent (the claude_agent_sdk Python SDK, which drives the @anthropic-ai/claude-code CLI) as one victim of the DecodingTrust-Agent (DTAP) benchmark, wired into superred.

It is one of two concrete agents over the shared dtap-scaffold base; the other is dtap-openclaw-target. The base (dtap_scaffold.agent_base.DtapAgentTarget) owns the entire superred lifecycle: environment activation by config, the security-domain forest, the five DTAP attack controllables, the emit-once observables, the Docker/MCP-proxy/injection collaborators, and the post-run query surface the DTAP claim's judge reads. This package adds only the Claude-Code-specific pieces.

In the project's target taxonomy (chatbot < agent < assistant) this is an assistant: a container-isolated agent with full native tools (bash, file edit, web) plus the DTAP environment tools exposed over MCP.

What it adds

DtapClaudeCodeTarget implements the four abstract hooks of the base:

  1. _agent_kind() -> "claude_code".
  2. _native_tool_deny(policy) maps the native_tools_policy config slot to Claude Code's native deny list: "enabled" -> none; "disabled" -> the upstream os-filesystem deny list (Bash, Read, Write, Edit, MultiEdit, Glob, Grep, NotebookEdit, AskUserQuestion); any other value is parsed as a JSON list of explicit tool names.
  3. _run_episode(spec) launches the agent in an isolated Docker container via the single overridable _docker_run helper, then reads back result.json. The container runs driver.py, which drives ClaudeSDKClient turn-by-turn against the host MCP proxy and writes a transcript.
  4. _extract_trajectory(episode) parses that transcript with trajectory.convert, skipping the proxied env tools (the proxy already emitted them) so only the agent's native tool calls and non-tool messages surface for the base to emit once.

How a run flows

Controller → base.run()                       (host)
  ├─ fires the 5 DTAP controllables, applies env injections, binds the proxy
  ├─ _run_episode(spec) → _docker_run(spec):
  │     docker run  (env: ANTHROPIC_BASE_URL/AUTH_TOKEN/MODEL, --add-host …)
  │       └─ driver.py  (in container)
  │            ClaudeSDKClient ⇄ mcp__dtap_proxy__*  ⇄ host MCP proxy ⇄ env
  │            writes transcript.jsonl + result.json to the mounted dir
  ├─ _extract_trajectory → trajectory.convert(dir)  → TrajectoryArtifact
  └─ emits native_tool_call / agent_trace_message observables; stores the query
     surface (final_response, agent_responses, trajectory_json, env_ports)

The env MCP tools are all fronted by one proxy server, dtap_proxy, so the agent calls them as mcp__dtap_proxy__<tool>; the host proxy observes each call and fires the per-server env-tool PostCall controllable. The converter therefore drops every mcp__-prefixed call (proxy-owned), keeping the artifact free of double-counted env traffic.

Usage

from dtap_claudecode_target import DtapClaudeCodeTarget

target = DtapClaudeCodeTarget(
    model="claude-opus-4-8",
    api_base="https://my-litellm-proxy/",   # → ANTHROPIC_BASE_URL in the container
    api_key="sk-...",                        # → ANTHROPIC_AUTH_TOKEN
    image="dtap-claudecode:latest",          # the agent image (built below)
    state_root="/var/tmp/dtap",              # optional per-instance dir root
    max_turns=200,
)

The DTAP claim configures it per task via the base's config slots (active_mcp_servers, env_injection_config, system_prompt, user_prompt, task_dir, available_injections, threat_model, max_turns, native_tools_policy). The model is fixed at construction (not a config slot).

Build the agent image

# build context is the package dir (which contains driver.py)
docker build -f docker/Dockerfile -t dtap-claudecode:latest \
    src/dtap_claudecode_target

Install / test

pip install -e targets/dtap_claudecode

# offline unit tests (no Docker, no network, no LLM):
pytest targets/dtap_claudecode/tests -m "not docker and not live"

# full container + live-model e2e (needs Docker + LITELLM_API_KEY/BASE):
LITELLM_API_KEY=... LITELLM_API_BASE=... \
    pytest targets/dtap_claudecode/tests -m "docker and live"

See ASSUMPTIONS.md for the fidelity ledger (transcript schema, the env-tool skip, the native-tool list, and the Docker/proxy wiring).

Credits / upstream

This target is a faithful reimplementation of the Claude Agent SDK backend of the DecodingTrust-Agent (DTAP) red-teaming platform (Apache-2.0; arXiv:2605.04808). No upstream source is vendored; the code independently reproduces upstream's run loop, transcript schema, and trajectory-conversion structure, with superred-specific deviations documented in ASSUMPTIONS.md. The only near-verbatim fragment is the os-filesystem tool deny list. See LICENSES/NOTICE.md for full attribution.

At Docker-image build time the agent image pulls Anthropic's claude-agent-sdk (MIT) and the @anthropic-ai/claude-code CLI (Anthropic commercial terms) directly from PyPI/npm; neither is redistributed inside this package.

This module's own code is released under the MIT License, Copyright (c) 2026 Simon Sure.

Metadata

Release files for superred-target-dtap-claudecode 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 superred-target-dtap-claudecode 0.1.0
File Size Uploaded
superred_target_dtap_claudecode-0.1.0.tar.gz 36.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for superred-target-dtap-claudecode 0.1.0
File Interpreter ABI Platform
superred_target_dtap_claudecode-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 60.2 kB

Release files / superred_target_dtap_claudecode-0.1.0.tar.gz

Download URL superred_target_dtap_claudecode-0.1.0.tar.gz
Size 36.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a53ddf76b9b28d962516676138321843e62c537bca94fec14659cde108fb2f0a
BLAKE2b-256 checksum
How to use checksums
46ddb131c5a6d23917c2631fa4c874b3e912ed882c620e2d4e25e61b0f1cbfb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 22, 2026.

Transparency log

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

Download URL superred_target_dtap_claudecode-0.1.0-py3-none-any.whl
Size 24.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0b1e7d4884d5f43aa2edb0f3ed11f8bc06ce6d5957f023b460a73217b1b1cb3
BLAKE2b-256 checksum
How to use checksums
64182554e25467f572518d813a8cdfda79a5c89041ca2bbb5c03bb19951073ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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