Files
plugins/packages/agy-cli/agy-cli.test.mjs
T
yetone f10738917f agy-cli 0.1.83: a pending call Codex dropped is answered as cancelled, and the live session goes on (#1231)
Codex delivers a sub-agent message at a sampling boundary by keeping the
interrupted reply's text, dropping its tool call, and sending the history
on with the new message. Since 0.1.74 lineageVerdict called that a fork:
the pending call was closed with SUPERSEDED_NOTE and the conversation was
replayed in a new session, losing agy's cached prefix and, for a long
history, the turns past the 112 KiB prompt budget.

Now lineageVerdict returns "dropped" when the recorded history with the
turn's unanswered calls taken out is exactly the client's history, and
the reply that carried them kept some text. keepDroppedTurn answers those
calls with "cancelled by the client, not executed" through the existing
steerInSession (MCP commit wait, session/cancel, history set to the
client's), and the new trailing message goes in as the next prompt in
the same session. A changed reply text, a reply that was only the call,
grown tools, another work dir or other instructions still replay as
before; so does a steer that fails.

Run (mote, HOME=$(mktemp -d)):
- node --test test/dropped-call.mjs: 3 pass (kept session; changed text
  replays; call-only reply replays).
- bun test (agy-cli): 38 pass, 0 fail.
- bun scripts/check.mjs agy-cli: ok.

Broken by hand: origin/main's index.mjs with the new test: the kept-
session case fails (a second agy session is started); the two replay
cases pass on both.

Not tried: a real Codex session with a sub-agent message arriving
mid-sampling against a real agy; the fake reproduces the request shape
the issue describes. Part 1 (history seed through systemPrompt.append,
opt-in) is not in this change.
2026-11-17 01:49:29 +08:00

68 lines
2.4 KiB
JavaScript

// Runs the suites in test/ (brought over from gitxm/yce-magpie-agy, MIT), each
// in a bun process of its own: they mock node:child_process, move the clock and
// set the bridge's environment, and smoke.mjs ends with process.exit.
import { expect, test } from "bun:test"
import path from "node:path"
const dir = path.join(import.meta.dir, "test")
const hook = path.join(dir, "cp-hook.mjs")
function run(args, timeout) {
const result = Bun.spawnSync({ cmd: [process.execPath, ...args], cwd: dir, env: { ...process.env, AGY_BRIDGE_STORED_SIGNIN: "skip" }, stdout: "pipe", stderr: "pipe", timeout })
const output = result.stdout.toString() + result.stderr.toString()
if (result.exitCode !== 0) console.error(output)
return { code: result.exitCode, output }
}
for (const [name, mocks] of [
["platform.mjs", true],
["compat.mjs", true],
["prefill.mjs", false],
["usage.mjs", true],
["signin.mjs", false],
["catalog.mjs", false],
["step-usage.mjs", false],
["tool-schema.mjs", false],
["tool-summary.mjs", false],
["usage-settlement.mjs", false],
["steer-in-session.mjs", false],
["dropped-call.mjs", false],
["repeat-batch.mjs", false],
["conversation-key.mjs", false],
["windows-nc.mjs", false],
["spare.mjs", false],
]) {
test(`test/${name}`, () => {
// bun's 5s default per test is a fixed wait these process-spawning tests
// overrun on a loaded machine; the 240s run bounds a real hang.
const { code, output } = run(["test", "--timeout", "120000", ...(mocks ? ["--preload", hook] : []), `./${name}`], 240_000)
expect(output).toMatch(/\b[1-9]\d* pass\b/)
expect(code).toBe(0)
}, 250_000)
}
test("test/re2-pattern-unit.mjs", () => {
const { code, output } = run([path.join(dir, "re2-pattern-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)
test("test/smoke.mjs against a fake agy", () => {
const { code, output } = run([path.join(dir, "smoke.mjs")], 240_000)
expect(output).toMatch(/ALL OK \(\d+ checks\)/)
expect(code).toBe(0)
}, 250_000)
test("test/array-items-unit.mjs", () => {
const { code, output } = run([path.join(dir, "array-items-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)
test("test/documents-unit.mjs", () => {
const { code, output } = run([path.join(dir, "documents-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)