Skip to content

Commit b89142a

Browse files
committed
fix: consume prompt on first poll read to prevent duplicate dispatch
The GET endpoint now clears the prompt from the session after the first read. Subsequent polls see status "picked" but no prompt, so even if multiple fetches are in flight only the first one gets the prompt to send to the agent.
1 parent 0fa0670 commit b89142a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

apps/app/src/app/api/pick/route.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ export async function GET(req: NextRequest) {
99
const session = getSession(sessionId);
1010
if (!session) return NextResponse.json({ status: "waiting" });
1111

12+
// Consume the prompt on first read so duplicate polls don't re-trigger
13+
if (session.status === "picked" && session.prompt) {
14+
const prompt = session.prompt;
15+
setSession(sessionId, { status: "picked" });
16+
return NextResponse.json({ status: "picked", prompt });
17+
}
18+
1219
return NextResponse.json(session);
1320
}
1421

0 commit comments

Comments
 (0)