Skip to content

Commit d109dbd

Browse files
committed
docs: use better session id generation in agent example
1 parent d65d868 commit d109dbd

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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)