Skip to content

[bot] LiteLLM: amoderation() async variant not instrumented #402

@braintrust-bot

Description

@braintrust-bot

Summary

The Braintrust LiteLLM integration instruments litellm.moderation() (sync) but not litellm.amoderation() (async). This is the only LiteLLM function where the async variant is missing — every other instrumented function has both sync and async patchers.

LiteLLM exposes amoderation() as a documented async function (confirmed via LiteLLM source and recent bug fix PR). Calls to litellm.amoderation() produce zero Braintrust tracing.

What is missing

No tracing span is created when users call litellm.amoderation() through either wrap_litellm() or patch_litellm().

Current async parity in py/src/braintrust/integrations/litellm/patchers.py:

Function Sync Patcher Async Patcher
completion / acompletion Yes Yes
responses / aresponses Yes Yes
image_generation / aimage_generation Yes Yes
embedding / aembedding Yes Yes
speech / aspeech Yes Yes
transcription / atranscription Yes Yes
rerank / arerank Yes Yes
moderation / amoderation Yes No

The fix requires:

  • Adding _amoderation_wrapper_async to tracing.py (mirroring the existing _moderation_wrapper)
  • Adding LiteLLMAmoderationPatcher to patchers.py
  • Adding it to _ALL_LITELLM_PATCHERS

Braintrust docs status

The Braintrust LiteLLM integration docs do not specifically mention moderation support.

Upstream sources

Local files inspected

  • py/src/braintrust/integrations/litellm/patchers.pyLiteLLMModerationPatcher exists (sync only); no LiteLLMAmoderationPatcher
  • py/src/braintrust/integrations/litellm/tracing.py_moderation_wrapper exists; no _amoderation_wrapper_async
  • py/src/braintrust/integrations/litellm/test_litellm.py — no async moderation tests
  • Grep for amoderation across py/src/braintrust/integrations/litellm/ returns zero matches

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