Skip to content

fix(flex): keep execution internals replaceable - #73

Draft
isaacbmiller wants to merge 1 commit into
feature/dspy-flexfrom
flex-merge-safety
Draft

fix(flex): keep execution internals replaceable#73
isaacbmiller wants to merge 1 commit into
feature/dspy-flexfrom
flex-merge-safety

Conversation

@isaacbmiller

Copy link
Copy Markdown

Summary

  • exclude the private BridgeRuntime from whole-program pickles and rebuild it from canonical module_src after loading
  • clarify that interpreter_factory creates sandbox sessions while Flex may validate/lower source and install its guest shim
  • document the exact max_predictor_calls accounting unit and interpreter-dependent Python/library availability
  • align CodeInterpreter.tools with the non-string JSON-compatible values Flex already bridges
  • mark Deno-dependent Flex tests correctly and fix the existing Flex test lint violation

This draft is based on an exact mirror of Michael’s michaelisaac-dev/dspy:feature/dspy-flex head at b27168a (stanfordnlp/dspy#10047). GitHub’s integration does not have PR-write access to Michael’s fork, so the clean stacked diff is hosted in cmpnd-ai/dspy for review and can be applied directly to Michael’s branch.

The change preserves interpreter_factory as the public execution hook without adding a premature backend/runtime abstraction, while avoiding persistence and documentation contracts that would block a later Monty-compatible source compiler and shim.

Verification

  • 172 passed, 165 skipped (Deno is not installed in the orb)
  • Ruff passed for Flex, CodeInterpreter, GEPA Flex integration, and Flex tests
  • git diff --check passed
  • Python compilation passed

Prepared by Isaac Miller.

Exclude the private bridge from whole-program persistence and rebuild it from canonical source after loading.

Clarify interpreter and predictor-budget contracts so future source lowering and alternate CodeInterpreter implementations remain compatible.
Comment thread dspy/flex/flex.py
return state

def __setstate__(self, state: dict[str, Any]) -> None:
state.pop("_bridge", None) # Ignore bridges persisted by prerelease versions.

@michaelisaac-dev michaelisaac-dev Jul 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need this? There are no old Flex pickles out there anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants