Skip to content

Latest commit

 

History

History
355 lines (289 loc) · 18.2 KB

agents.md

File metadata and controls

355 lines (289 loc) · 18.2 KB
myst
html_meta
description keywords
Configure AgentKernelArena agents for controlled A/B experiments and RL-ready GPU kernel optimization runs.
AgentKernelArena, agents, models, Claude Code, Cursor, Codex, GEAK, A/B testing, agent RL, ROCm, GPU

Configure agents and models in AgentKernelArena

AgentKernelArena evaluates one agent per run. The agent is selected by the agent.template field in the chosen run configuration. This topic lists the supported agents, explains how models and providers are configured, and describes how to use the arena for A/B testing.

Supported agents

To generate tasks from external SIKL data, use the separate sikl_task_builder authoring workflow. It runs before task discovery and produces tasks for the optimization agents listed below.

The following agents are available.

agent.template Description
cursor Cursor Agent CLI
claude_code Anthropic Claude Code CLI
codex Codex CLI
deepseek_harness DeepSeek Harness headless CLI (setup)
forge KernelForge on schema-v3 kernel tasks; target languages triton, gluon, hip and flydsl (FlyDSL rewrites need a Triton or HIP baseline)
geak GEAK Workflow engine on schema-v3 kernel tasks; target languages triton, gluon, hip and flydsl
qa_auditor Task QA auditor; does not optimize kernels (see Audit tasks with the QA auditor)

The registry maps the legacy names geak_v4 to geak and forge_operator2flydsl to forge, with the same configuration and post-processing. Forge and GEAK work on schema-v3 tasks; the run's top-level target_language selects the candidate language, and an unsupported language, or a package that is not a v3 kernel task (such as the e2e serving tasks), fails before any engine work. See the GEAK and Forge guides for runtime requirements. Registry availability alone does not establish GPU or model qualification.

Select one in a run configuration:

agent:
  template: claude_code

Each agent lives under agents/<agent_name>/ and is registered into a shared registry, so the framework loads only the agent you select.

The supported identifiers are defined by AgentType in src/module_registration.py. Retired templates and compatibility notes are listed in the release notes.

The Cursor, Claude Code, and Codex integrations reuse their host CLI login state. Specialized integrations have additional setup and configuration under their respective agents/<agent_name>/ directories.

quality_loop is intentionally not an agent.template. It is a repository-level task maintenance workflow that invokes Codex roles across the tasks selected by its run config and publishes at most one draft PR. It never creates GitHub issues. See Audit and harden tasks.

Models, providers, and agent settings

The selected integration controls model, provider, authentication, effort, timeout, and iteration settings. Its defaults live in its CLI and agents/<agent_name>/agent_config.yaml; supported fields in the run config's agent mapping override those defaults. See CLI run-level overrides and each specialized integration's guide for supported fields and precedence. These settings do not belong in task configurations.

For Cursor, Claude Code, and Codex, authenticate with the host CLI. A normal run preflights only the selected CLI. When the config selects one of these first-class integrations (or qa_auditor), select the run configuration first and check its CLI/backend:

CONFIG_PATH=example_configs/quickstart_claude_mi300.yaml
make docker-check-agents CONFIG="$CONFIG_PATH"

Use AGENTS=<comma-separated names> for an explicit subset or AGENTS=all for the original three CLIs (Cursor, Claude Code, and Codex) and login states. GEAK and its aliases resolve to Claude Code for this check; normal runs also check the pinned GEAK engine and SDK. Other specialized integrations have their own checks; their README files document dependencies and provider configuration.

DeepSeek Harness supports config-selected checks and explicit AGENTS=deepseek_harness. Install its pinned CLI, export DEEPSEEK_API_KEY, and select one of the quickstart_deepseek_harness_* example configurations. Its preflight checks version and credential presence without contacting the provider. Each task uses a fresh Harness home and the standard Arena evaluator. See the integration guide for model, endpoint, Docker, and session-isolation details.

DeepSeek's run-level overrides and per-invocation budget follow its integration guide. It uses reasoning_effort rather than the other CLIs' effort field. Agent completion and independent candidate acceptance are reported separately.

Iteration and time budgets

Cursor, Claude Code, Codex, and DeepSeek Harness accept agent.budget_mode:

budget_mode Behavior
iterations (default) One agent session. The prompt asks for up to max_iterations versions, and timeout_seconds is the session's hard limit. Unchanged from earlier releases.
time No iteration count. timeout_seconds is the agent's wall-clock budget for the task. If the agent ends its session early, Arena resumes the same session with a prompt stating the time remaining, and stops it at the original deadline.
agent:
  template: claude_code
  budget_mode: time
  timeout_seconds: 21600

The deadline is fixed when the first session starts, after the framework's setup and baseline measurement and before candidate evaluation, so those phases do not consume the budget. A continuation starts only while at least 10 minutes remain, and at most 20 sessions run per task. A continuation stopped at the deadline is not an agent failure; a first session that times out, a nonzero exit, or a failed result still is. Arena evaluates the files delivered at the declared paths either way.

