A full agent id never resolves to a different agent titled with it (#9731)
* fix(server): resolve a full agent id only to the agent with that id The daemon's agent lookup tries the exact id, then a unique id prefix, then an exact title. A full id that matched no agent fell through to the title step, so `paseo agent delete <id>` hard-deleted a different agent whose title was that id, and inspect, stop, update, mode, logs and open acted on it the same way. Stop at the exact-id step when the identifier is a complete agent id. Closes #9727 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): tag the full-agent-id guard as compatibility for older daemons Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): say which commands the full-agent-id compatibility guard covers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8ff657cd4a
commit
286d528b71
3 files changed
+70
-4
No files matched your search
@@ -62,8 +62,9 @@ export async function resolveAgentEntry(
|
||||
}
|
||||
}
|
||||
|
||||
// A complete agent UUID is an exact identity: the daemon falls back to a
|
||||
// title match, which must not answer for an ID that does not exist.
|
||||
// COMPAT(fullAgentIdExact): daemons before v0.16.0 resolve a full agent ID
|
||||
// that matches no agent to an agent titled with it, so archive, detach and
|
||||
// reload accept their answer only when it is that ID. Remove after 2027-05-15.
|
||||
if (FULL_AGENT_UUID_PATTERN.test(trimmed)) {
|
||||
const agentId = trimmed.toLowerCase();
|
||||
const fetchResult = await client.fetchAgent({ agentId });
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
import assert from "node:assert";
|
||||
import { runLocalPaseo } from "./helpers/local-cli.ts";
|
||||
import { getAvailablePort } from "./helpers/network.ts";
|
||||
import { runPaseoCli, startTestDaemon } from "./helpers/test-daemon.ts";
|
||||
import { mkdtemp, rm } from "fs/promises";
|
||||
import { createTempDirs, runPaseoCli, startTestDaemon } from "./helpers/test-daemon.ts";
|
||||
import { mkdtemp, rm, writeFile } from "fs/promises";
|
||||
import { tmpdir } from "os";
|
||||
import { join } from "path";
|
||||
|
||||
@@ -135,6 +135,64 @@ try {
|
||||
}
|
||||
console.log("✓ delete reports AGENT_NOT_FOUND for an unknown ID\n");
|
||||
}
|
||||
|
||||
{
|
||||
console.log("Test 10: a missing full ID does not delete an agent titled with it");
|
||||
const missingId = "11111111-2222-4333-8444-555555555555";
|
||||
const titledId = "c9a97e5d-4a92-4646-a016-53032146d0a1";
|
||||
const dirs = await createTempDirs();
|
||||
await writeFile(
|
||||
join(dirs.paseoHome, "agents", `${titledId}.json`),
|
||||
JSON.stringify(
|
||||
{
|
||||
id: titledId,
|
||||
provider: "codex",
|
||||
cwd: dirs.workDir,
|
||||
createdAt: "2026-09-03T18:29:21.949Z",
|
||||
updatedAt: "2026-09-03T18:29:21.949Z",
|
||||
title: missingId,
|
||||
labels: {},
|
||||
lastStatus: "closed",
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
const daemon = await startTestDaemon(dirs);
|
||||
const host = `127.0.0.1:${daemon.port}`;
|
||||
try {
|
||||
for (const command of ["inspect", "delete"]) {
|
||||
const result = await runPaseoCli(daemon, [
|
||||
"agent",
|
||||
command,
|
||||
missingId,
|
||||
"--json",
|
||||
"--host",
|
||||
host,
|
||||
]);
|
||||
assert.strictEqual(result.exitCode, 1, `${command}: ${result.stdout}`);
|
||||
assert.strictEqual(
|
||||
JSON.parse(result.stderr).error.code,
|
||||
"AGENT_NOT_FOUND",
|
||||
`${command}: ${result.stderr}`,
|
||||
);
|
||||
}
|
||||
|
||||
const titled = await runPaseoCli(daemon, [
|
||||
"agent",
|
||||
"inspect",
|
||||
titledId,
|
||||
"--json",
|
||||
"--host",
|
||||
host,
|
||||
]);
|
||||
assert.strictEqual(titled.exitCode, 0, titled.stderr);
|
||||
assert.strictEqual(JSON.parse(titled.stdout).Id, titledId);
|
||||
} finally {
|
||||
await daemon.stop();
|
||||
}
|
||||
console.log("✓ a missing full ID does not delete an agent titled with it\n");
|
||||
}
|
||||
} finally {
|
||||
await rm(paseoHome, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
@@ -319,6 +319,7 @@ type ProviderSubagentManagerEvent = Extract<
|
||||
// Clients before 0.1.45 validate providers with z.enum(["claude", "codex", "opencode"]) and reject
|
||||
// the entire session message if they encounter an unknown provider.
|
||||
const LEGACY_PROVIDER_IDS = new Set(["claude", "codex", "opencode"]);
|
||||
const FULL_AGENT_ID_PATTERN = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
|
||||
const MIN_VERSION_ALL_PROVIDERS = "0.1.45";
|
||||
const MIN_VERSION_EXPLICIT_WORKSPACE_RECOVERY = "0.1.105";
|
||||
function errorToFriendlyMessage(error: unknown): string {
|
||||
@@ -5767,6 +5768,12 @@ export class Session {
|
||||
return { ok: true, agentId: trimmed };
|
||||
}
|
||||
|
||||
// A complete agent ID names one agent. When none has it, no prefix or
|
||||
// title answers for it, so a command never acts on a different agent.
|
||||
if (FULL_AGENT_ID_PATTERN.test(trimmed)) {
|
||||
return { ok: false, notFound: true, error: `Agent not found: ${trimmed}` };
|
||||
}
|
||||
|
||||
const prefixMatches = Array.from(knownIds).filter((id) => id.startsWith(trimmed));
|
||||
if (prefixMatches.length === 1) {
|
||||
return { ok: true, agentId: prefixMatches[0] };
|
||||
|
||||
Reference in new issue
Block a user