Schedule chat prompts: send_at holds a queued prompt until its time
A chat_prompt with a future send_at (epoch ms) is always queued, durable in chat_prompt_queue (new send_at column, added to older databases on Open), listed with send_at in chat_queue frames, and delivered by the room's runner once the time passes, waking on a timer. The queue stays FIFO: prompts queued after a scheduled one wait behind it. A past or zero send_at behaves as before; chat_unqueue cancels as for any queued prompt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -123,6 +123,13 @@ func admitChatPrompt(ctx context.Context, request protocol.Message, broker chatB
|
||||
requestID: request.ID,
|
||||
write: write,
|
||||
}
|
||||
if prompt.SendAt > 0 {
|
||||
// Only a future time schedules; a past one sends exactly as an
|
||||
// unscheduled prompt.
|
||||
if at := time.UnixMilli(prompt.SendAt); at.After(hub.clock()) {
|
||||
queuedPrompt.sendAt = at
|
||||
}
|
||||
}
|
||||
// Claim the operation before admission so a concurrent retry of the same
|
||||
// prompt is acknowledged rather than delivered twice.
|
||||
hub.rememberOp(sessionID, operationID)
|
||||
|
||||
Reference in New Issue
Block a user