Repository navigation
fix(bedrock): map response roles explicitly - #1138
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Bedrock OpenAI-family decoder passed provider-supplied role strings to
String.to_existing_atom/1. A string without an existing atom raisedArgumentErrorin the caller's process.Replace that conversion with explicit mappings for
assistant,user,system, andtool. Unknown values fall back to:assistant, matching the default OpenAI-compatible response builder's response role. The default decoder does not useString.to_existing_atom/1for response roles.Extend the existing Bedrock OpenAI unit tests to cover all four supported roles, an unknown string, an unsupported string that already has a VM atom (
error), andnil. The unknown-string regression failed against the original decoder and passes with the fix.Audited conversions left unchanged:
amazon_bedrock/cohere.ex: converts provider-response field names, but rescuesArgumentErrorand preserves unknown names as strings.anthropic.ex: converts caller-supplied tool schema field names during request encoding, and rescuesArgumentError.lmstudio.ex: converts caller-suppliedreasoning_effortoptions after an allowlist check; the corresponding atoms are defined in the module.Verification:
mix format: passed.mix compile --warnings-as-errors: passed.mix credo --strict: passed; 625 source files checked, no issues.mix test test/req_llm/providers/amazon_bedrock/openai_test.exs: 21 passed.mix test: 5,334/5,336 passed, 11 skipped, 240 excluded; two StreamServer synchronization timeouts inmetadata_test.exs:147anderror_handling_test.exs:51(seed 434574).mix test --failed: both previously failing tests passed.ERL_FLAGS='+S 4:4' mix test --max-cases 4: 5,336 passed, 11 skipped, 240 excluded.The initial timeout cause was not confirmed. No streaming code was changed. Fixture recording was disabled and no fixtures were modified.
🤖 Generated with Codex and Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.