Skip to content

fix: emit completed assistant chat messages#23591

Open
michael-schienbein-fhr wants to merge 2 commits intoanomalyco:devfrom
michael-schienbein-fhr:mooki/chat-message-bodies-refresh
Open

fix: emit completed assistant chat messages#23591
michael-schienbein-fhr wants to merge 2 commits intoanomalyco:devfrom
michael-schienbein-fhr:mooki/chat-message-bodies-refresh

Conversation

@michael-schienbein-fhr
Copy link
Copy Markdown

@michael-schienbein-fhr michael-schienbein-fhr commented Apr 20, 2026

Issue for this PR

Closes #22831

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

chat.message already exposes populated parts for user messages, but current dev never emits a completed assistant chat.message. That leaves plugin authors with an asymmetric hook: they can observe finalized user messages but not finalized assistant messages through the same stable API.

This change emits one completed chat.message for assistant messages during processor cleanup, after the assistant message and its parts have been finalized. I also widened the plugin hook type from UserMessage to Message so the hook matches what runtime code now delivers.

I kept the change small on purpose:

  • no new hooks
  • no behavior changes to the existing user chat.message path
  • no changes to experimental hooks

The fix works because the processor already has the finalized assistant message id and can read the final stored parts at cleanup time. Emitting the hook there gives plugins the same completed-message shape they already get for user messages.

How did you verify your code works?

  • Ran bun test --timeout 30000 test/session/processor-effect.test.ts test/session/prompt-effect.test.ts
  • Ran bun run typecheck
  • Added an assistant regression test that fails on clean origin/dev with Expected length: 1 / Received length: 0
  • Re-ran that same test on this branch and confirmed it passes

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

[FEATURE]: Expose prompt/output message bodies to plugin chat.message hook

1 participant