-
-
Notifications
You must be signed in to change notification settings - Fork 392
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Basic checks
- I searched existing issues - this hasn't been reported
- I can reproduce this consistently
- This is a RubyLLM bug, not my application code
What's broken?
To Reproduce
- Create a Chat
- Start a conversation — begin adding attachments (add multiple messages with varying attachments)
- Try to specify a new attachment
- See inconsistent behavior
How We Resolved This For Now
# within chat_stream_job.rb#perform
# Path A: User message has attachments → use chat.prompt() with blobs
# Path B: Text-only → use chat.complete() as before
if @user_msg.attachments.attached?
stream_with_attachments
else
stream_text_only
end
# also within chat_stream_job.rb — uses #prompt to ensure only latest attachments are passed to LLM for consistency
def stream_with_attachments
blobs = @user_msg.attachments.blobs.to_a
response = @chat.prompt(@user_msg.content, with: blobs) do |chunk|
break if stopped?
chunk_text = extract_chunk_text(chunk)
next if chunk_text.nil? || chunk_text.empty?
@accumulated += chunk_text
# Create assistant message on first chunk
@llm_msg ||= @chat.messages.create!(role: :assistant, content: @accumulated)
@llm_msg.update_columns(content: @accumulated)
@llm_msg.broadcast_full_replace!
end
endHow to reproduce
- Create a chat with attachments
- Chat repetitively, uploading new attachments per message and asking about details on each one
- Observe the issue
Expected behavior
Expected chat to reliably respond to the latest messages with their distinct attachments as the attachment context.
What actually happened
Before
Chat gets confused, referencing the wrong attachment (I saw this in old tests) or referencing a RubyLLM::Content object (I saw this in recent tests)
Environment
- Ruby Version: 4.0.0
- RubyLLM version 1.11.0
- Provider Anthropic
- OS: MacOS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working