Skip to content

[BUG]: [LLMObs] Bedrock integration fails with Cohere rerank model #14575

@Nimtaa

Description

@Nimtaa

Tracer Version(s)

3.14.0

Python Version(s)

3.12

Pip Version(s)

25.2

Bug Report

The LLMObs integration for AWS Bedrock does not handle responses from the Cohere reranking model cohere.rerank-v3-5:0. When used, it raises errors during span generation due to assumptions in the response parsing logic.

The integration should gracefully handle rerank responses from Bedrock and correctly set span tags and kind.

Reproduction Code

No response

Error Logs

The integration fails with the following errors:

Traceback (most recent call last): File "/home/nonroot/.venv/lib/python3.12/site-packages/ddtrace/llmobs/_integrations/base.py", line 105, in llmobs_set_tags self._llmobs_set_tags(span, args, kwargs, response, operation) File "/home/nonroot/.venv/lib/python3.12/site-packages/ddtrace/llmobs/_integrations/bedrock.py", line 133, in _llmobs_set_tags output_messages = self._extract_output_message(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nonroot/.venv/lib/python3.12/site-packages/ddtrace/llmobs/_integrations/bedrock.py", line 376, in _extract_output_message if isinstance(response["text"][0], str): ~~~~~~~~~~~~~~~~^^^ IndexError: list index out of range

Traceback (most recent call last): File "/home/nonroot/.venv/lib/python3.12/site-packages/ddtrace/llmobs/_llmobs.py", line 238, in _submit_llmobs_span span_event = self._llmobs_span_event(span) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nonroot/.venv/lib/python3.12/site-packages/ddtrace/llmobs/_llmobs.py", line 256, in _llmobs_span_event raise KeyError("Span kind not found in span context") KeyError: 'Span kind not found in span context'

Also, the warning:
Bedrock input is not a list of messages or a single string.

Libraries in Use

No response

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions