fix(queue): bind agent ID at enqueue time to prevent cross-agent deli…#5371
Merged
zhijianma merged 5 commits intoJun 22, 2026
Merged
Conversation
…very - Add agentId field to QueueItem, captured from storage at enqueue time - Override X-Agent-Id header in background sender with item.agentId - Fix waitForChatIdle to use correct agent ID for status polling, preventing spurious idle detection after agent switch - Handle AbortError correctly in waitForChatIdle fetch Closes agentscope-ai#5354
|
Hi @zhaozhuang521, this is your 154th Pull Request. 📋 About PR TemplateTo help maintainers review your PR faster, please make sure to include:
Complete PR information helps speed up the review process. You can edit the PR description to add these details. 🙌 Join Developer CommunityThanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page: We truly appreciate your enthusiasm—and look forward to your future contributions! 😊 We'll review your PR soon. |
…ion drift After an agent switch the session list is replaced with the new agent's sessions, causing getBackendSessionId() to fail for the original chat. The background sender then posts to an incorrect session_id, creating a new conversation for the remaining queued items. - Add backendSessionId field to QueueItem, captured from window.currentSessionId at enqueue time - startAllBackgroundQueues prefers the item's snapshot over the live sessionApi lookup (which may be stale after agent switch) - startBackgroundQueue POST body uses item.backendSessionId as primary source, falling back to the resolved parameter
added 3 commits
June 22, 2026 13:59
Two related fixes for cross-agent / queue interaction issues:
1. Foreground sender uses wrong session after agent switch
- Removing ctrl.signal from background fetch keeps the HTTP connection
alive when the queue loop is aborted, so the server completes and
persists the turn (no message loss, no duplicates)
- scheduleNextSend now force-sets window.currentSessionId from the
queue item's backendSessionId snapshot before SDK submit, so
customFetch always uses the correct session even if the global was
overwritten by a recent agent switch
- Agent switch effect sets chatLoading=true immediately as defense
in depth against the reload race window
2. Slash commands swallowed by queue when busy
- handleEnterEnqueue (capture-phase Enter listener) now skips strings
starting with '/' so the slash-command system handles them
- handleBeforeSubmit non-owner-tab branch returns true for slash
commands instead of routing them through the queue
zhijianma
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #5354
Type of Change
Component(s) Affected
Checklist
pre-commit run --all-fileslocally and it passespytestor as relevant) and they passFor Channel Changes (DingTalk, Feishu, QQ, Console, etc.)
./scripts/check-channels.sh(or./scripts/check-channels.sh --changed) and it passestests/contract/channels/test_<channel>_contract.py(REQUIRED)create_instance()with proper channel initializationtests/contract/channels/__init__.py)tests/unit/channels/test_<channel>.pyfor complex internal logicTesting
[How to test these changes]
Local Verification Evidence
Additional Notes
[Optional: any other context]