Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ruby_llm/protocols/converse/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def parse_completion_body(data, raw:)
cache_write_tokens: usage['cacheWriteInputTokens'],
thinking_tokens: reasoning_tokens(usage),
finish_reason: data['stopReason'],
model: data['modelId'],
model: data['modelId'] || @model&.id,
raw: raw
)
end
Expand Down
19 changes: 19 additions & 0 deletions spec/ruby_llm/protocols/converse/chat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@
expect(message.finish_reason).to eq('guardrail_intervened')
end

it 'falls back to the request model when Bedrock omits modelId' do
response_body = {
'output' => {
'message' => {
'content' => [{ 'text' => 'Hi!' }]
}
},
'usage' => {}
}

provider = double(config: RubyLLM.config, connection: nil)
model = instance_double(RubyLLM::Model, id: 'openai.gpt-oss-120b-1:0')
protocol = RubyLLM::Protocols::Converse.new(provider, model)
response = instance_double(Faraday::Response, body: response_body)
message = protocol.send(:parse_completion_body, response_body, raw: response)

expect(message.model).to eq('openai.gpt-oss-120b-1:0')
end

it 'extracts thinking tokens from top-level reasoningTokens' do
response_body = {
'output' => {
Expand Down
Loading