Skip to content

Commit ac1dd47

Browse files
committed
fix(scenarios): the scenario runner's build and ask turns go without the host's memory variables too
ClaudeCodeDriver.turnEnv drops CLAUDE_MEMORY_ENV beside the billing and effort variables, so a scenario round run in a project container does not read the project's memory either. Claude-Session: https://claude.ai/code/session_01L6bhgXWFXqMUE85PmLT9AE Co-authored-by: Claude <noreply@anthropic.com>
1 parent 637a5bd commit ac1dd47

4 files changed

Lines changed: 27 additions & 9 deletions

File tree

‎.changeset/37842-skill-evals-memory-isolated.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
Clause-②: no
66
Metadata-protocol: none
77

8-
A skill-eval round run inside a project container no longer reads that project's memory. Each turn used to inherit the container's memory variables (`CLAUDE_COWORK_MEMORY_PATH_OVERRIDE`, `CLAUDE_MEMORY_STORES`), so the turns of both arms could answer from the project's own notes and the without-skill arm scored as if it had the skill. Every turn is now spawned without them, listed as `CLAUDE_MEMORY_ENV` next to the API-billing and effort variables, and the README says a round is isolated from project memory.
8+
A skill-eval round run inside a project container no longer reads that project's memory. Each turn used to inherit the container's memory variables (`CLAUDE_COWORK_MEMORY_PATH_OVERRIDE`, `CLAUDE_MEMORY_STORES`), so the turns of both arms could answer from the project's own notes and the without-skill arm scored as if it had the skill. Every turn is now spawned without them, listed as `CLAUDE_MEMORY_ENV` next to the API-billing and effort variables. The scenario runner's own build and ask turns (`npx @objectstack/scenarios run`) are spawned without them too, and the README says both kinds of turn are isolated from project memory.

‎packages/qa/scenarios/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,8 @@ pnpm --filter @objectstack/scenarios skill-evals --self-test # the runner's o
10221022
The container sets `CLAUDE_COWORK_MEMORY_PATH_OVERRIDE` and `CLAUDE_MEMORY_STORES` so its own sessions read the
10231023
project's memory store, and a turn that inherited them would answer from those notes in both arms, so the no-skill
10241024
arm could score as if it had the skill. Every turn is spawned without them, beside the billing variables and
1025-
`CLAUDE_CODE_EFFORT_LEVEL` (`CLAUDE_MEMORY_ENV` in `src/runner/driver.ts`).
1025+
`CLAUDE_CODE_EFFORT_LEVEL` (`CLAUDE_MEMORY_ENV` in `src/runner/driver.ts`). The scenario runner's build and ask
1026+
turns are spawned without them too, so both kinds of turn are isolated.
10261027
- **The arms**: each turn is one `claude -p` in a fresh temporary directory. The prompt goes on stdin. The two arms
10271028
differ only in the bundle. The with-skill arm copies it into `.claude/skills/BUNDLE/` without its `evals/`, so the
10281029
turn cannot read the assertions it is graded on. The no-skill arm's directory is empty. Both arms take the same

‎packages/qa/scenarios/src/runner/driver.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ export const CLAUDE_EFFORT_ENV = 'CLAUDE_CODE_EFFORT_LEVEL';
233233
* container sets them so its own sessions read and write the project's memory
234234
* store, and a child spawned with them reads that store too. A skill-eval turn
235235
* that inherits them answers from the host's notes in both arms, so the
236-
* no-skill arm can score as if it had the skill. Every skill-eval turn is
237-
* spawned without them (`turnEnv` in `src/skill-evals/run.ts`).
236+
* no-skill arm can score as if it had the skill, and a scenario turn builds
237+
* or answers from them. Every turn either runner spawns goes without them
238+
* (`ClaudeCodeDriver.turnEnv` here, `turnEnv` in `src/skill-evals/run.ts`).
238239
*/
239240
export const CLAUDE_MEMORY_ENV = ['CLAUDE_COWORK_MEMORY_PATH_OVERRIDE', 'CLAUDE_MEMORY_STORES'] as const;
240241

@@ -461,10 +462,14 @@ export class ClaudeCodeDriver implements AgentDriver {
461462
return raw === undefined || raw === '' || raw === 'unset' || raw === 'auto' ? undefined : raw;
462463
}
463464

464-
/** A turn's environment: no API-billing variable, and no {@link CLAUDE_EFFORT_ENV} to override the `--effort` the turn passes. */
465+
/**
466+
* A turn's environment: no API-billing variable, no {@link CLAUDE_EFFORT_ENV} to override the `--effort` the turn
467+
* passes, and no {@link CLAUDE_MEMORY_ENV} variable pointing the turn at the host's memory store.
468+
*/
465469
private turnEnv(): NodeJS.ProcessEnv {
466470
const env = subscriptionOnlyEnv();
467471
delete env[CLAUDE_EFFORT_ENV];
472+
for (const k of CLAUDE_MEMORY_ENV) delete env[k];
468473
return env;
469474
}
470475

