Skip to content

dspy/direct-forward-call

Pack Severity Fix Versions
DSPy warning none, edit by hand All versions

Calling .forward(...) directly on a dspy.Module or predictor skips Module.__call__, which breaks callbacks, MLflow tracing, dspy.track_usage, and optimizer trace capture.

result = self.respond.forward(question=question)
result = self.respond(question=question)

Attribute calls to .forward(...) on files that import dspy, excluding super().forward(...).

Invoke the sub-module or predictor directly with module(...) so DSPy runs __call__.

Calling .forward(...) directly bypasses dspy.Module.__call__ hooks, MLflow tracing, usage tracking, and optimizer trace capture. Call the module directly instead.

See all rules in the DSPy pack.