Learning resourcesReviewed · E2B

E2B DSPy RLMs

E2B's DSPy RLMs guide teaches Python developers to run AI-written code in a cloud sandbox, but its two reported example runs do not establish reliability. It connects DSPy 3.4.0 to E2B through a locally installed E2BInterpreter, with persistent CPython and SQLite state, host-side model tools and execution deadlines.

Researched 23 Nov 2026

In short.

E2B's DSPy RLMs guide is a tutorial for Python developers building AI data-analysis tools, but its cloud dependencies and two reported example runs leave production reliability unknown. The example combines persistent CPython and SQLite, host-side model calls, checked output fields and explicit execution deadlines. The page reports matching fixture answers for an eight-record input and an input with 50,000 additional records, without establishing general accuracy or guaranteed timings. Costs, licensing and compatibility beyond the documented setup are unknown.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete documentation page at [https://docs.e2b.dev/agents/dspy.md], including setup, embedded examples, reported results, request budgets, lifecycle behavior and failure caveats. Linked repository files, the cookbook README, DSPy documentation, model documentation and the documentation index are excluded. No code was executed. Operational behavior, current availability, pricing and licensing have not been independently established.

The overview

identity

This E2B documentation page explains how to connect DSPy's RLM module to remote Python execution [https://docs.e2b.dev/agents/dspy.md]. An RLM lets a model inspect inputs through generated Python, ask sub-models about selected passages and submit an answer with defined output fields.

The accompanying E2BInterpreter belongs to a local cookbook project [https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/dspy-rlms-python]. The page explicitly says it is neither a native DSPy import nor a separately published PyPI package. The linked project's files are outside the available evidence.

assessment

The guide is useful when an AI workflow needs persistent Python state, SQLite queries or standard CPython capabilities such as subprocess. It explains the boundaries between generated code, remote execution and host-side model calls, including how execution failures and cleanup are handled.

Its evidence supports a concrete integration example. The two source-reported runs do not establish dependable classification, general large-input performance or production readiness. Runtime behavior has not been independently assessed.

users

The clearest audience is Python developers building DSPy workflows that combine exact data queries with model judgments. The incident-analysis example shows a useful division of work: SQL selects records and counts results, while model sub-queries classify incident descriptions.

Beginners receive installation steps and a small SQLite example that needs no model request. They should still be comfortable managing Python environments, API credentials and remote resources. Developers needing local-only processing should account for the documented transfer of code and inputs to E2B and prompts to the model provider.

capabilities

Within one invocation, imports, generated variables, files and SQLite connections persist across execution steps. Supplied input variables are freshly assigned each step. Each invocation receives a fresh interpreter and its own sandbox, including concurrent invocations.

Generated Python can call llm_query and llm_query_batched through host-side tools and submit structured results with SUBMIT. The example uses a sandbox without outbound networking, pandas, numpy or a custom template.

The larger-input option adds 50,000 locally generated background records. The four high-severity candidates remain unchanged, so this demonstrates exploration of more records without increasing the candidate classification workload.

Using it

requirements

The documented setup uses Python 3.10–3.14, uv and a clone of the E2B cookbook. The local project pins DSPy to 3.4.0 and core E2B to 2.53.1 in its lockfile.

The full example requires E2B_API_KEY and OPENAI_API_KEY in a local .env file. The page names openai/gpt-5.6-luna as the default MODEL and configures temperature=None and max_tokens=16000. Changing MODEL changes only the identifier; other models may require different parameters in main.py. Their compatibility and the named model's current availability are not established.

mechanism

DSPy asks the action model to write Python, sends that code to the sandbox and uses execution output to inform the next step. Persistent state lets later steps reuse earlier imports, variables and database connections.

Model-tool wrappers send JSON requests with identifiers through the worker's standard output. The host validates the request, invokes the registered callable and returns a matching reply through standard input. Model-provider requests therefore originate on the host, where credentials remain.

Generated code eventually calls SUBMIT with the answer fields. DSPy parses and validates those fields against the signature; validation errors can provide feedback for another step. These checks address output structure and types, while semantic correctness requires separate assessment.

setup

