[opentelemetry-instrumentation-genai-dspy] Support copy and deepcopy on wrapped DSPy methods - #591
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Adds copy.copy / copy.deepcopy support for DSPy callables after they’ve been wrapped for OpenTelemetry tracing, to keep DSPy compilation/optimizers working without ObjectProxy deepcopy errors.
Changes:
- Introduces custom copy/deepcopy-capable wrapt wrappers and switches patching to use them.
- Adds unit tests covering copying/deepcopying wrapped
Toolcallables andReActmethods (including async when available). - Adds a changelog entry documenting the new compatibility behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| instrumentation/opentelemetry-instrumentation-genai-dspy/tests/test_instrumentor.py | Adds regression tests asserting wrapped DSPy callables can be copied/deepcopied (sync + async). |
| instrumentation/opentelemetry-instrumentation-genai-dspy/src/opentelemetry/instrumentation/genai/dspy/patch.py | Implements copyable/deepcopyable wrapper classes and replaces wrapping mechanism. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/.changelog/591.added | Documents the added copy/deepcopy compatibility. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ab574dd to
31c01ef
Compare
Pull request dashboard statusWaiting on reviewers · refreshed 2026-09-04 14:32 UTC Review the latest changes. Also blocked by: Merge conflicts. Status above doesn't look right?
|
opentelemetry-instrumentation-genai-dspy] Support copy and deepcopy on wrapped DSPy methods
Assisted-by: Antigravity
Assisted-by: Antigravity
Assisted-by: Antigravity
Assisted-by: Antigravity
31c01ef to
8cd8c38
Compare
Implements copy and deepcopy support on wrapped DSPy functions and bound methods.
DSPy optimizers and teleprompters (such as
dspy.compile,BootstrapFewShot, andMIPRO) rely heavily oncopy.copyandcopy.deepcopyto clone module trees and bound method callables during prompt optimization. Without custom wrapper copy handlers, copying wrapped DSPy callables raisesNotImplementedError: object proxy must define __deepcopy__().Type of change
Checklist