Repository navigation
fix: support message content - #16980
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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds reasoning-aware model streaming, structured thinking/message events, simplified message component streaming, and handler-owned SSE completion. Runner channels can close without emitting ChangesAgent reasoning and streaming
Message and SSE stream contracts
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Model as EinoChatModel
participant Agent as AgentComponent
participant Runtime as RuntimeEmitter
participant Service as AgentService
participant Handler as SSEHandler
Model->>Agent: stream content and reasoning
Agent->>Runtime: emit deltas
Runtime->>Service: forward agent message events
Service->>Handler: write structured SSE events
Handler->>Handler: append done after channel close
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/handler/agent.go (1)
405-420: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winMake the handler the sole owner of the final terminator.
Producer
doneevents are currently written immediately. If one arrives before another queued event, clients stop at[DONE]and miss the trailing event. Skip producerdoneevents and unconditionally write exactly one terminator after the channel closes.Proposed completion handling
- doneSent := false for ev := range events { if ev.Type == "done" { - doneSent = true + continue } if err := service.WriteChatbotRunEvent(c.Writer, ev); err != nil { return } } - if !doneSent { - _ = service.WriteChatbotRunEvent(c.Writer, canvas.RunEvent{Type: "done"}) - } + _ = service.WriteChatbotRunEvent(c.Writer, canvas.RunEvent{Type: "done"})As per coding guidelines, “Prefer deletion over compatibility shims, deprecated branches, wrapper APIs, and dual-track migration notes; converge coexisting implementations to one path unless an external contract requires compatibility.”
Also applies to: 1031-1072
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/handler/agent.go` around lines 405 - 420, The event loop in the handler should not forward producer-generated "done" events. Update the flow around doneSent and WriteChatbotRunEvent to skip those events, then unconditionally write exactly one final RunEvent with Type "done" after the events channel closes, preserving client-disconnect handling.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/agent/canvas/runner.go`:
- Around line 48-49: Update the comments at
internal/agent/canvas/runner.go:48-49 to state that the HTTP/SSE handler appends
the terminator after channel closure, removing the Python migration reference;
update internal/agent/runtime/context.go:41-42 to describe the marker as
tracking streamed Agent message chunks; and update
internal/entity/models/types.go:175-178 to describe the current canvas consumer
behavior without Python comparisons.
In `@internal/agent/component/agent.go`:
- Around line 242-257: Replace the canvas-wide AgentMessageEventsEmittedKey
usage in the Agent streaming and fallback emission paths with state scoped to
the current Agent invocation or node, so each Agent can emit independently.
Update all corresponding checks and writes, including the additional paths noted
in the comment, and add a regression test that runs two sequential Agent
components and verifies both produce visible output.
In `@internal/service/agent.go`:
- Around line 98-143: Update makeAgentMessageDeltaEmitter to process both
thinkingDelta and contentDelta in the same callback instead of returning after
reasoning, preserving their streaming order and buffered inline content. Return
an EOF finalizer that closes any active thinking phase and flushes remaining
ThinkStreamState content, and invoke it before message_end; add coverage for
combined deltas and streams ending immediately after reasoning.
---
Outside diff comments:
In `@internal/handler/agent.go`:
- Around line 405-420: The event loop in the handler should not forward
producer-generated "done" events. Update the flow around doneSent and
WriteChatbotRunEvent to skip those events, then unconditionally write exactly
one final RunEvent with Type "done" after the events channel closes, preserving
client-disconnect handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: de4a48ec-ddc4-4d8a-bddd-a65afc7ae523
📒 Files selected for processing (16)
internal/agent/canvas/runner.gointernal/agent/component/agent.gointernal/agent/component/agent_test.gointernal/agent/component/llm.gointernal/agent/component/message.gointernal/agent/component/message_chunked_test.gointernal/agent/component/message_test.gointernal/agent/runtime/context.gointernal/entity/models/llm.gointernal/entity/models/types.gointernal/handler/agent.gointernal/handler/agent_test.gointernal/service/agent.gointernal/service/agent_run_e2e_test.gointernal/service/agent_test.gointernal/service/bot_completion.go
💤 Files with no reviewable changes (1)
- internal/agent/component/message_chunked_test.go
|
LGTM |
Summary
As Title
