GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(evals): shell grading keeps unknown list status, joins continuat… · pingdotgg/t3code@d64222b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • evals/mcp-tool-use
    • device-grading.ts
    • run.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎evals/mcp-tool-use/device-grading.ts‎

Copy file name to clipboardExpand all lines: evals/mcp-tool-use/device-grading.ts
+28-5Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ const managedUi =
150150
/^(?:snapshot|screenshot|record|open|close|tap|click|type|fill|press|swipe|scroll|settings|back|home)$/;
151151
const interpreter = /^(?:python\d*(?:\.\d+)?|node|ruby|perl|osascript)$/;
152152
const shells = new Set(["bash", "sh", "zsh"]);
153+
/** How agent-device reports a failed command, e.g. `Error (COMMAND_FAILED): …`. */
154+
const AGENT_DEVICE_ERROR = /\bError \([A-Z_]+\):/;
153155

154156
export type ShellInvocation = {
155157
readonly words: ReadonlyArray<string>;
@@ -160,14 +162,18 @@ export type ShellInvocation = {
160162
readonly executed: boolean;
161163
/** An aggregate success cannot establish success of an action masked by ||. */
162164
readonly unmasked: boolean;
165+
/** A later `;` or `&` command owns the call's exit status. */
166+
readonly sequenced: boolean;
163167
};
164168

165169
// A deliberately bounded shell grammar, not a shell executor. Keep quotes until expansion so
166170
// literal command examples, comments and quoted heredocs never become invocations.
167171
const tokens = (source: string) =>
168-
source.match(
169-
/`(?:\\.|[^`])*`|[<>]\((?:[^()]|\([^()]*\))*\)|\$\((?:[^()'"\\]|\\.|'[^']*'|"(?:\\.|[^"\\])*"|\([^()]*\))*\)|(?:"(?:\\.|[^"\\])*"|'[^']*'|\\.|\$\{\w+\}|[^\s;&|(){}<>"'\\])+|&&|\|\||[;\n&|(){}]|\d*(?:>>?|<)(?:&\d+)?/g,
170-
) ?? [];
172+
source
173+
.replace(/'[^']*'|\\\n/g, (part) => (part.startsWith("'") ? part : ""))
174+
.match(
175+
/`(?:\\.|[^`])*`|[<>]\((?:[^()]|\([^()]*\))*\)|\$\((?:[^()'"\\]|\\.|'[^']*'|"(?:\\.|[^"\\])*"|\([^()]*\))*\)|(?:"(?:\\.|[^"\\])*"|'[^']*'|\\.|\$\{\w+\}|[^\s;&|(){}<>"'\\])+|&&|\|\||[;\n&|(){}]|\d*(?:>>?|<)(?:&\d+)?/g,
176+
) ?? [];
171177
const unquote = (word: string, variables: Map<string, string>) =>
172178
word.replace(
173179
/'([^']*)'|"((?:\\.|[^"\\])*)"|\\(.)|([^'"\\]+)/g,
@@ -346,12 +352,14 @@ export function shellInvocations(
346352
let certain = true;
347353
let currentCertain = true;
348354
let currentUnmasked = true;
355+
let currentSequenced = false;
349356
const append = (nested: ShellInvocation[]) =>
350357
actions.push(
351358
...nested.map((action) => ({
352359
...action,
353360
executed: action.executed && currentCertain,
354361
unmasked: action.unmasked && currentUnmasked,
362+
sequenced: action.sequenced || currentSequenced,
355363
})),
356364
);
357365
const truth = (words: string[]): boolean | undefined => {
@@ -456,14 +464,26 @@ export function shellInvocations(
456464
if (!active || !words.length || reachable === false) return;
457465
const list = listTokens();
458466
currentUnmasked = !list.includes("||") && words[0] !== "!";
467+
// The call's exit status is the last command's; an action followed by `;` or `&` doesn't own it.
468+
currentSequenced = commandTokens.slice(tokenIndex).some((t) => /^[;\n&]$/.test(t));
459469
const finalAndSuccess =
460470
succeeded &&
461471
gate === "&&" &&
462472
currentUnmasked &&
463473
!commandTokens.some((t) => /^(?:if|for|while|until|then|else|fi|do|done)$/.test(t)) &&
464474
!commandTokens.slice(tokenIndex).some((t) => /^[;\n&]$/.test(t));
465475
currentCertain = certain && (reachable === true || finalAndSuccess);
466-
status = truth(words);
476+
// A list's status is known only when this command certainly ran, or when its own result
477+
// decides the list either way (`x && false`, `x || true`).
478+
const value = truth(words);
479+
status =
480+
reachable === true
481+
? value
482+
: gate === "&&" && value === false
483+
? false
484+
: gate === "||" && value === true
485+
? true
486+
: undefined;
467487
for (const word of [...rawWords, ...redirects]) if (!bodies.has(word)) substitutions(word);
468488
if (loopList) return;
469489
const body = words.map((word) => bodies.get(word)).find((value) => value !== undefined);
@@ -567,6 +587,7 @@ export function shellInvocations(
567587
remote,
568588
executed: currentCertain,
569589
unmasked: currentUnmasked,
590+
sequenced: currentSequenced,
570591
raw:
571592
uiCommand.test([cli, ...normalized.slice(1)].join(" ")) ||
572593
(agent && (remote || cli === "mac_agent_device")),
@@ -735,12 +756,14 @@ export function gradeDevice(expect: typeof DeviceExpect.Type | undefined, run: D
735756
if (expect.recording !== undefined) {
736757
const steps = shell
737758
.filter(({ call }) => call.failed === false)
738-
.flatMap(({ actions }) =>
759+
.flatMap(({ call, actions }) =>
739760
actions
740761
.filter(
741762
(action) =>
742763
action.executed &&
743764
action.unmasked &&
765+
// Before a later `;` command, only an error-free output shows the action succeeded.
766+
(!action.sequenced || !AGENT_DEVICE_ERROR.test(call.output ?? "")) &&
744767
!action.remote &&
745768
(run.launchers ?? []).includes(action.words[0] ?? ""),
746769
)
Collapse file

‎evals/mcp-tool-use/run.test.ts‎

Copy file name to clipboardExpand all lines: evals/mcp-tool-use/run.test.ts
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,10 @@ it.each([
547547
"! xcrun simctl io PRIVATE screenshot /tmp/proof.png",
548548
"if false; then :; elif true; then xcrun simctl openurl PRIVATE acme://settings; fi",
549549
"for f in $(xcrun simctl io PRIVATE screenshot /tmp/p.png); do echo $f; done",
550+
// Review feedback on #25850: an uncertain short-circuit, and line continuations.
551+
"test -f /tmp/flag && true || xcrun simctl io PRIVATE screenshot /tmp/a.png",
552+
"ssh build-mac xcrun simctl io PRIVATE \\\n screenshot /tmp/a.png",
553+
'ssh build-mac "xcrun simctl io PRIVATE \\\n screenshot /tmp/a.png"',
550554
])("rejects simulator UI shell mutations: %s", (command) => {
551555
const calls = [{ step: 0, tool: "Bash", input: { command } }];
552556
assert.isTrue(gradeDevice({ noRawUi: true }, { calls }).some((c) => !c.pass));
@@ -1255,6 +1259,44 @@ it.each([
12551259
);
12561260
});
12571261

1262+
it.each([
1263+
[
1264+
"a later `;` command hides an agent-device error",
1265+
"record start /tmp/demo/voice.mp4; echo done",
1266+
"Error (COMMAND_FAILED): Remote daemon is unavailable\ndone",
1267+
false,
1268+
],
1269+
[
1270+
"a later `;` command with clean output",
1271+
"record start /tmp/demo/voice.mp4; echo done",
1272+
"Recording started\ndone",
1273+
true,
1274+
],
1275+
[
1276+
"`&&` makes the start part of the call's success",
1277+
"record start /tmp/demo/voice.mp4 && echo done",
1278+
"Error (COMMAND_FAILED): x",
1279+
true,
1280+
],
1281+
] as const)(
1282+
"credits a recording start only when the call's status covers it: %s",
1283+
(_, start, output, pass) => {
1284+
const launcher = "/home/user/.t3/userdata/device/bin/agent-device";
1285+
const calls = [
1286+
{ step: 0, tool: "Bash", failed: false, output, input: { command: `${launcher} ${start}` } },
1287+
{ step: 1, tool: "Bash", failed: false, input: { command: `${launcher} record stop` } },
1288+
];
1289+
const run = {
1290+
calls,
1291+
launchers: [launcher],
1292+
text: "Saved /tmp/demo/voice.mp4",
1293+
stopReason: "end_turn",
1294+
};
1295+
const checks = gradeSample({ device: { recording: "/tmp/demo/voice.mp4" } }, run);
1296+
assert.equal(checks.find((check) => check.check.startsWith("device recording"))?.pass, pass);
1297+
},
1298+
);
1299+
12581300
it("leaves errored samples out of pass rates and lists them in the summary", () => {
12591301
const usage = { input: 10, output: 0, cacheWrite: 0, cacheRead: 0 };
12601302
const row = (id: string, pass: boolean, error?: string) => ({

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.