Skip to content

Conversation

@satyadevai
Copy link
Collaborator

@satyadevai satyadevai commented Dec 10, 2025

Closes #1063


Note

Track and restore all wrapt-patched DSPy methods to properly uninstrument; add tests and update example to demonstrate uninstrumentation.

  • Instrumentation (DSPy):
    • Add _wrap_object to track all wrapped targets and store originals.
    • Implement unwrap_object using resolve_path/apply_patch to restore originals.
    • Update _instrument to use _wrap_object across all DSPy targets; update _uninstrument to reverse-unpatch all tracked methods.
  • Tests:
    • Add test_uninstrument to verify all instrumented methods are unwrapped.
  • Example:
    • Update examples/lm.py to use gpt-4.1, guard with __main__, and demonstrate uninstrument() behavior.

Written by Cursor Bugbot for commit c99fb9b. This will update automatically on new commits. Configure here.

@satyadevai satyadevai force-pushed the 1063-dspy-uninstrumentation branch from 721a8ab to 18cf0f2 Compare December 12, 2025 12:44
@satyadevai satyadevai marked this pull request as ready for review December 12, 2025 18:18
@satyadevai satyadevai requested a review from a team as a code owner December 12, 2025 18:18
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 12, 2025
lm = LM("openai/gpt-4.1")
output = lm("hello!")
print(f"{output=}")
DSPyInstrumentor().uninstrument()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect users to explicitly call the uninstrument() method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this isn’t expected in normal usage. The uninstrument() call is used here purely for testing, to validate that uninstrumentation works correctly or not.

Copy link
Collaborator

@caroger caroger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please respond to/address all review comments (including cursor bots) before marking them resolved.

@satyadevai satyadevai force-pushed the 1063-dspy-uninstrumentation branch from 8d2c567 to c99fb9b Compare December 19, 2025 14:10
@satyadevai satyadevai requested a review from caroger December 19, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[bug][dspy] uninstrument does not run properly

2 participants