Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@

For AI-Ready tasks, tag the source and run `dokimi eval check ./evals --controls --mode host --json` before including them in Usage or weighted coverage.

Measure each shipping helper on the same tasks and agents with `dokimi agent run --arms base,assets`.

## Persisted formats

- Every artifact format is a versioned JSON Schema in
Expand All @@ -117,9 +119,9 @@

## What goes in the tree

- Runs write to git-ignored output dirs under `dokimi/`: `results/`,

Check notice on line 122 in AGENTS.md

View workflow job for this annotation

GitHub Actions / self / repo scan

repo scan unresolved

AGENTS.md: path: `results/`: tried results
`reports/`, `answers/`, `eval/` (not the `dokimi/dokimi/eval/` package),

Check notice on line 123 in AGENTS.md

View workflow job for this annotation

GitHub Actions / self / repo scan

repo scan unresolved

AGENTS.md: path: `answers/`: tried answers

Check notice on line 123 in AGENTS.md

View workflow job for this annotation

GitHub Actions / self / repo scan

repo scan unresolved

AGENTS.md: path: `reports/`: tried reports
`baselines/`. Logs, coverage files and tarballs stay local too.

Check notice on line 124 in AGENTS.md

View workflow job for this annotation

GitHub Actions / self / repo scan

repo scan unresolved

AGENTS.md: path: `baselines/`: tried baselines
- `dokimi/data/` holds only the fixtures this repo's own tests and
examples read: `data/skills/fastcontext/`, `data/agent_profiles/`,
`data/explore_tasks/`. The other skills there, `data/skills/dokimi-design-evals/`
Expand Down Expand Up @@ -151,7 +153,7 @@
`gh repo fork --remote --remote-name fork`, then `git push -u fork <branch>`
and `gh pr create -R intel/dokimi --base main --head <you>:<branch>`. Push
branches only to the fork, even with write access to `intel/dokimi` (bot
branches, `dependabot/*` and `renovate/*`, are the exception).

Check notice on line 156 in AGENTS.md

View workflow job for this annotation

GitHub Actions / self / repo scan

repo scan unresolved

