Skip to content
Merged
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
51 changes: 48 additions & 3 deletions .github/workflows/eval-refresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,31 @@ jobs:
exit 1
fi

# The same treatment for a sandbox that fails its own self-check
# (`packages/sandbox/src/toolchain-check.ts`). It runs before the
# agent is installed and errors the cell when the pinned Hookdeck CLI
# is not what the agent's shells resolve. Every job builds the same
# image from the same Dockerfile, so one failure means all of them
# will fail, and the run should stop rather than error every remaining
# cell one at a time. The string is the error's own prefix, and a test in
# `packages/sandbox` fails if the two drift apart.
#
# Only a deterministic answer carries it: `command -v hookdeck`
# resolving nothing, or the wrong version. A probe that times out or
# hits a dead container is retried once and then throws
# "sandbox self-check could not complete", which errors that cell
# alone and does not match here.
sandbox_broken="sandbox self-check failed"
if [ "$eval_status" -ne 0 ] && grep -qF "$sandbox_broken" "$run_log"; then
echo "::error::The sandbox image failed its self-check (pinned Hookdeck CLI missing from PATH or wrong version). Cancelling the run: every remaining job builds the same image."
{
echo "experiment=${{ matrix.experiment }}"
echo "eval=${{ matrix.eval_id }}"
echo "matched=${sandbox_broken}"
} > sandbox-broken.marker
exit 1
fi

if [ "$eval_status" -ne 0 ]; then
exit "$eval_status"
fi
Expand Down Expand Up @@ -490,13 +515,25 @@ jobs:
# later still sees it.
retention-days: 90

