Skip to content

[Bug]: enable_litellm_models_monitoring is documented for LiteLLMChatModel but also governs AnthropicChatModel #8413

Description

@feiiiiii5

What component(s) are affected?

  • Opik Python SDK
  • Opik Typescript SDK
  • Opik Agent Optimizer SDK
  • Opik UI
  • Opik Server
  • Documentation

Opik version

  • Opik version: 2.2.71 (origin/main at f06298d93)

Describe the problem

enable_litellm_models_monitoring is documented as governing one class, but the Anthropic adapter also reads it.

sdks/python/src/opik/config.py:217-222:

enable_litellm_models_monitoring: bool = True
"""
If set to True - Opik will create llm spans for LiteLLMChatModel calls.
It is mainly to be used in tests since litellm uses external Opik callback
which makes HTTP requests not via the opik package.
"""

sdks/python/src/opik/evaluation/models/anthropic/anthropic_chat_model.py:65:

enable_tracking = track and config.enable_litellm_models_monitoring

So an AnthropicChatModel built with track=True silently produces no spans when a user or test harness sets enable_litellm_models_monitoring=False — a flag whose own documentation limits it to LiteLLMChatModel and whose stated reason for existing (litellm's external callback plumbing) does not apply to the Anthropic client, which traces through opik.integrations.anthropic.track_anthropic in-process.

This surfaced while writing #8408/#8409: the repo triage bot suggested the LangChain adapter should honour the same config flag "for consistency". I did not do that, precisely because the flag is documented as LiteLLM-scoped — but checking that led here, and the Anthropic use looks like the same copy-paste viewed from the other side.

Which way is correct?

Either reading is defensible and they are not the same change, so I would rather not guess:

  1. The docstring is accurate and the usage is wrong → drop the config term from anthropic_chat_model.py:65, leaving track to govern that adapter. Behaviour change for anyone currently setting the flag to False.
  2. The flag is meant as a general "SDK-attached LLM span" switch → then config.py:217 and its name should be generalised (and the LangChain adapter should read it too, which is what the triage bot assumed). Also a behaviour change, in the opposite direction.

Option 3 is adding an Anthropic-specific option, which is a new configuration surface rather than a fix.

Reproduction steps and code snippets

Not executed as a live trace test — this is a code-and-documentation contradiction rather than a runtime mystery, and the two lines above are the whole of it. rg enable_[a-z_]*monitoring src/opik/config.py returns exactly this one option, so there is no general switch being read by mistake.

Error logs or stack trace

None — the failure mode is silent absence of spans.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions