fix: emit role chunk from anthropic message start in chat stream - #3575
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis change extends ChangesAnthropic MessageStart Event Handler
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
Confidence Score: 4/5The change is a small, well-scoped addition to an existing switch statement; the new code path is logically consistent with how other event types build role/delta chunks in the same function. The implementation correctly extracts the role before returning a role-only chunk, and the caller already handles nil vs non-nil responses, so the new branch does not introduce any observable runtime risk. The only gap is the absence of a unit test, which leaves the new branch entirely uncovered. core/providers/anthropic/chat.go — the new branch in ToBifrostChatCompletionStream has no test coverage. Important Files Changed
Reviews (1): Last reviewed commit: "fix: emit role chunk from anthropic mess..." | Re-trigger Greptile |
Merge activity
|
|
tejas ghatte seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
## Summary
When processing Anthropic streaming events, the `message_start` event was previously discarded entirely. This meant the assistant role information included in the initial message event was never forwarded to the caller, resulting in incomplete stream chunks.
## Changes
- When a `message_start` event contains a non-empty role on the message, a `chat.completion.chunk` stream response is now returned with the role populated in the delta, rather than returning `nil` and silently dropping it.
## Type of change
- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI
## Affected areas
- [x] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
Send a streaming chat completion request through the Anthropic provider and verify that the first chunk in the stream includes the assistant role in the delta.
```sh
go test ./core/providers/anthropic/...
```
Confirm the first streamed chunk contains:
```json
{
"object": "chat.completion.chunk",
"choices": [
{
"index": 0,
"delta": {
"role": "assistant"
}
}
]
}
```
## Screenshots/Recordings
N/A
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
N/A
## Security considerations
No security implications.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
…imhq#3575) ## Summary When processing Anthropic streaming events, the `message_start` event was previously discarded entirely. This meant the assistant role information included in the initial message event was never forwarded to the caller, resulting in incomplete stream chunks. ## Changes - When a `message_start` event contains a non-empty role on the message, a `chat.completion.chunk` stream response is now returned with the role populated in the delta, rather than returning `nil` and silently dropping it. ## Type of change - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Send a streaming chat completion request through the Anthropic provider and verify that the first chunk in the stream includes the assistant role in the delta. ```sh go test ./core/providers/anthropic/... ``` Confirm the first streamed chunk contains: ```json { "object": "chat.completion.chunk", "choices": [ { "index": 0, "delta": { "role": "assistant" } } ] } ``` ## Screenshots/Recordings N/A ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations No security implications. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
When processing Anthropic streaming events, the
message_startevent was previously discarded entirely. This meant the assistant role information included in the initial message event was never forwarded to the caller, resulting in incomplete stream chunks.Changes
message_startevent contains a non-empty role on the message, achat.completion.chunkstream response is now returned with the role populated in the delta, rather than returningniland silently dropping it.Type of change
Affected areas
How to test
Send a streaming chat completion request through the Anthropic provider and verify that the first chunk in the stream includes the assistant role in the delta.
go test ./core/providers/anthropic/...Confirm the first streamed chunk contains:
{ "object": "chat.completion.chunk", "choices": [ { "index": 0, "delta": { "role": "assistant" } } ] }Screenshots/Recordings
N/A
Breaking changes
Related issues
N/A
Security considerations
No security implications.
Checklist
docs/contributing/README.mdand followed the guidelines