-
-
Couldn't load subscription status.
- Fork 296
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?
When using acts_as_chat with Rails, file attachments via the with: parameter only work when creating new chats, not when adding messages to existing chats.
How to reproduce
# Create a chat
chat_record = Chat.create!(model: 'claude-sonnet-4')
# This works (response correctly describes diagram)
chat_record.ask("What's in this file?", with: "app/assets/images/diagram.png")
# This does not work (response describes diagram, not chart)
chat_record.ask("What's in this file?", with: "app/assets/images/chart.png")However, the following, using RubyLLM and not acts_as_chat works as expected:
# Create a chat
chat = RubyLLM.chat(model: 'claude-sonnet-4')
# This works (response correctly describes diagram)
chat.ask("What's in this file?", with: "app/assets/images/diagram.png")
# This works (response correctly describes chart)
chat.ask("What's in this file?", with: "app/assets/images/chart.png")Expected behavior
The expected behavior is:
- First message with file: File content should be included in the AI request and the response should reference the file content
- Subsequent messages with different files: Each new file should be processed and included in the AI request, with the response correctly referencing the new file content
- Consistent behavior: File attachments should work the same way whether it's the first message or the 10th message in a conversation
The Rails integration should behave identically to the raw RubyLLM chat instance, where file attachments work correctly in all subsequent messages. The acts_as_chat helper should not change the core functionality of file attachment processing.
Current behavior: Only the first file attachment in a conversation is processed correctly; subsequent file attachments are ignored.
Expected behavior: All file attachments should be processed correctly, regardless of their position in the conversation history.
What actually happened
- File attachments are ignored in subsequent messages
- Only works with fresh
RubyLLM.chatinstances - Breaks the conversation flow for applications that need to add files mid-conversation
Environment
- Ruby version: 3.3.8
- RubyLLM version: 1.8.2
- Rails version: 8.0.2
- Provider: OpenAI
- OS: MacOS 15.6.1