To resume, time mode keeps the provider's session state: Claude Code runs with --session-id instead of --no-session-persistence, and Codex runs without --ephemeral. Those CLIs write state to their own home directories. DeepSeek Harness keeps one isolated DSH_HOME per task launch and passes the opening JSON event's session ID through --session-id on each continuation. Its continuations retain the same task directory and home, with separate prompt/stdout/stderr artifacts per invocation; a later task retry gets a fresh home. A missing session ID stops continuation, and a failed adoption never falls back to a new conversation. The shared loop is src/tools/agent_time_budget.py, the prompt text is src/prompts/agent_budget.py, and each CLI's resume arguments and output parsing stay in its agents/<agent_name>/launch_agent.py. Other agents reject budget_mode: time when the run starts; GEAK and Forge use their own budget settings.

Agent sandbox

An agent runs with its CLI's own sandbox disabled, inside a container that mounts the whole checkout. Unconfined, it can read and change framework code, other task packages and other runs' workspaces, including earlier agents' solutions. The framework therefore confines each agent's process tree with Linux Landlock wherever it can. The run configuration selects the mode:

agent:
  template: codex
agent_sandbox: auto   # the default; or landlock, or none
Mode Behavior
auto (default) Confine every launch the sandbox supports. Any other launch runs unconfined, and task_result.yaml records why.
landlock Confine every launch. A run or task the sandbox does not support fails before its workspace is created.
none No sandbox.

The sandbox supports a launch when all of these hold:

  • the agent is Claude Code, Codex, Cursor or DeepSeek Harness. GEAK and Forge are not supported; the QA auditor is part of the framework and is never confined;
  • the task is a single-GPU kernel task. Serving tasks under tasks/e2e/ need the full checkout, and multi-GPU tasks (a task.yaml whose distributed block sets world_size to 2 or more) are not supported;
  • the run directory is inside the checkout, as it is with a relative workspace_directory_prefix (the default). Outside it, the agent could reach other runs' workspaces and the task-session state;
  • the kernel offers Landlock ABI 3 or later (Linux 6.2+) and seccomp does not block it. Docker's default seccomp profile allows it;
  • HOME does not contain the checkout. The Docker runner gives each worker its own HOME under /tmp.

The sandbox grants HOME read-write. make docker-parallel-run gives each worker its own HOME, but make docker-run uses the host's HOME with the agents' configuration mounted, so an agent could leave settings or hooks there that the agents of later tasks read. In that case the framework logs a warning and the result records home_isolated: false.

A confined agent:

Can Cannot
Read and write its task workspace, its HOME, /tmp and /dev/shm Open, list or change anything else in the checkout: src/, tasks/, other workspaces, logs/ and other runs
Read the frozen baseline workspace and the framework's agent context files Write the baseline workspace or the framework's task-session state
Read and execute everything outside the checkout except /dev Open device nodes other than the terminal, null/random and GPU devices
Use the network

The framework writes one policy per task launch into the task-session state directory. Each launcher starts its CLI through src/agent_sandbox.py, which restricts itself, checks that it can no longer read a framework file, records an attestation and then executes the CLI. Every tool and compiler the agent starts inherits the restriction. The framework, the final evaluation and the candidate verifier run outside the sandbox, so measurements are unchanged.

The agent can write /tmp and HOME, where the runner keeps the build caches. A cache key can be computed from the candidate's source, so a compiled artifact planted under it would be loaded in place of that source. The final evaluation therefore compiles into new, private cache directories in the task-session state: Triton, PyTorch extensions, TorchInductor, the Arena HIP kernel cache, the MIOpen kernel caches, XDG_CACHE_HOME, the AITER JIT directory and the FlyDSL runtime and autotune caches (unset, the AITER and FlyDSL caches default to HOME), plus AITER_ROOT_DIR where the runner sets it. It also sets PYTHONPYCACHEPREFIX, so Python ignores any __pycache__ bytecode in the workspace, where the candidate and the evaluation harness are imported from. This holds with or without the sandbox. The cost is that the final evaluation compiles as a fresh container does: the candidate, and any AITER module it imports, is built again, outside the timed region.

task_result.yaml records the outcome under agent_sandbox. A resumed task keeps the candidate of its earlier invocations, so the outcome combines every invocation that launched the agent, including one that was interrupted (its launch is recorded before the agent starts). One that launched nothing, because the budget was already spent, does not count. The status is:

  • enforced when every launch of the task was confined and attested the policy;
  • unattested or invalid when a confined launch did not attest it. The candidate is then not accepted;
  • mixed when the agent ran confined in some invocations and unconfined in others, for example a run resumed with a different agent_sandbox mode;
  • not_applied with a reason when auto ran the agent unconfined, and off when the sandbox was off;
  • not_launched when no invocation launched the agent.

