Skip to content

Commit 66c5b74

Browse files
authored
docs: use better session id generation in agent example (#24)
1 parent bca5291 commit 66c5b74

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/examples/agent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class ExampleAgent implements acp.Agent {
3030
async newSession(
3131
_params: acp.NewSessionRequest,
3232
): Promise<acp.NewSessionResponse> {
33-
const sessionId = Math.random().toString(36).substring(2);
33+
const sessionId = Array.from(crypto.getRandomValues(new Uint8Array(16)))
34+
.map((b) => b.toString(16).padStart(2, "0"))
35+
.join("");
3436

3537
this.sessions.set(sessionId, {
3638
pendingPrompt: null,

0 commit comments

Comments
 (0)