The documented sequence is to clone the cookbook repository [https://github.com/e2b-dev/e2b-cookbook], enter examples/dspy-rlms-python, run uv sync --frozen, copy .env.example to .env and supply the required keys and model identifier. To reuse E2BInterpreter elsewhere, the page describes installing that local project with pip install /path/to/e2b-cookbook/examples/dspy-rlms-python.

The supplied check_sqlite.py example creates an in-memory database across several execute calls and checks region counts. It requires E2B_API_KEY and contacts E2B, but makes no model request. The documented RLM entry point is uv run main.py; adding --background-records 50000 selects the larger input.

Manual interpreter use places shutdown() in a finally block. DSPy's documented invocation lifecycle also calls shutdown() in finally. No installation or execution is included in this assessment.

example

The worked task selects resolved, high-severity incidents for the inference service, classifies which describe queue buildup and counts those incidents by region. Its signature defines candidate_ids, queue_incident_ids, counts_by_region and a short summary.

The fixture has four SQL candidates: INC-001, INC-002, INC-004 and INC-006. Its queue labels identify INC-001, INC-004 and INC-006, with counts of two for eu and one for us. The published larger-input trajectory excludes INC-002 because model loading failed before requests could enter the scheduler.

The example saves the answer, assessment and native trajectory in result.json. Its structural check and fixture-label comparison are separate: correct filtering and counts for submitted IDs can coexist with an incorrect classification. A deterministic assessment failure raises an error while retaining the answer and diagnostics.

Assessment & evidence

limitations

The example gives each code execution a 120-second deadline, including time waiting for host tools; the adapter default is 60 seconds. The default sandbox lifetime is 600 seconds and refreshes at execution boundaries. Model thinking between executions consumes that lifetime, and expiry fails without automatic recreation or replay.

Syntax and generated-code errors are recoverable. Setup, transport, worker-death and deadline errors terminate the session and trigger sandbox cleanup. Printed output may be truncated; oversized ordinary expression results and tool arguments produce recoverable feedback. Oversized structured submissions terminate the session, and final fields are never truncated.

Deleting the sandbox cannot stop an already running host callable or provider request. Host tools need their own argument validation, restrictions and deadlines. Following a host crash, resource reconciliation is still necessary: expiry is a backstop, not evidence that deletion occurred. The demonstrated model behavior does not guarantee compliance with execution instructions.

reasoning

The design provides a useful separation between exact operations and interpretation. SQL can express eligibility rules and aggregation directly, while model calls handle the meaning of selected incident descriptions. Persistent state lets generated code reuse intermediate work across steps.

This supports an inspectable prototype, but correctness depends on both the generated code and the classifications. Structural validation can accept an answer whose chosen labels are wrong. Inspecting the trajectory and checking labels against representative records are therefore necessary to judge suitability for a particular task.

alternatives

The page's direct comparison is DSPy's default Python interpreter, which it describes as using local Deno/Pyodide WebAssembly isolation and supporting input inspection without placing the whole input in the prompt. It states that the DSPy 3.4.0 default interpreter has no code-execution timeout.

E2B supplies remote Linux with full CPython, sqlite3 and subprocess, plus an enforced execution deadline. This comparison helps explain the integration's purpose. The page does not establish comparative accuracy, throughput, costs or behavior in other DSPy versions, and it does not assess other sandbox providers.

evidence

The evidence is the complete E2B documentation page [https://docs.e2b.dev/agents/dspy.md], including its embedded code, reported observations and lifecycle caveats. Linked code, documentation and model information have not been examined.

The page reports one run of each configuration: 19 seconds and three RLM steps for eight records, and 30 seconds and five steps with 50,000 additional records. It reports matching candidate IDs, region counts and fixture labels in both. These are source-reported observations, not independently reproduced results or reliability estimates.

Both reported runs used Python 3.14, DSPy 3.4.0, E2B 2.53.1 and the named default model. The larger input retained the same four candidates, which limits conclusions about harder classification workloads or arbitrary long-context quality.

Access & freshness

costs

Prices, billable usage, token consumption and total run costs are unknown. The full example uses E2B and a model provider; the SQLite-only example uses E2B without a model request. The page provides no pricing or free-tier entitlement.

The configuration caps action iterations at six and sub-queries at four. DSPy may make an additional extraction request if the model does not submit. Provider requests have a 20-second timeout, no SDK retries or adapter fallback retries, and a 16,000 completion-token budget including reasoning tokens. These are usage controls, not a stated monetary spending cap.

rights

The page supplies no license text establishing permissions to modify or redistribute the adapter, cookbook files or documentation. Those rights are unknown from this evidence; a repository link alone does not establish them.

API keys remain on the host, but generated code and selected inputs go to E2B, while prompts and passages used in model sub-queries go to the provider. The page advises supplying only data those services may process. Data retention, residency and contractual terms are not described.

freshness

The page was captured at 2026-11-23T15:05:45.428Z. Its instructions and observations describe the pinned DSPy 3.4.0 and E2B 2.53.1 setup.

Publication and last-update dates are not provided. Current package releases, ongoing maintenance, model availability and compatibility with newer dependencies are unknown. The capture date identifies the documentation snapshot, rather than confirming that every dependency remains available or unchanged.

actions

Before adopting the example, establish current service prices, model availability, license permissions and acceptable data handling. Preserve the documented dependency versions for an initial evaluation, and review LM parameters when choosing another model.

For a practical evaluation, begin with the SQLite persistence example, then inspect the seed task's generated code, tool calls, submitted fields and separate semantic-label assessment. Follow with representative records whose expected classifications are known. The generated background records do not substitute for varied real tasks.

Set independent deadlines and restrictions for every host callable, verify cleanup behavior, and retain sandbox_id and dspy_session identifiers for diagnosing failures. The page points to the cookbook README for additional limits, concurrency, async behavior and recovery instructions [https://github.com/e2b-dev/e2b-cookbook/blob/main/examples/dspy-rlms-python/README.md]; those details remain unassessed here.

Evidence for this report

selected-page.txtselected · checked 2026-11-23