landlock accepts only enforced (or not_launched); auto and none judge an unconfined or mixed candidate as without the sandbox. Run summaries and the CSV report show the status of each task.

When a whole auto run cannot be confined, for example on a kernel without Landlock, main.py also prints a note when it starts.

Limits: the network is not restricted. Every GPU render node in the container stays reachable; as without the sandbox, the GPU is selected through the visible-device environment variables. With Landlock ABI 6 the agent also cannot signal processes outside its sandbox.

Agent cost records

For every task whose agent was launched, main.py writes <run_dir>/agent_costs/<task_workspace>.json, for all agents. The record is written after the agent returns or fails, and a cost-record error never changes the task outcome. Each launcher only exposes what its provider reports; the shared tool src/tools/agent_cost.py normalizes it and writes null when a value is not reported. Arena never estimates dollars from tokens.

Agent Dollars Tokens
claude_code result.total_cost_usd result.usage
codex null (not reported by the CLI) turn.completed.usage
cursor null (not reported by the CLI) result.usage, when the CLI version emits it
geak Claude Agent SDK ResultMessage.total_cost_usd ResultMessage.usage
forge KernelForge llm_usage.total_cost_usd, when cost_available is not false KernelForge llm_usage counters
deepseek_harness null The --json final event's usage, when emitted; otherwise null
qa_auditor null null

Main fields:

  • total_cost_usd and usage: totals over every attempt and session, or null.
  • cost_status and usage_status: complete; partial when the total is a lower bound (for example, a session stopped at its deadline reported nothing, or GEAK work finished after its last SDK result); not_reported; or ambiguous when resumed values cannot be combined safely.
  • attempts: one entry per launch of the task, including a later --resume-run attempt, with run settings, agent seconds, any launcher error, and each raw provider report (invocations).

Resumed sessions are not double counted. Codex token usage and Claude Code 2.1.277 or later dollar totals are running totals for the session, so only the increase is added. Older Claude Code versions report per process, and those values are summed. If the Claude Code version cannot be parsed and a session was resumed, the dollar total is null with status ambiguous. Token field names are converted to snake_case but otherwise kept as the provider defines them. For example, Codex input_tokens includes cached_input_tokens, while Claude input_tokens excludes cache reads.

A/B testing and ablation studies

AgentKernelArena is designed to test changes to agent behavior: a model, Model Context Protocol (MCP) server, skill, prompt strategy, tool integration, memory strategy, or policy.

Run the same task set twice, once with the capability enabled and once without, then compare the standardized scores:

CONFIG_PATH=example_configs/quickstart_claude_mi300.yaml

# Baseline
make docker-run CONFIG="$CONFIG_PATH" RUN_ARGS="--run-suffix baseline"

# With the new capability enabled in the agent configuration
make docker-run CONFIG="$CONFIG_PATH" RUN_ARGS="--run-suffix with_capability"

Both runs land in the same workspace directory with distinct run names, so the visualization dashboard can show them side-by-side. Hold every non-treatment factor constant—including tasks, hardware, environment, and scoring—and repeat matched trials when agent behavior is stochastic. The observed deltas estimate the effect of the capability under test.

You can also generate a text comparison directly:

python3 src/tools/compare_runs.py \
  workspace_MI300_claude_code/run_<timestamp>_baseline \
  workspace_MI300_claude_code/run_<timestamp>_with_capability

The resulting task_result.yaml files expose compilation, correctness, timing, speedup, and score fields that an external RL system can consume as reward signals. AgentKernelArena does not itself update a policy.

Add a new agent

To integrate a custom agent:

  1. Create agents/<your_agent>/ with a launch_agent(eval_config, task_config_dir, workspace) function decorated with @register_agent("<your_agent>").
  2. Add an entry to the AgentType enum and an import branch in src/module_registration.py.
  3. Wire the agent into the prompt builder and post-processing handler in src/module_registration.py if it needs the standard behavior.
  4. Add agent_config.yaml and document the supported run-level overrides. Keep provider, CLI and authentication behavior in the integration, not in task files.
  5. Add Docker provisioning and preflight support when the integration needs another executable or dependency. Registration alone does not install an agent or make its host login available in the worker.
  6. Add focused tests and run a real task through Docker with the configured agent before claiming execution support.

A minimal launcher skeleton is:

# Copyright(C) [2026] Advanced Micro Devices, Inc. All rights reserved.
from agents import register_agent


@register_agent("your_agent")
def launch_agent(
    eval_config: dict,
    task_config_dir: str,
    workspace: str,
) -> str:
    # Build the task prompt, invoke the agent in the workspace, and return
    # its output. Propagate execution failures; the evaluator owns acceptance.
    raise NotImplementedError("Implement the agent invocation")

Use the registry and a nearby launcher as the interface reference. Follow CONTRIBUTING.md for architecture boundaries, regression checks and publication requirements.