Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(team): refuse to judge a team run that is still ACTIVE

Jack Rudenko780cb66cb6af
diff --git a/packages/cli/src/team-list-contract.test.ts b/packages/cli/src/team-list-contract.test.ts
index cd0c81da..2713ef13 100644
--- a/packages/cli/src/team-list-contract.test.ts
+++ b/packages/cli/src/team-list-contract.test.ts
@@ -18,6 +18,7 @@ import {
MAX_SETTLED_RUNS,
type TeamHandle,
cancelTeamRun,
+ judgeResponses,
listTeamRuns,
preflightTeamRun,
pruneTeamRunsForTests,
@@ -163,6 +164,10 @@ describe.skipIf(!MAGMUX)("team run registry (list / status / cancel / capture)",
await expect(preflightTeamRun({ path, slots: 1 })).rejects.toThrow(message);
await expect(startModels(path, paneRunOptions(t))).rejects.toThrow(message);
+ // judging it now would vote on whichever slots happen to have finished
+ await expect(judgeResponses(path)).rejects.toThrow(
+ `invalid_args: the team run at ${path} is still ACTIVE (run_id ${active.runId})`
+ );
}, 60_000);
it("refuses an invalid require_pattern in preflight, before any session dir or record", async () => {
diff --git a/packages/cli/src/team-orchestrator.ts b/packages/cli/src/team-orchestrator.ts
index 8e200ed2..385a6824 100644
--- a/packages/cli/src/team-orchestrator.ts
+++ b/packages/cli/src/team-orchestrator.ts
@@ -1686,6 +1686,13 @@ export async function judgeResponses(
sessionPath: string,
opts: TeamJudgeOptions = {}
): Promise<TeamVerdict> {
+ // Response files are written only at a slot's terminal transition: judging a run that
+ // is still ACTIVE would silently vote on the subset that happens to have finished.
+ const active = activeRunAt(resolve(sessionPath));
+ if (active)
+ throw new Error(
+ `invalid_args: the team run at ${resolve(sessionPath)} is still ACTIVE (run_id ${active.runId}); judge it once it has settled`
+ );
// Collect all response files in sorted order
const responseFiles = readdirSync(sessionPath)
.filter((f) => f.startsWith("response-") && f.endsWith(".md"))