Skip to content

[bot] LiteLLM: rerank() / arerank() not instrumented #266

@AbhiPrasad

Description

Summary

The Braintrust LiteLLM integration (wrap_litellm() and patch_litellm()) instruments completion, acompletion, responses, aresponses, image_generation, aimage_generation, embedding, aembedding, moderation, transcription, and atranscription. LiteLLM also exposes documented reranking APIs that are not instrumented at all:

  • litellm.rerank() — sync reranking for retrieval / RAG pipelines
  • litellm.arerank() — async reranking

LiteLLM’s rerank API is distinct from chat/completions: it takes a query plus a list of documents, and returns a RerankResponse with ranked results (index, relevance_score, optional document) plus optional metadata under meta (billed_units, tokens). Braintrust currently drops these calls entirely.

What is missing

No tracing spans are created when users call litellm.rerank() or litellm.arerank() through either wrap_litellm() or patch_litellm().

The current LiteLLM integration only patches:

  • completion, acompletion
  • responses, aresponses
  • image_generation, aimage_generation
  • embedding, aembedding
  • moderation
  • transcription, atranscription

There are no rerank patchers in py/src/braintrust/integrations/litellm/patchers.py, no rerank wrappers in py/src/braintrust/integrations/litellm/tracing.py, and no rerank coverage in py/src/braintrust/integrations/litellm/test_litellm.py.

Braintrust docs status

not_found — The Braintrust LiteLLM integration docs at https://www.braintrust.dev/docs do not mention rerank support.

Upstream sources

  • LiteLLM rerank docs: https://docs.litellm.ai/docs/rerank
  • LiteLLM Python SDK signatures expose both rerank(model, query, documents, ...) and arerank(model, query, documents, ...)
  • LiteLLM RerankResponse contains results and meta fields (litellm.types.rerank.RerankResponse)

Local repo files inspected

  • py/src/braintrust/integrations/litellm/__init__.py
  • py/src/braintrust/integrations/litellm/patchers.py
  • py/src/braintrust/integrations/litellm/tracing.py
  • py/src/braintrust/integrations/litellm/test_litellm.py
  • py/noxfile.py

Relationship to existing issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions