Skip to content

Commit e74bb9f

Browse files
starfolkbotclaude
andcommitted
clean up: drop redundant comments
The SKILL.md paragraph carries the "why" for dspy.lm; variable names carry the rest. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent db87b06 commit e74bb9f

2 files changed

Lines changed: 2 additions & 21 deletions

File tree

‎py/src/braintrust/integrations/dspy/test_dspy.py‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,36 +42,29 @@ def test_dspy_callback(memory_logger):
4242

4343
spans_by_name = {span["span_attributes"]["name"]: span for span in spans}
4444

45-
# DSPy modules are pipeline steps → task per spec.
46-
module_span = spans_by_name.get("dspy.module.ChainOfThought")
47-
assert module_span is not None
45+
module_span = spans_by_name["dspy.module.ChainOfThought"]
4846
assert module_span["span_attributes"]["type"] == "task"
4947
assert module_span["metadata"]["module_class"].endswith("ChainOfThought")
5048

5149
lm_span = spans_by_name["dspy.lm"]
5250
assert lm_span["context"]["span_origin"]["instrumentation"]["name"] == "dspy-auto"
53-
# dspy.lm intentionally has no `llm` type — the underlying provider integration
54-
# (litellm/openai/anthropic) owns the `llm` leaf and its token accounting.
5551
assert lm_span["span_attributes"].get("type") != "llm"
5652
assert "metadata" in lm_span
5753
assert "model" in lm_span["metadata"]
5854
assert MODEL in lm_span["metadata"]["model"]
59-
# Still record provider so downstream tools can attribute the call correctly;
60-
# derived from the litellm-style "openai/..." prefix.
6155
assert lm_span["metadata"]["provider"] == "openai"
6256
assert "input" in lm_span
6357
assert "output" in lm_span
6458

6559
format_span = spans_by_name["dspy.adapter.format"]
66-
parse_span = spans_by_name["dspy.adapter.parse"]
67-
6860
assert format_span["span_attributes"]["type"] == "task"
6961
assert format_span["metadata"]["adapter_class"].endswith("ChatAdapter")
7062
assert "signature" in format_span["input"]
7163
assert "demos" in format_span["input"]
7264
assert "inputs" in format_span["input"]
7365
assert isinstance(format_span["output"], list)
7466

67+
parse_span = spans_by_name["dspy.adapter.parse"]
7568
assert parse_span["span_attributes"]["type"] == "task"
7669
assert parse_span["metadata"]["adapter_class"].endswith("ChatAdapter")
7770
assert "signature" in parse_span["input"]

‎py/src/braintrust/integrations/dspy/tracing.py‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88

99
_INSTRUMENTATION = "dspy-auto"
1010

11-
# LiteLLM-style model strings are "<provider>/<model>" (e.g. "openai/gpt-4o-mini").
12-
# The prefix identifies the provider whose pricing applies.
1311
_LM_METADATA_PARAM_ALLOWLIST = ("temperature", "max_tokens", "top_p", "top_k", "stop")
14-
15-
# Aggregate eval stats that DSPy Evaluate surfaces on its return dict. These are
16-
# domain-level scores, not spec-listed span `metrics` keys, so they go in metadata.
1712
_EVALUATE_METADATA_ALLOWLIST = ("accuracy", "score", "total", "correct")
1813

1914

@@ -139,13 +134,6 @@ def on_lm_start(
139134
if key in inputs:
140135
metadata[key] = inputs[key]
141136

142-
# dspy.lm is intentionally NOT typed as `llm`. DSPy delegates the actual
143-
# provider call to LiteLLM (or a patched provider client), which owns the
144-
# `llm` leaf span and its token accounting. Typing this parent as `llm`
145-
# would produce two `llm` spans per model call when the underlying
146-
# provider is also instrumented, and this span cannot supply the tokens
147-
# required for `llm` because DSPy's callback contract does not expose
148-
# usage in `outputs`.
149137
span = start_span(
150138
name="dspy.lm",
151139
input=inputs,

0 commit comments

Comments
 (0)