Skip to content

feat(chat): add queue-debounce concurrency strategy#495

Merged
dancer merged 5 commits into
mainfrom
josh/queue-debounce
May 15, 2026
Merged

feat(chat): add queue-debounce concurrency strategy#495
dancer merged 5 commits into
mainfrom
josh/queue-debounce

Conversation

@dancer
Copy link
Copy Markdown
Collaborator

@dancer dancer commented May 12, 2026

summary

adds an opt-in burst concurrency strategy for #414

when a thread is idle, the first message waits for debounceMs, messages that arrive during that window are queued, and the handler runs once with the latest message plus earlier burst messages in context.skipped

after the handler finishes, messages that arrived while it was running are drained like queue, so the latest queued message is processed with earlier queued messages in context.skipped

keeps existing drop, queue, debounce, and concurrent behavior unchanged

updates docs to cover burst, explain when to choose it over debounce, and document the related MessageContext behavior

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, Comment, Open in v0 May 13, 2026 1:53pm
chat-sdk-nextjs-chat Ready Ready Preview, Comment, Open in v0 May 13, 2026 1:53pm

Copy link
Copy Markdown
Collaborator

@visyat visyat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good aside from the mode naming!!

Comment thread .changeset/soft-jars-cover.md Outdated
Comment thread apps/docs/content/docs/concurrency.mdx Outdated
@dancer dancer merged commit b75eedb into main May 15, 2026
17 checks passed
@dancer dancer deleted the josh/queue-debounce branch May 15, 2026 02:18
patrick-chinchill added a commit to Chinchill-AI/chat-sdk-python that referenced this pull request May 29, 2026
Ports the new burst concurrency strategy from upstream commit b75eedb (vercel/chat#495). Part of the 0.4.29 sync wave.

burst is a hybrid of debounce and queue:
- Idle thread: first message waits debounce_ms before dispatching; messages arriving during the window are queued; when the window elapses, the handler runs once with the latest message and earlier burst messages exposed via context.skipped
- Busy thread: messages arriving while a handler is running drain identically to queue

Distinct semantics from existing strategies:
- queue: handler called per-message (queue drains in order)
- debounce: handler called once with latest, earlier messages silently dropped
- burst: handler called once with latest, earlier messages in context.skipped

Honors max_queue_size + on_queue_full (queue semantics) and debounce_ms (debounce semantics). Existing drop / queue / debounce / concurrent behavior unchanged.

Naming follows upstream's emitted strategy literal "burst" (not the PR title "queue-debounce") for state-adapter interop.

Pre-merge code review verified: §3 pass-interaction clean, §5 no new task lifecycle hazards, §6 ContextVar boundaries clean, wedge tests pin the right invariants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants