Skip to content

fix(core): attach sessionKey to chat-composer system messages - #562

Open
YuriNachos wants to merge 1 commit into
clawwork-ai:mainfrom
YuriNachos:fix/sessionkey-system-messages
Open

fix(core): attach sessionKey to chat-composer system messages#562
YuriNachos wants to merge 1 commit into
clawwork-ai:mainfrom
YuriNachos:fix/sessionkey-system-messages

Conversation

@YuriNachos

Copy link
Copy Markdown

Closes #214.

Problem

System messages emitted by the chat composer (send errors, send-timeout, compact, reset) were added via addMessage(taskId, 'system', …) without a sessionKey, 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.sessionKey into every system-message path in createChatComposer (packages/core/src/services/chat-composer.ts):

  • emitError gains a trailing sessionKey? parameter; all five call sites (gateway send-error ×3, lifecycle send-timeout, local catch) pass task.sessionKey in the correct positional slot.
  • The three direct addMessage(…, 'system', …) sites (send-timeout, compact, reset) pass { sessionKey: task.sessionKey }.

The change is purely additive — options.sessionKey is optional, so no existing addMessage consumer is affected.

Tests

New packages/core/test/chat-composer.test.ts exercises four system-message paths (send-error, send-timeout, compact, reset) and asserts each carries the task's sessionKey.

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 (the LeftNav compact/reset shortcuts and a useChatSend catch fallback) that also omit sessionKey; those are intentionally out of scope here (one concern per PR) and are good candidates for a follow-up.

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>
@YuriNachos
YuriNachos requested a review from samzong as a code owner August 7, 2026 11:48
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Hi @YuriNachos,
Thanks for your pull request!
If the PR is ready, use the /auto-cc command to assign Reviewer to Review.
We will review it shortly.

Details

Instructions for interacting with me using comments are available here.
If you have questions or suggestions related to my behavior, please file an issue against the gh-ci-bot repository.

@YuriNachos

Copy link
Copy Markdown
Author

/auto-cc

@github-actions
github-actions Bot requested a review from HiddenPuppy August 7, 2026 21:17
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.

[Bug] System error messages missing sessionKey in ensemble mode

1 participant