Skip to content

Commit b3ff4b5

Browse files
committed
Pass sessionAffinity to workersai model
Include sessionAffinity when creating the workersai model in ChatAgent. The streamText call now invokes workersai with a second argument ({ sessionAffinity: this.sessionAffinity }) so requests can be routed with session affinity (sticky sessions), improving consistency for stateful or session-based interactions.
1 parent 930ae10 commit b3ff4b5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ export class ChatAgent extends AIChatAgent<Env> {
6868
const workersai = createWorkersAI({ binding: this.env.AI });
6969

7070
const result = streamText({
71-
model: workersai("@cf/moonshotai/kimi-k2.5"),
71+
model: workersai("@cf/moonshotai/kimi-k2.5", {
72+
sessionAffinity: this.sessionAffinity
73+
}),
7274
system: `You are a helpful assistant that can understand images. You can check the weather, get the user's timezone, run calculations, and schedule tasks. When users share images, describe what you see and answer questions about them.
7375
7476
${getSchedulePrompt({ date: new Date() })}

0 commit comments

Comments
 (0)