‎packages/qa/scenarios/test/runner/units.test.ts‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { makeDriver, parseArgs } from '../../src/runner/cli.js';
2525
import {
2626
ApiBillingRefusedError,
2727
assertSubscriptionLogin,
28+
CLAUDE_MEMORY_ENV,
2829
ClaudeCodeDriver,
2930
DEFAULT_ASK_MAX_TURNS,
3031
DEFAULT_AUTHOR_MAX_TURNS,
@@ -1172,8 +1173,8 @@ describe("the seed's load plan — reference cycles found from the card's own lo
11721173
* `claude-opus-5-5`; with no `--model` it serves `stand-in`. `--help` prints
11731174
* the `--effort` entry as Claude Code 2.1.325 does (its level list wrapped onto
11741175
* the next line), or no such entry under `STAND_IN_NO_EFFORT`; an `ENV` turn
1175-
* answers its argument list and the `CLAUDE_CODE_EFFORT_LEVEL` it was started
1176-
* with.
1176+
* answers its argument list, the `CLAUDE_CODE_EFFORT_LEVEL` it was started
1177+
* with and which of the host's memory variables it was started with.
11771178
*/
11781179
const STAND_IN = `#!/usr/bin/env node
11791180
process.on('SIGTERM', () => { process.stderr.write('stand-in: terminated\\n'); process.exit(143); });
@@ -1197,7 +1198,7 @@ process.stdin.on('end', () => {
11971198
const text = input.startsWith('ARGV')
11981199
? JSON.stringify(args)
11991200
: input.startsWith('ENV')
1200-
? JSON.stringify({ argv: args, effortEnv: process.env.CLAUDE_CODE_EFFORT_LEVEL ?? null })
1201+
? JSON.stringify({ argv: args, effortEnv: process.env.CLAUDE_CODE_EFFORT_LEVEL ?? null, memoryEnv: ['CLAUDE_COWORK_MEMORY_PATH_OVERRIDE', 'CLAUDE_MEMORY_STORES'].filter((k) => process.env[k] !== undefined) })
12011202
: 'stdin ' + input.length + ' · longest argv ' + longest;
12021203
const asked = args.indexOf('--model') === -1 ? undefined : args[args.indexOf('--model') + 1];
12031204
const served = asked === undefined ? 'stand-in' : asked === 'retired' ? 'claude-opus-5-5' : 'claude-' + asked + '-4-5-20250929';
@@ -1394,7 +1395,7 @@ describe('the live driver against a stand-in `claude`: the prompt on stdin, and
13941395
return at === -1 ? undefined : argv[at + 1];
13951396
};
13961397
/** An `ENV` turn's answer: the stand-in's argument list and the effort variable it was started with. */
1397-
const envOf = (t: ParsedTurn) => JSON.parse(t.replyText) as { argv: string[]; effortEnv: string | null };
1398+
const envOf = (t: ParsedTurn) => JSON.parse(t.replyText) as { argv: string[]; effortEnv: string | null; memoryEnv: string[] };
13981399
/** The refusal's message, or `undefined` when nothing was refused. */
13991400
const refusalOf = (run: () => unknown): string | undefined => {
14001401
try {
@@ -1453,6 +1454,17 @@ describe('the live driver against a stand-in `claude`: the prompt on stdin, and
14531454
}
14541455
});
14551456

1457+
it('the host’s memory variables never reach a turn: a build turn and an ask turn are both started without them', async () => {
1458+
vi.stubEnv('PATH', `${dir}${delimiter}${process.env.PATH ?? ''}`);
1459+
vi.stubEnv('CLAUDE_COWORK_MEMORY_PATH_OVERRIDE', '/host/project/memory');
1460+
vi.stubEnv('CLAUDE_MEMORY_STORES', 'host-store');
1461+
expect([...CLAUDE_MEMORY_ENV].sort()).toEqual(['CLAUDE_COWORK_MEMORY_PATH_OVERRIDE', 'CLAUDE_MEMORY_STORES']);
1462+
const d = makeDriver('claude', parseArgs([]));
1463+
const built = (await d.author(task('ENV'))).turn;
1464+
const asked = await d.ask(ask('ENV'));
1465+
expect([envOf(built).memoryEnv, envOf(asked).memoryEnv]).toEqual([[], []]);
1466+
});
1467+
14561468
it('an effort level the CLI’s own `--help` does not list is refused before any turn — the CLI would warn, run at its default and exit 0 — and so is any effort on a CLI with no `--effort`', () => {
14571469
vi.stubEnv('PATH', `${dir}${delimiter}${process.env.PATH ?? ''}`);
14581470
expect(refusalOf(() => makeDriver('claude', parseArgs(['--effort', 'turbo'])))).toMatch(/^--effort takes one of the levels `claude` 2\.1\.0 \(stand-in\) accepts \(low, medium, high, xhigh, max\), not `turbo`$/);

0 commit comments

Comments
 (0)