AGENTS.md: path: `dependabot/*`: glob dependabot/* matches nothing in the tree; a build may create it
- When a change depends on an open PR, wait for it to merge or put both in one
PR; PRs are not stacked on each other's branches.

Expand All @@ -159,7 +161,7 @@

Review your diff against [REVIEW.md](REVIEW.md). For the commands below, set
`base_ref` to the upstream `main` ref named by `make ci-local`, for example
`intel/main` or `origin/main`.

Check notice on line 164 in AGENTS.md

View workflow job for this annotation

GitHub Actions / self / repo scan

repo scan unresolved

AGENTS.md: path: `origin/main`: tried origin/main

Check notice on line 164 in AGENTS.md

View workflow job for this annotation

GitHub Actions / self / repo scan

repo scan unresolved

AGENTS.md: path: `intel/main`: tried intel/main

- For each test of changed behaviour, break the code it covers (flip a
condition, drop a branch), confirm the test fails, then revert the break.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dokimi catalog check --root /path/to/your/catalog --kind skills

Then follow [reviewing a skill or repository](dokimi/docs/reviewing.md) for the next step and its cost. Agent experiments need the selected provider or logged-in harness; executable coding tasks also need their supported container environment. Check [harness support](dokimi/docs/coding-harnesses.md) before choosing a runner.

For scored coding-agent sessions and offline pilot replay, use `dokimi agent run` and `dokimi agent replay`. Use `dokimi eval check --controls` to verify the correct and look-alike wrong solutions. See [AI-Ready coding-agent tests](dokimi/docs/coding-harnesses.md#ai-ready-coding-agent-test).
For scored coding-agent sessions and offline pilot replay, use `dokimi agent run` and `dokimi agent replay`. Use `dokimi eval check --controls` to verify the correct and look-alike wrong solutions. Use the `--arms base,assets` option to measure each shipping helper. See [AI-Ready coding-agent tests](dokimi/docs/coding-harnesses.md#ai-ready-coding-agent-test).

## Read the evidence

Expand Down
8 changes: 8 additions & 0 deletions dokimi/changelog.d/20261124_030000_agent-helper-effect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!--
Copyright (C) 2026 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

### Added

- Compare each shipping helper to the baseline on matched coding-agent sessions and report the effect per agent.
8 changes: 8 additions & 0 deletions dokimi/changelog.d/20261202_codex_sandbox_unavailable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!--
Copyright (C) 2026 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

### Fixed

- Mark failed Codex runs as inconclusive when a separate probe confirms Linux namespace failure.
29 changes: 29 additions & 0 deletions dokimi/docs/coding-harnesses.md
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,11 @@ repeat and a Wilson 95% interval for the checker pass rate. Exit 0 means all
controls and sessions passed, 1 that at least one failed, 2 that input was
invalid, and 3 that evidence was inconclusive without a failure.

On Linux, a failed Codex tool operation and a failed checker trigger a
separate namespace probe. A confirmed namespace failure makes the session
inconclusive and keeps its metering and transcript. Re-test the classification
with `pytest tests/test_agent_environment.py`.

With `--json`, `cost.spent_usd` sums known session costs and `cost.priced`
is false when any counted session lacks a price, or null when no calls were
counted. `cost.calls` sums reported agent turns. When the turn count is
Expand Down Expand Up @@ -1591,3 +1596,27 @@ under `data.sessions` in JSON output.
After changing the runner, run `pytest tests/test_agent_run.py` and repeat the
archived replay for each profile. Check the historical score and the measured
rubric coverage separately.

### Measure a shipping helper

Use `--arms base,assets` to run matched repeats with the baseline and with
each shipping helper. Supply `--helper NAME=DIR` once per helper. Keep the
helper out of the baseline task's `workspace/`.

```bash
dokimi agent run --tasks ./evals --agent claude-code=sonnet --agent codex=gpt \
--arms base,assets --helper docs=./helper-test --out-dir results/helpers --json
```

In host mode, a helper can overlay `workspace/` with the skill, `AGENTS.md`,
or docs index in the location each agent discovers. For MCP, provide
`claude-mcp.json` with a `mcpServers` object and `codex-mcp.toml` with a
`mcp_servers` table. Use environment references for credentials.

`data.helpers` reports the Usage difference for each helper, agent and model.
Each difference uses the same scored repeats on both sides. Evidence below
70% matched rubric coverage is inconclusive. Every shipping helper needs
a nonnegative difference on every measured agent. The helper gate fails
when no helper is declared or any measured difference is negative.
`pytest tests/test_helper_effects.py` exercises overlay isolation and the
helper gate.
2 changes: 2 additions & 0 deletions dokimi/docs/reference/cli-interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
"allow_abbrev": true,
"params": [
{"key": "--agent", "action": "_AppendAction", "choices": null, "const": null, "default": null, "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "option", "nargs": null, "position": null, "required": true, "type": "dokimi.commands.agent_run._agent#2c54f4024358"},
{"key": "--arms", "action": "_StoreAction", "choices": ["'base'", "'base,assets'"], "const": null, "default": "base", "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "option", "nargs": null, "position": null, "required": false, "type": null},
{"key": "--endpoint", "action": "_StoreAction", "choices": null, "const": null, "default": null, "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "option", "nargs": null, "position": null, "required": false, "type": null},
{"key": "--help/-h", "action": "_HelpAction", "choices": null, "const": null, "default": "==SUPPRESS==", "group_key": null, "group_required": null, "hidden": false, "is_flag": true, "kind": "option", "nargs": 0, "position": null, "required": false, "type": null},
{"key": "--helper", "action": "_AppendAction", "choices": null, "const": null, "default": null, "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "option", "nargs": null, "position": null, "required": false, "type": "dokimi.commands.agent_run._helper#f72c0463880e"},
{"key": "--json", "action": "_StoreTrueAction", "choices": null, "const": true, "default": false, "group_key": null, "group_required": null, "hidden": false, "is_flag": true, "kind": "option", "nargs": 0, "position": null, "required": false, "type": null},
{"key": "--key-env", "action": "_StoreAction", "choices": null, "const": null, "default": null, "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "option", "nargs": null, "position": null, "required": false, "type": null},
{"key": "--mode", "action": "_StoreAction", "choices": ["'docker'", "'harbor'", "'host'"], "const": null, "default": "host", "group_key": null, "group_required": null, "hidden": false, "is_flag": false, "kind": "option", "nargs": null, "position": null, "required": false, "type": null},
Expand Down
105 changes: 105 additions & 0 deletions dokimi/dokimi/agent_run/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright (C) 2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""Install matched helper treatments and calculate their paired Usage effect."""

from __future__ import annotations

import json
import shutil
import tomllib
from dataclasses import dataclass
from pathlib import Path
from typing import Any

from dokimi.files import InputError

from .scoring import usage_summary


@dataclass(frozen=True)

Check warning on line 20 in dokimi/dokimi/agent_run/helpers.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: flip-bool `True` -> `False`
class Helper:
name: str
root: Path

def validate(self) -> None:
workspace = self.root / "workspace"
codex = self.root / "codex-mcp.toml"
claude = self.root / "claude-mcp.json"
if not (workspace.is_dir() or claude.is_file() or codex.is_file()):
raise InputError(f"{self.name}: expected workspace/, claude-mcp.json or codex-mcp.toml")
if workspace.is_dir() and not any(workspace.iterdir()):
raise InputError(f"{self.name}: workspace/ is empty")
try:
if claude.is_file() and not _servers(json.loads(claude.read_text(encoding="utf-8")), "mcpServers"):
raise ValueError("claude-mcp.json needs mcpServers")
if codex.is_file() and not _servers(tomllib.loads(codex.read_text(encoding="utf-8")), "mcp_servers"):
raise ValueError("codex-mcp.toml needs exactly the mcp_servers table")
except (ValueError, OSError):
raise InputError(f"{self.name}: invalid MCP configuration") from None

def applies_to(self, agent: str) -> bool:
config = {"claude-code": "claude-mcp.json", "codex": "codex-mcp.toml"}.get(agent)
return (self.root / "workspace").is_dir() or (config is not None and (self.root / config).is_file())

def install(self, workspace: Path, config: Path, agent: str, argv: list[str]) -> None:
overlay = self.root / "workspace"
if overlay.is_dir():
shutil.copytree(overlay, workspace, dirs_exist_ok=True)
if agent == "claude-code" and (server := self.root / "claude-mcp.json").is_file():

Check warning on line 49 in dokimi/dokimi/agent_run/helpers.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-clause `agent == "claude-code" and (server := self.root / "claude-mcp.json").is_file()` -> `((server := self.root / "claude-mcp.json").is_file())`
local = config / server.name
shutil.copyfile(server, local)
# The launcher may be node.exe plus a script. Add flags before `-- PROMPT`.
argv[-2:-2] = ["--strict-mcp-config", "--mcp-config", str(local)]
if agent == "codex" and (server := self.root / "codex-mcp.toml").is_file():

Check warning on line 54 in dokimi/dokimi/agent_run/helpers.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-clause `agent == "codex" and (server := self.root / "codex-mcp.toml").is_file()` -> `((server := self.root / "codex-mcp.toml").is_file())`
with (config / "config.toml").open("a", encoding="utf-8") as file:
file.write("\n" + server.read_text(encoding="utf-8"))
Comment on lines +55 to +56


def _servers(config: Any, key: str) -> bool:
return isinstance(config, dict) and set(config) == {key} and isinstance(config[key], dict) and bool(config[key])

Check warning on line 60 in dokimi/dokimi/agent_run/helpers.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-clause `isinstance(config, dict) and set(config) == {key} and isinstance(config[key], dict) and bool(config[key])` -> `(isinstance(config, dict) and isinstance(config[key], dict) and bool(config[key]))`


def helper_effects(rows: list[dict[str, Any]], helpers: tuple[Helper, ...], repeats: int) -> dict[str, Any]:
if not helpers:
return {"status": "FAIL", "reason": "no shipping helper declared", "comparisons": [], "qualifying_helpers": []}
per_helper = {helper.name: _paired(rows, helper.name, repeats) for helper in helpers}
qualifying = [name for name, results in per_helper.items()
if results and all(row["effect"] is not None and row["effect"] >= 0 for row in results)]

Check warning on line 68 in dokimi/dokimi/agent_run/helpers.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-clause `results and all(row["effect"] is not None and row["effect"] >= 0 for row in results)` -> `(all(row["effect"] is not None and row["effect"] >= 0 for row in results))`
comparisons = [row for results in per_helper.values() for row in results]
if any(row["effect"] is not None and row["effect"] < 0 for row in comparisons):
status = "FAIL"
else:
status = "PASS" if len(qualifying) == len(helpers) else "INCONCLUSIVE"
return {"status": status, "comparisons": comparisons, "qualifying_helpers": qualifying}


def _paired(rows: list[dict[str, Any]], helper: str, repeats: int) -> list[dict[str, Any]]:
base = {_cell(r): r for r in rows if r["arm"] == "base"}
treated = {_cell(r): r for r in rows if r["arm"] == helper}
left, right = [], []
for key, row in base.items():
with_helper = treated.get(key, {**row, "arm": helper, "points": None})
if not _scored(row) or not _scored(with_helper):

Check warning on line 83 in dokimi/dokimi/agent_run/helpers.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-clause `not _scored(row) or not _scored(with_helper)` -> `(not _scored(row))`
row = {**row, "verdict": "INCONCLUSIVE", "points": None}
with_helper = {**with_helper, "verdict": "INCONCLUSIVE", "points": None}
left.append(row)
right.append(with_helper)
before = usage_summary(left, repeats)
after = usage_summary(right, repeats)
return [_delta(a, b, helper) for a, b in zip(before, after, strict=True)]


def _scored(row: dict[str, Any]) -> bool:
return row["verdict"] in ("PASS", "FAIL") and row["points"] is not None

Check warning on line 94 in dokimi/dokimi/agent_run/helpers.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-clause `row["verdict"] in ("PASS", "FAIL") and row["points"] is not None` -> `(row["points"] is not None)`


def _cell(row: dict[str, Any]) -> tuple[str, str, str, int]:
return row["agent"], row["model"], row["task"], row["repeat"]


def _delta(left: dict[str, Any], right: dict[str, Any], helper: str) -> dict[str, Any]:
baseline, treated = left["usage"], right["usage"]
effect = treated - baseline if treated is not None and baseline is not None else None
return {"helper": helper, "agent": left["agent"], "model": left["model"], "base_usage": baseline,
"helper_usage": treated, "effect": effect, "coverage": left["rubric_coverage"]}
51 changes: 41 additions & 10 deletions dokimi/dokimi/agent_run/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
from dokimi.repos.events import convert
from dokimi.repos.transcript import Transcript

from .adapters import Adapter, Route, Unavailable, adapter_for
from .adapters import Adapter, Codex, Route, Unavailable, adapter_for
from .checker import SYSTEM_ENV, check, inconclusive, refuse_workspace_checker, session_env
from .container import claim, container_evidence, model_activity
from .controls import check_controls, task_control_digest
from .helpers import Helper, helper_effects
from .scoring import GROUP_WEIGHTS, usage_summary

_ENV_ERROR = re.compile(
Expand All @@ -41,6 +42,7 @@
re.IGNORECASE,
)
_SECRET_NAME = re.compile(r"TOKEN|PASSWORD|PASSWD|AUTH|SECRET|KEY|PROXY", re.IGNORECASE)
_NAMESPACE_ERROR = re.compile(r"(?m)^bwrap: (?:Creating new namespace failed|No permissions to create a new namespace)")
_HOST_CAPTURE_LIMIT = 16 * 1024 * 1024


Expand All @@ -59,6 +61,7 @@
repeats: int
output: Path
runner: process.Runner = process.run
helpers: tuple[Helper, ...] | None = None

def execute(self) -> dict[str, Any]:
adapters = self.validate()
Expand All @@ -68,17 +71,28 @@
raise InputError(f"output directory already exists: {self.output}") from exc
controls = check_controls(self.tasks, "host" if self.mode == "host" else "docker", runner=self.runner)
control_rows = {row["task"]: row for row in controls["tasks"]}
cells = itertools.product(self.tasks, self.agents, range(1, self.repeats + 1))
rows = [self.session(task, agent, rep, adapters.get(agent.name), index, control_rows[task.name])
for index, (task, agent, rep) in enumerate(cells, 1)]
return {"mode": self.mode, "repeats": self.repeats, "sessions": rows,
"usage": usage_summary(rows, self.repeats), "controls": controls}
arms = [None, *(self.helpers or ())]
cells = itertools.product(self.tasks, self.agents, range(1, self.repeats + 1), arms)
rows = [self.session(task, agent, rep, adapters.get(agent.name), index, control_rows[task.name], helper)
for index, (task, agent, rep, helper) in enumerate(cells, 1)]
result = {"mode": self.mode, "repeats": self.repeats, "sessions": rows,
"usage": usage_summary(rows, self.repeats), "controls": controls}
if self.helpers is not None:
result["helpers"] = helper_effects(rows, self.helpers, self.repeats)
return result

def validate(self) -> dict[str, Adapter]:
if len({task.name for task in self.tasks}) != len(self.tasks):
raise InputError("task names must be unique")
if self.mode == "docker" and any(agent.name != "claude-code" for agent in self.agents):
raise InputError("--mode docker supports only claude-code; use --mode harbor for other container agents")
if self.helpers and self.mode != "host":
raise InputError("--helper needs --mode host")
names = {helper.name for helper in self.helpers or ()}
if "base" in names or len(names) != len(self.helpers or ()):

Check warning on line 92 in dokimi/dokimi/agent_run/runner.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-clause `"base" in names or len(names) != len(self.helpers or ())` -> `("base" in names)`
raise InputError("helper names must be unique and cannot use the reserved name base")
for helper in self.helpers or ():

Check warning on line 94 in dokimi/dokimi/agent_run/runner.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-clause `self.helpers or ()` -> `(())`
helper.validate()

Check warning on line 95 in dokimi/dokimi/agent_run/runner.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: delete-statement `helper.validate()` -> `pass`
adapters = {a.name: adapter_for(a.name) for a in self.agents} if self.mode == "host" else {}
for task in self.tasks:
self._validate_task(task)
Expand All @@ -100,7 +114,7 @@
raise InputError(f"{task.name}: timeouts must be positive finite numbers")

def session(self, task: TaskSpec, agent: Agent, rep: int, adapter: Adapter | None, session_id: int,
control: dict[str, Any]) -> dict[str, Any]:
control: dict[str, Any], helper: Helper | None = None) -> dict[str, Any]:
result_dir = self.output / f"session-{session_id:05d}"
result_dir.mkdir()
start = time.monotonic()
Expand All @@ -111,17 +125,19 @@
row = inconclusive(_control_failure_reason(control))
elif task_control_digest(task.path) != control["task_digest"]:
row = inconclusive("task files changed after checker controls")
elif helper is not None and not helper.applies_to(agent.name):
row = inconclusive("helper has no configuration for this agent")
elif adapter is None:
row = self._container(task, agent, tmp, result_dir)
else:
row = self._host(task, agent, adapter, tmp, result_dir, control["task_digest"])
row = self._host(task, agent, adapter, tmp, result_dir, control["task_digest"], helper)
except Unavailable as exc:
row = inconclusive(str(exc))
except (OSError, RuntimeError):
row = inconclusive("runner could not prepare or launch the session")
evidence = {
"task": task.name, "group": task.metadata["usage_group"], "source": task.metadata.get("source"),
"agent": agent.name, "model": agent.model, "arm": "base", "repeat": rep,
"agent": agent.name, "model": agent.model, "arm": helper.name if helper is not None else "base", "repeat": rep,
"claimed": None, "points": None, "cost_usd": None, "tokens_in": None, "tokens_out": None,
"transcript": None, "wall_s": round(time.monotonic() - start, 3), **row,
"false_success": row.get("claimed") is True and row["verdict"] == "FAIL",
Expand All @@ -130,16 +146,19 @@
return evidence

def _host(self, task: TaskSpec, agent: Agent, adapter: Adapter, tmp: Path, output: Path,
task_digest: str) -> dict[str, Any]:
task_digest: str, helper: Helper | None = None) -> dict[str, Any]:
workspace, config, home = (tmp / name for name in ("workspace", "config", "home"))
config.mkdir()
home.mkdir()
cmd, route_env = adapter.launch(_prompt(task), agent.model, config, self.route)
sandbox = shutil.which(cmd[0]) if sys.platform == "linux" and isinstance(adapter, Codex) else None
seed = task.path / "workspace"
if seed.is_dir():
shutil.copytree(seed, workspace)
else:
workspace.mkdir()
if helper is not None:
helper.install(workspace, config, agent.name, cmd)
Comment on lines +160 to +161
venv = workspace / ".dokimi-venv"
plain_env = session_env(home, venv)
self._create_venv(workspace, venv, plain_env)
Expand All @@ -162,10 +181,22 @@
trace_path.write_text(redact(proc.stdout, secrets), encoding="utf-8")
reason = _unavailable(proc, trace)
verdict = (inconclusive(reason) if reason else self._host_check(task, workspace, trace_path, task_digest))
if sandbox and verdict["verdict"] == "FAIL" and self._sandbox_failed(os.path.abspath(sandbox), trace, tmp, home):
verdict = inconclusive("Codex could not create a Linux workspace sandbox")
activity = model_activity(trace) or (trace_format == "text" and proc.ok and bool(trace.answer))
return {**verdict, "claimed": claim(trace.answer), **metered,
"transcript": trace_path.relative_to(self.output).as_posix(), "model_activity": activity}

def _sandbox_failed(self, executable: str, trace: Transcript, cwd: Path, home: Path) -> bool:
if not any(event.get("kind") in {"command", "edit"} and event.get("rc") not in (None, 0) for event in trace.events):
return False
try:
probe = self.runner([executable, "sandbox", "linux", "--", "/bin/true"], cwd=cwd, timeout=10,
env=process.Env.only(SYSTEM_ENV, {"HOME": str(home)}))
except OSError:
return False
return not probe.ok and bool(_NAMESPACE_ERROR.search(probe.stderr))

def _host_check(self, task: TaskSpec, workspace: Path, trace_path: Path, task_digest: str) -> dict[str, Any]:
try:
with tempfile.TemporaryDirectory(prefix="dokimi-checker-", ignore_cleanup_errors=True) as scratch:
Expand Down
Loading
Loading