Skip to content

Commit

Permalink
feat(agent): Add unique graph ID generation for agent copies
Browse files Browse the repository at this point in the history
Modify copyAgentAction to generate new graph IDs when copying agents to ensure
each copy has a distinct graph identity. This prevents potential conflicts and
maintains data isolation between copied agents.

Changes:
- Import createGraphId utility
- Generate new graph ID during copy operation
- Pass new ID when creating graph copy
  • Loading branch information
toyamarinyon committed Dec 16, 2024
1 parent c9dab35 commit 989ca92
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/dev/copy-agent/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { putGraph } from "../../(playground)/p/[agentId]/canary/actions";
import {
buildFileFolderPath,
createFileId,
createGraphId,
pathJoin,
pathnameToFilename,
} from "../../(playground)/p/[agentId]/canary/lib/utils";
Expand Down Expand Up @@ -101,7 +102,8 @@ export async function copyAgentAction(
} as Node;
}),
);
const { url } = await putGraph({ ...graph, nodes: newNodes });
const newGraphId = createGraphId();
const { url } = await putGraph({ ...graph, id: newGraphId, nodes: newNodes });
const newAgentId = `agnt_${createId()}` as AgentId;
const newAgent = await db.insert(agents).values({
id: newAgentId,
Expand Down

0 comments on commit 989ca92

Please sign in to comment.