fix(core): attach sessionKey to chat-composer system messages - #562
Open
YuriNachos wants to merge 1 commit into
Open
fix(core): attach sessionKey to chat-composer system messages#562YuriNachos wants to merge 1 commit into
YuriNachos wants to merge 1 commit into
Conversation
Thread task.sessionKey into every persisted system message emitted by chat-composer (emitError paths, send timeout, /compact, /reset) so system errors/timeouts/compact/reset notices correlate to the originating session in ensemble mode. The store's addMessage already accepted sessionKey; this is a plumbing fix plus a matching widening of the composer's local addMessage options type. Closes clawwork-ai#214 Signed-off-by: Yurii Chukhlib <yurii.chukhlib@viber.com>
Contributor
|
Hi @YuriNachos, DetailsInstructions for interacting with me using comments are available here. |
Author
|
/auto-cc |
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 #214.
Problem
System messages emitted by the chat composer (send errors, send-timeout, compact, reset) were added via
addMessage(taskId, 'system', …)without asessionKey, so they were not associated with the task's session — breaking the per-session message scoping the rest of the message store relies on.Fix
Thread
task.sessionKeyinto every system-message path increateChatComposer(packages/core/src/services/chat-composer.ts):emitErrorgains a trailingsessionKey?parameter; all five call sites (gateway send-error ×3, lifecycle send-timeout, local catch) passtask.sessionKeyin the correct positional slot.addMessage(…, 'system', …)sites (send-timeout, compact, reset) pass{ sessionKey: task.sessionKey }.The change is purely additive —
options.sessionKeyis optional, so no existingaddMessageconsumer is affected.Tests
New
packages/core/test/chat-composer.test.tsexercises four system-message paths (send-error, send-timeout, compact, reset) and asserts each carries the task'ssessionKey.pnpm --filter @clawwork/core test→ 110 passed.Scope / follow-up
This PR covers the core chat-composer paths from #214. The same
addMessage(…, 'system', …)pattern exists in a few desktop-only call sites (theLeftNavcompact/reset shortcuts and auseChatSendcatch fallback) that also omitsessionKey; those are intentionally out of scope here (one concern per PR) and are good candidates for a follow-up.