Skip to content

Fix #707 structured content persistence and harden streaming error handling#718

Open
afurm wants to merge 2 commits into
crmne:mainfrom
afurm:af/fix-707-content-streaming
Open

Fix #707 structured content persistence and harden streaming error handling#718
afurm wants to merge 2 commits into
crmne:mainfrom
afurm:af/fix-707-content-streaming

Conversation

@afurm
Copy link
Copy Markdown
Contributor

@afurm afurm commented Apr 2, 2026

What this does

Fixes #707 by preserving structured string-keyed content across the ActiveRecord persistence boundary instead of reloading it as RubyLLM::Content::Raw.

This PR also hardens streaming error handling so the test matrix stays green:

  • adds a useful to_s / to_json representation for Content::Raw
  • handles missing Faraday v2 env objects in generic and Bedrock streaming error paths
  • avoids VertexAI auth initialization during stubbed streaming error specs
  • updates the gemspec spec to respect FARADAY_VERSION
  • adds regression coverage for the persistence and streaming error cases

Fixes #707.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case

Required for new features

  • I opened an issue before writing code and received maintainer approval
  • Linked issue: #___

PRs for new features or enhancements without a prior approved issue will be closed.

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
  • For provider changes: Re-recorded VCR cassettes with bundle exec rake vcr:record[provider_name]
  • All tests pass: bundle exec rspec
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

Validation run locally:

  • bundle exec rubocop
  • Rails appraisal matrix for rails-7.1, rails-7.2, rails-8.0, rails-8.1
  • The same appraisal matrix again with FARADAY_VERSION=1.10.3
  • Local gitleaks scan against .gitleaks.toml

AI-generated code

  • I used AI tools to help write this code
  • I have reviewed and understand all generated code (required if above is checked)

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.10%. Comparing base (4942d6c) to head (a444caf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/ruby_llm/content.rb 71.42% 2 Missing ⚠️
lib/ruby_llm/providers/bedrock/streaming.rb 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #718      +/-   ##
==========================================
+ Coverage   87.05%   87.10%   +0.04%     
==========================================
  Files         119      119              
  Lines        5594     5615      +21     
  Branches     1407     1416       +9     
==========================================
+ Hits         4870     4891      +21     
  Misses        724      724              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[BUG] Inconsistent message.content type across persistence boundary

2 participants