ManipulationArena / release /docs /BLUE_ADAPTERS.md
krystal7's picture
Add files using upload-large-folder tool
0cc4f3a verified
|
Raw History Blame Contribute Delete
7.95 kB

Blue harness and model

The evaluated agent is the configured Blue harness plus model. All seven attack families use the same session boundary. Frozen attack plans, task inputs, attack budgets and Judge implementations remain bound to the selected case.

The default example selects harness: "dsh". Its model identifier is configurable. The original DeepSeek route retains its original initialization; other model identifiers use an explicit OpenAI-compatible DSH provider registration. The configured endpoint must support that protocol. A provider's authentication or model availability errors are surfaced as execution failures.

DSH example

Copy config/roles.example.json to an external directory and configure its endpoints and credential variables. Its Blue role is a complete built-in DSH configuration. Run a frozen unit with:

python -B examples/run_dsh.py --config /path/to/roles.json --image YOUR_NATIVE_IMAGE \
  --unit-key UNIT_KEY --output /path/to/runs/dsh-example

This invokes the supplied native execution adapter, including original MCP tools, session events and attack pauses. arena_result.json records the native verdict; runs/ retains tool and gate evidence.

For another DSH model, add its documented capabilities to the Blue role. For example, only for a model supporting these limits:

"capabilities": {"context_window": 200000, "max_output_tokens": 65536}

Both values must be positive integers, with the context window larger than the output limit. DSH requires these fields for models outside the default DeepSeek route. Custom adapters may also declare them and receive them in the factory context. They describe provider capacity: they do not replace native max_tokens, round, step or time budgets. Preparation and runtime reject an explicit native output budget that exceeds the declared model limit. No budget is silently reduced. Context handling remains part of the evaluated harness.

Other frameworks

For another framework, install your adapter and its dependencies in the native image and configure the Blue role, for example:

{
  "model": "YOUR_MODEL",
  "api_url": "https://blue-api.example.com/v1",
  "api_key_env": "ARENA_BLUE_API_KEY",
  "harness": "YOUR_HARNESS",
  "adapter": "your_adapter:create_harness",
  "python": "/opt/blue-runtime/bin/python"
}

harness is the recorded framework identifier, adapter is an importable Python factory, and python is an absolute interpreter path inside the user-supplied image. The adapter is imported in the actual Blue worker environment. Custom adapters do not import or execute DSH for Blue. There is no fallback to another harness or model. Red, Judge, native scoring and user simulation keep their own role configurations.

Factory and sessions

The factory is called as create_harness(context). The context contains:

Field Meaning
protocol_version Integer 1.
harness, model The selected framework and model identifiers.
api_url, api_key The Blue endpoint and resolved credential for this worker; Obstruction supplies its existing recording proxy.
workspace, session_home Task workspace and session evidence directory.
environment The worker environment, including native tool and attack control routes.
runtime_patches Paths to original tool/MCP, gate, persistence and runtime configuration documents.
runtime_options Existing session limits and constructor options, including timeouts and token budgets where provided.
capabilities Declared context_window and max_output_tokens, or an empty object.

Return an object with arena_protocol_version = 1, start_session(session_id) and close(). Each session must expose id and run(prompt, on_notification=None). Runs return an object with final_response (text), finish_reason and events (native event dictionaries). Supported successful terminal reasons are stop, end_turn, completed and finished.

An optional client.session_prompt(session_id, content) can inject user updates into a running session. Without it, the existing caller queues updates as follow-up turns in the same session. client._stderr_lines and client._proc are optional diagnostic interfaces.

def create_harness(context):
    # Construct your framework using the supplied Blue model/API and workspace.
    # The returned implementation owns tool execution, event delivery and gates.
    return YourHarnessAdapter(context)

The project supplies the session interface and native integration, rather than implementations of every external framework. A custom adapter must translate the original runtime configuration to its framework's tool and hook APIs. Merely returning final text does not implement the benchmark protocol.

Attack and tool protocol

Preserve the tool names, descriptions, schemas, results and task prompts passed by the native runner. Read the supplied runtime patch documents for stdio MCP server commands, arguments and environments. Launch those servers in the task workspace and expose their tools under the original namespaces. For Obstruction, the original native_action MCP interface continues to own native environment actions and budgets.

Deliver session events through on_notification using an object with method = "session.event" and payload = {"event": event}. Each event uses the original type/data schema, including assistant/message, tool/call and tool/result, qualified tool names, call IDs and message content. Persist session events as JSONL under session_home/sessions where the native runner consumes them.

The supplied gate plugin source specifies the existing control-file handshake. Its paths are included in runtime_patches; the worker environment provides STAGE2_GATE_DIR, STAGE2_SESSION_ROOT, STAGE2_GATE_TIMEOUT_MS and, where relevant, ATTACK_V2_*. Implement equivalent pause/decision/context-update handling in the selected framework. Wait for the host's attack decision at the same event boundary before continuing. Preserve tool-result replacements, live user updates, monitor behavior and task-owned tool execution. A framework that cannot honor a required hook must fail explicitly rather than silently skip that attack mechanism.

Adapters must apply the supplied timeouts, token budgets and persistence behavior. They must propagate provider and tool errors and retain evidence. Their implementation must not invent tool results, change frozen attacks, use Judge credentials or replace native task scoring.

Runtime layout

The interpreter and adapter dependencies must already exist in the supplied image. The four interactive families also require PyYAML in that interpreter; the runner provisions the original separate native MCP tool environment. Custom Blue startup does not install the DSH SDK into the selected interpreter.

Health tasks in the two native live adapters run Blue inside a nested Harbor task container. Provide a self-contained Python virtual environment with a standalone base; the runner copies that environment, its base and the adapter bridge into the task container at the same paths. System-prefix environments such as /usr or /usr/local are not self-contained. Package external CLI executables and their dependencies with that environment or make them available in the native task image.

The fixed Tau user simulator continues in a separate ungated DSH environment. Its credentials, model and interpreter are independent of custom Blue. The attack Judge and native auxiliary roles retain their original implementations.

Configuration and preparation are offline operations. A successful import or mock session test does not validate an external framework's live tools, provider transport or attack hooks; run native integration checks with the supplied image and your adapter before reporting benchmark measurements.