# The same fallback for a sandbox that failed its self-check: if the
# cancel below does not take, `publish-results` still refuses the run.
- name: Record broken sandbox
if: ${{ failure() && hashFiles('sandbox-broken.marker') != '' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sandbox-broken-${{ matrix.experiment }}__${{ matrix.eval_id }}
path: sandbox-broken.marker
if-no-files-found: error
retention-days: 90

- name: Cancel the run
# Fails closed. This used to be `gh run cancel … || true` inside the
# step above, so a cancel that did not take let every remaining job run
# and pay. Retried, and if it still fails the error says so: the
# marker above still stops `publish-results`, but the remaining cells
# will run until somebody cancels by hand.
if: ${{ failure() && hashFiles('provider-refused.marker') != '' }}
# will run until somebody cancels by hand. Either marker cancels: a
# provider refusal and a broken sandbox both fail every remaining job.
if: ${{ failure() && hashFiles('provider-refused.marker', 'sandbox-broken.marker') != '' }}
shell: bash
run: |
for attempt in 1 2 3; do
Expand All @@ -507,7 +544,7 @@ jobs:
echo "gh run cancel failed (attempt ${attempt}), retrying"
sleep $((attempt * 10))
done
echo "::error::Could not cancel run ${{ github.run_id }} after three attempts. The provider-refusal marker stops publish-results, but the remaining cells will keep running and billing: cancel the run by hand."
echo "::error::Could not cancel run ${{ github.run_id }} after three attempts. The marker uploaded above stops publish-results, but the remaining cells will keep running and billing: cancel the run by hand."
exit 1

- name: Upload raw results
Expand Down Expand Up @@ -723,6 +760,14 @@ jobs:
echo "::error::A provider refused requests during this run, so it is not published, whatever the floor says: $(paste -sd, - <<< "$refused")"
exit 1
fi
# Likewise a sandbox that failed its self-check. Every job builds the
# same image, so whatever came back is a run with a broken instrument,
# and a merge would fill its holes with carried-forward rows.
broken="$(grep -E '^sandbox-broken-' <<< "$available" || true)"
if [ -n "$broken" ]; then
echo "::error::The sandbox image failed its self-check during this run, so it is not published, whatever the floor says: $(paste -sd, - <<< "$broken")"
exit 1
fi
while IFS= read -r name; do
if grep -qxF "$name" <<< "$available"; then
gh run download ${{ github.run_id }} --name "$name" --dir "downloaded-results/$name"
Expand Down
25 changes: 23 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,10 @@ with a plausible partial score, and one was written as a `2/6` agent failure), a
run that failed while its own report claims success (nine of twelve baselines in
one run, every one of them confidently building on the wrong product), a
declared credential the agent never referenced, a skill offered and never
opened, a baseline that self-installed a product skill, and a cell whose only
green checks are the ones an idle agent satisfies.
opened, a baseline that self-installed a product skill, a cell whose only
green checks are the ones an idle agent satisfies, and a cell whose agent could
not find the pinned CLI or ran a different one (69 of the 76 Codex cells in run
42044644850).

Nothing flagged is not the same as nothing to learn. It means no cell tripped a
signal the script knows about, and the signals it knows about are the ones that
Expand Down Expand Up @@ -1320,6 +1322,25 @@ deleted through the API, so a shared project accumulates history, and a scorer
that just asks "did an event arrive?" will eventually say yes because of an
earlier run.

**Codex runs most commands in a login shell, and a login shell rebuilds PATH.**
In release run 42044644850, 2,233 of Codex's 2,456 shell commands were
`/bin/bash -lc '…'`; the rest were `bash -c`. A login shell runs Debian's
`/etc/profile`, which replaces whatever PATH the harness passed in with a fixed
list. Claude Code runs `bash -c` and inherits it. Of the Codex attempts in that
run that invoked the pinned `hookdeck`, 26/26, 18/22, 16/16 and 19/19 across
the four arms met `command not found`, and the four that did not had run it
only through `bash -c`. The agents carried on by absolute path, by `npx`, by an
unpinned `npx -y hookdeck-cli@latest`, or through the REST API — all of it
scored as though both agents had the same baseline. So anything an agent needs
on PATH has to be on it for both kinds of shell: the image sets it in `ENV` and
again in `/etc/profile.d/`, and `toolchain-check.ts` errors a cell before it
starts if either shell does not resolve the pinned version. A missing or wrong
CLI is treated in CI like a provider refusal: it leaves a `sandbox-broken`
marker that `publish-results` refuses on and cancels the run, because every
job builds the same image. A probe that times out or hits a dead container is
retried once and then errors only its own cell. Setting `PATH` on
`docker exec` alone is not enough.

**Credentials reach the agent through `EvalSession.sandboxEnv`.** The session is
created before the sandbox because the sandbox needs the lease. Disposal runs in
reverse, so the container is torn down before the project is released.
Expand Down
162 changes: 162 additions & 0 deletions apps/framework/lib/pinned-cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import { HOOKDECK_CLI_VERSION } from '@hookdeck-evals/sandbox';

/**
* Whether a cell's agent ran without the pinned Hookdeck CLI, and how it got
* round that.
*
* Every experiment is supposed to get the CLI baked into the sandbox image, so
* a row differs from its neighbour by skills and nothing else. On the Codex
* arms it was mostly not on PATH: Codex runs most commands in a login shell
* (`bash -lc`), and Debian's `/etc/profile` drops the npm prefix the CLI lives
* in. In release run 42044644850, of the Codex attempts that invoked
* `hookdeck`, 26/26, 18/22, 16/16 and 19/19 across the four arms met
* `command not found`; the four that did not had run it only through
* `bash -c`. The agents carried on through an absolute path into the package,
* `npx`, an unpinned `npx -y hookdeck-cli@latest`, or the REST API. The first
* two still ran the pinned 2.5.0; the third did not; none of them is the
* baseline the row claims, a CLI that is simply there.
*
* The image now fixes the PATH and the sandbox refuses to start a cell whose
* shells cannot run the pin, so this should not fire on a new run for the
* first reason. It stays for two: rows already on disk carry it, and the
* self-check cannot see a CLI the agent fetches for itself mid-run. Flagged
* whether the cell passed or failed, because a passing row whose agent had to
* find the CLI, or ran a different one, is still not comparable.
*
* Kept outside `scripts/triage.ts` because that file runs `main()` at module
* scope and so cannot be imported by a test.
*/
export interface PinnedCliEvidence {
/** The shell said `hookdeck` does not exist (bash's wording, or dash's). */
notFound: boolean;
/** `hookdeck-cli` package specs the agent ran or installed that are not the pin. */
unpinned: string[];
/** It ran the platform binary inside the package directly. */
absolutePath: boolean;
}

const NOT_FOUND = /hookdeck: (command )?not found/;

/**
* `npx hookdeck-cli@<v>`, `npm install -g hookdeck-cli@<v>`, and the bare
* `hookdeck-cli@<v>` inside either. A spec with no version is not counted: npx
* resolved it to the installed 2.5.0 in every case run 42044644850 reported a
* version.
*/
const PACKAGE_SPEC = /hookdeck-cli@([A-Za-z0-9][\w.-]*)/g;

const BINARY_PATH = /hookdeck-cli\/binaries\/[\w-]+\/hookdeck/;

/** What a cell ran in a shell, and what came back, across every attempt. */
export interface ShellActivity {
commands: string[];
outputs: string[];
}

interface TranscriptLike {
type?: string;
input?: { command?: unknown };
output?: unknown;
error?: unknown;
}

export interface RowLike {
transcript?: TranscriptLike[];
toolCalls?: unknown[];
priorAttempts?: Array<{ transcript?: TranscriptLike[] }>;
}

function asText(value: unknown): string {
if (value === undefined || value === null) return '';
return typeof value === 'string' ? value : JSON.stringify(value);
}

/**
* Shell commands only, by design. A docs page the agent fetched, or a README
* it wrote for the user, can say `npx hookdeck-cli@latest` without the agent
* having run it, and flagging that would make this cry wolf. Outputs are read
* only for the shell's own `not found`.
*/
export function shellActivity(row: RowLike): ShellActivity {
const commands: string[] = [];
const outputs: string[] = [];
const transcripts = [
row.transcript ?? [],
...(row.priorAttempts ?? []).map((attempt) => attempt.transcript ?? []),
];
for (const transcript of transcripts) {
for (const part of transcript) {
if (part?.type !== 'tool_call') continue;
const command = part.input?.command;
if (typeof command !== 'string') continue;
commands.push(command);
outputs.push(`${asText(part.output)}\n${asText(part.error)}`);
}
}
for (const raw of row.toolCalls ?? []) {
const call = raw as {
command?: unknown;
result?: unknown;
error?: unknown;
};
if (typeof call?.command !== 'string') continue;
commands.push(call.command);
outputs.push(`${asText(call.result)}\n${asText(call.error)}`);
}
return { commands, outputs };
}

export function pinnedCliEvidence(
activity: ShellActivity,
pinned: string = HOOKDECK_CLI_VERSION
): PinnedCliEvidence | undefined {
const notFound = activity.outputs.some((output) => NOT_FOUND.test(output));
const commands = activity.commands.join('\n');
const unpinned = [
...new Set(
[...commands.matchAll(PACKAGE_SPEC)]
.map((match) => match[1])
.filter((version) => version !== pinned && version !== `v${pinned}`)
.map((version) => `hookdeck-cli@${version}`)
),
].sort();
const absolutePath = BINARY_PATH.test(commands);
if (!notFound && unpinned.length === 0) return undefined;
return { notFound, unpinned, absolutePath };
}

/**
* The `triage` flags for this evidence: up to two, because they say different
* things. A CLI that was not on PATH leaves a row that may still have run the
* pinned version — reached by absolute path, or by an unversioned `npx` that
* resolved to the install — but whose agent had to go looking for a tool the
* other agent was handed. Only a `hookdeck-cli@<other>` that actually ran
* makes the row unpinned.
*/
export function pinnedCliFlags(
evidence: PinnedCliEvidence,
pinned: string = HOOKDECK_CLI_VERSION
): Array<{ label: string; detail: string }> {
const flags: Array<{ label: string; detail: string }> = [];
if (evidence.notFound) {
const workaround = evidence.absolutePath
? ', then called the binary inside the package by absolute path'
: '';
flags.push({
label: 'PINNED CLI NOT ON PATH',
detail:
`\`hookdeck: command not found\` in its shell${workaround}. The pinned ` +
'CLI was installed but not on PATH, so this agent had to find a tool ' +
'the baseline promises is simply there; do not compare the row across agents',
});
}
if (evidence.unpinned.length > 0) {
flags.push({
label: 'UNPINNED CLI',
detail:
`ran ${evidence.unpinned.join(', ')} instead of ${pinned}, so this ` +
'row was not measured with the pinned CLI',
});
}
return flags;
}
20 changes: 18 additions & 2 deletions apps/framework/lib/provenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { join } from 'node:path';
import {
HOOKDECK_CLI_VERSION,
SKILLS_CLI_VERSION,
sandboxImageDefinition,
} from '@hookdeck-evals/sandbox';

/**
Expand Down Expand Up @@ -36,7 +37,10 @@ import {
* instead of making it by default.
*/
export interface Provenance {
/** The harness every scenario shares: base prompt, CLI pin, skills pin. */
/**
* The harness every scenario shares: base prompt, CLI pin, skills pin,
* sandbox image definition.
*/
harness: string;
/** The scenario's own files. Changes when its prompt, seed or scorer does. */
scenario: string;
Expand Down Expand Up @@ -110,14 +114,26 @@ export function skillsPin(root: string): string {
* exactly what happened on 27 August and is why this module exists now rather
* than later. The skill *context* is deliberately excluded: that varies by arm
* and is the treatment being measured, not a change to the instrument.
*
* The sandbox image definition is in here because the image decides what an
* agent's shell can run. Until it was, a Dockerfile change meant to put the
* pinned CLI on PATH for Codex's login shells, where it had been
* `command not found`, would have left every row's harness hash where it was,
* so rows either side of it would read as measured under one instrument
* whether or not the change worked.
*/
export function harnessFingerprint(basePrompt: string, root: string): string {
export function harnessFingerprint(
basePrompt: string,
root: string,
imageDefinition: string = sandboxImageDefinition()
): string {
return short(
[
`base-prompt:${basePrompt}`,
`hookdeck-cli:${HOOKDECK_CLI_VERSION}`,
`skills-cli:${SKILLS_CLI_VERSION}`,
`skills-pin:${skillsPin(root)}`,
`sandbox-image:${imageDefinition}`,
].join('\n')
);
}
Expand Down
14 changes: 13 additions & 1 deletion apps/framework/scripts/triage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {
ERRORED_RUNS_DIRNAME,
readErroredEvidenceTree,
} from '../harness/errored-cell.js';
import {
pinnedCliEvidence,
pinnedCliFlags,
type RowLike,
shellActivity,
} from '../lib/pinned-cli.js';

/**
* Which cells of a run you have to read, and why.
Expand Down Expand Up @@ -48,7 +54,7 @@ interface Check {
passed?: boolean;
}

interface Row {
interface Row extends RowLike {
experiment: string;
eval: string;
passed?: boolean;
Expand Down Expand Up @@ -237,6 +243,12 @@ function flagsFor(row: Row, requiredEnv: string[]): Flag[] {
flags.push({ label: 'NO TOOL CALLS', detail: 'scored without acting' });
}

// Pass or fail: a row whose agent could not find the pinned CLI, or ran a
// different one, is not the baseline it claims to be either way. See
// `lib/pinned-cli.ts`.
const cli = pinnedCliEvidence(shellActivity(row));
if (cli) flags.push(...pinnedCliFlags(cli));

return flags;
}

Expand Down
Loading
Loading