maple-agent-tracing-dspy
Installation
SKILL.md
Maple agent tracing: DSPy
Goal: every conversation with the user's DSPy program shows up in Maple Agent Sessions as one session, with one turn per call to the program, a transcript, model calls with tokens and cost, tool calls with arguments, results and failures, and one lane per worker module.
Spans come from openinference-instrumentation-dspy. It records no tokens, no tool names, no agent spans and no session id; the steps below add all four. Do not skip any step.
Step 0: Detect versions and existing setup
- Read
pyproject.toml/requirements*.txt/uv.lock. Requiredspy>=3.4. On 3.3 or older, tell the user this skill targets 3.4 and ask before upgrading. - Find how LMs are built:
dspy.LM("provider/model", ...). Note anyengine=,cache=,callbacks=,disable_history,max_history_size. - Search for an existing OpenTelemetry setup:
TracerProvider(,set_tracer_provider,opentelemetry-instrument,logfire.configure,mlflow.dspy.autolog,phoenix.otel.register,LiteLLMInstrumentor,OpenAIInstrumentor.- An existing
TracerProvider: reuse it. Add the OTLP exporter to it and pass it toinstrument(). Never create a second provider. LiteLLMInstrumentor/OpenAIInstrumentorfrom OpenInference: remove them (they double-count model calls on the LiteLLM engine and record nothing on the native one).mlflow.dspy.autolog(): leave it if the user wants MLflow too, but it is not the Maple path.
- An existing
- Find where the program is called per user message (HTTP handler, CLI loop, worker). That is where the session id goes.
- Find
dspy.Parallel,dspy.Evaluate,ThreadPoolExecutor,threading.Threadaround module calls. - Find
dspy.streamify(...)calls and where they run relative todspy.configure(see Streaming in Step 3). - Check for a
dspy.Modulesubclass with an attribute namedhistory(see "Do not").