BerriAI/litellm · error · Exception

Unable to convert openai tool calls=

Error message

Unable to convert openai tool calls={tool_calls} to bedrock tool calls. Received error={e}

What it means

Converse conversion guard: while translating OpenAI tool_calls to Bedrock Converse toolUse blocks, an exception occurred (e.g. malformed arguments JSON or missing function fields); it is wrapped with the offending tool_calls in the message and re-raised so the caller can see which input failed.

Solutions

  1. Check the tool_calls structure; Bedrock requires specific tool call formats.
  2. Simplify the tool calls or inspect the conversion error {e} for the offending field.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/litellm_core_utils/prompt_templates/factory.py:3715 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/80af02434fffaf86. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/prompt_templates/factory.py:3715

                        # Fallback: no objects extracted — use empty dict.
                        arguments_dict = {}

                bedrock_tool = BedrockToolUseBlock(input=arguments_dict, name=name, toolUseId=tool_id)
                bedrock_content_block = BedrockContentBlock(toolUse=bedrock_tool)
                _parts_list.append(bedrock_content_block)

                # Check for cache_control and add a separate cachePoint block
                if tool.get("cache_control", None) is not None:
                    cache_point_block = litellm.AmazonConverseConfig().get_cache_point_block(
                        {"cache_control": tool["cache_control"]},
                        block_type="content_block",
                        model=model,
                    )
                    if cache_point_block is not None:
                        _parts_list.append(cache_point_block)
        return _parts_list
    except Exception as e:
        raise Exception(f"Unable to convert openai tool calls={tool_calls} to bedrock tool calls. Received error={e}")


def _append_bedrock_tool_result_media_block(
    tool_result_content_blocks: list[BedrockToolResultContentBlock],
    processed_block: BedrockContentBlock,
    content: dict,
    content_type: str,
) -> None:
    if "image" in processed_block:
        tool_result_content_blocks.append(BedrockToolResultContentBlock(image=processed_block["image"]))
    elif "document" in processed_block:
        tool_result_content_blocks.append(BedrockToolResultContentBlock(document=processed_block["document"]))
    else:
        verbose_logger.warning(
            "Bedrock Converse: unrecognized BedrockContentBlock keys %s for %s tool-result block %s; dropping.",
            list(processed_block.keys()),
            content_type,
            content,

View on GitHub (pinned to 77b7c6c40c)