Skip to content

Conversation

@Jbrito6492
Copy link

@Jbrito6492 Jbrito6492 commented Feb 10, 2026

SKNK-7473

What this does

Adds AWS Bedrock Guardrails support to the ruby_llm gem by injecting guardrail headers (X-Amzn-Bedrock-GuardrailIdentifier and X-Amzn-Bedrock-GuardrailVersion) into Bedrock API requests. Headers are applied after AWS request signing to avoid invalidating the signature.

Also includes:

  • No-op cache_prompts method on Chat for compatibility with ruby_conversations gem (Bedrock does not support prompt caching)
  • Gem name updated to ruby_llm_community
  • Reduced log verbosity (bodies: false in connection logging)

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

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)

API changes

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

New Configuration Attributes

RubyLLM.configure do |config|
  config.bedrock_guardrail_identifier = 'your-guardrail-id'
  config.bedrock_guardrail_version = '2'  # defaults to 'DRAFT'
end

Files Changed

File Change
lib/ruby_llm/configuration.rb Added bedrock_guardrail_identifier and bedrock_guardrail_version config attrs
lib/ruby_llm/providers/bedrock.rb Added build_guardrail_headers method
lib/ruby_llm/providers/bedrock/chat.rb Inject guardrail headers after signing in sync path
lib/ruby_llm/providers/bedrock/streaming/base.rb Inject guardrail headers after signing in streaming path
lib/ruby_llm/chat.rb No-op cache_prompts for Bedrock compatibility
lib/ruby_llm/connection.rb Disable request body logging to reduce noise
ruby_llm.gemspec Rename gem to ruby_llm_community

Related issues

SKNK-7473 — AWS Bedrock Guardrails integration for Lexi

Jbrito6492 and others added 4 commits November 30, 2025 02:05
Remove gem rename (ruby_llm -> ruby_llm_community) and logging
config change (bodies: false) that were bundled into the guardrail
commit but are not related to guardrails support.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use ** (double splat) to accept any keyword arguments without
naming them, satisfying Lint/UnusedMethodArgument.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pre-existing offenses across all spec files. This pattern is used
consistently throughout the test suite and is not worth refactoring.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Jbrito6492 Jbrito6492 requested review from Toacin and navidgs February 11, 2026 17:53
@Jbrito6492 Jbrito6492 merged commit b515b14 into main Feb 11, 2026
13 checks passed
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.

3 participants