Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/term-commands/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,12 @@ export async function resolveSpawnIdentity(
isAliveFn: (agent: { id: string; paneId: string }) => Promise<boolean> = (agent) =>
executorRegistry.resolveWorkerLivenessByTransport(agent),
): Promise<SpawnIdentity> {
// Migration 061 + PR #1627: agents.id is UUID. Non-UUID names cannot match
// by id; skip the canonical-lookup query and return a fresh canonical with
// a generated UUID workerId. Keeps role-based dispatch working post-061.
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(name)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Use the existing UUID_REGEX constant (defined at line 2258) instead of duplicating the regex literal. This improves maintainability and ensures consistency across the module.

Additionally, while this guard prevents crashes for role-based names (like "engineer"), the parallel spawn logic later in this function (line 2413) still constructs workerId as ${name}-${shortId}. If agents.id is a UUID type in Postgres, those parallel IDs will still cause invalid input syntax for type uuid errors. You should consider updating the parallel ID generation to ensure it always produces a valid UUID.

  if (!UUID_REGEX.test(name)) {

return { kind: 'canonical', workerId: uuidFactory(), sessionUuid: uuidFactory() };
Comment on lines +2340 to +2341

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve role-scoped identity for non-UUID spawn names

Returning early for any non-UUID name bypasses all existing canonical lookup/liveness logic and always mints a brand-new workerId, so repeated genie spawn <role> calls no longer correlate with the same role identity. In this code path, identity.workerId is later assigned to effectiveRole (handleWorkerSpawn), which means downstream registration/lookup uses a fresh UUID instead of the requested role name, breaking the intended canonical/parallel decision path and making role-based resume/dispatch behavior diverge for normal role names.

Useful? React with 👍 / 👎.

}
const { getConnection } = await import('../lib/db.js');
const sql = await getConnection();
// `agents.id` is the PRIMARY KEY (migrations/005_pg_state.sql), so the
Expand Down
Loading