Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"REPL Environment for OpenEnv","local":"repl-environment-for-openenv","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Current Architecture","local":"current-architecture","sections":[],"depth":2},{"title":"What Works Today","local":"what-works-today","sections":[],"depth":2},{"title":"Rewards","local":"rewards","sections":[],"depth":2},{"title":"Quick Start","local":"quick-start","sections":[{"title":"Remote Server Usage","local":"remote-server-usage","sections":[],"depth":3},{"title":"Local Environment Usage","local":"local-environment-usage","sections":[],"depth":3},{"title":"Local Recursive RLM Usage","local":"local-recursive-rlm-usage","sections":[],"depth":3},{"title":"Using Different Models for Outer and Inner Loops","local":"using-different-models-for-outer-and-inner-loops","sections":[],"depth":3}],"depth":2},{"title":"Server","local":"server","sections":[],"depth":2},{"title":"API Surface","local":"api-surface","sections":[{"title":"Remote Client","local":"remote-client","sections":[],"depth":3},{"title":"Local Helpers","local":"local-helpers","sections":[],"depth":3},{"title":"Actions and Observations","local":"actions-and-observations","sections":[],"depth":3}],"depth":2},{"title":"Injected REPL Helpers","local":"injected-repl-helpers","sections":[],"depth":2},{"title":"Finalization Patterns","local":"finalization-patterns","sections":[{"title":"FINAL(...)","local":"final","sections":[],"depth":3},{"title":"FINAL_VAR(...)","local":"finalvar","sections":[],"depth":3},{"title":"answer dict","local":"answer-dict","sections":[],"depth":3}],"depth":2},{"title":"Prompt Utilities","local":"prompt-utilities","sections":[],"depth":2},{"title":"Examples","local":"examples","sections":[],"depth":2},{"title":"Environment Variables","local":"environment-variables","sections":[],"depth":2},{"title":"References","local":"references","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/openenv/pr_813/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/entry/start.9c9d6cdf.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/chunks/scheduler.2b22cead.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/chunks/singletons.b9e7e2c8.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/chunks/paths.4b396019.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/entry/app.b8b7485a.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/chunks/preload-helper.b21f837c.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/chunks/index.1a0e8013.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/nodes/0.93b1c108.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/nodes/29.886c44cf.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.f5f19e58.js"> | |
| <link rel="modulepreload" href="/docs/openenv/pr_813/en/_app/immutable/chunks/CodeBlock.640a2a71.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"REPL Environment for OpenEnv","local":"repl-environment-for-openenv","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Current Architecture","local":"current-architecture","sections":[],"depth":2},{"title":"What Works Today","local":"what-works-today","sections":[],"depth":2},{"title":"Rewards","local":"rewards","sections":[],"depth":2},{"title":"Quick Start","local":"quick-start","sections":[{"title":"Remote Server Usage","local":"remote-server-usage","sections":[],"depth":3},{"title":"Local Environment Usage","local":"local-environment-usage","sections":[],"depth":3},{"title":"Local Recursive RLM Usage","local":"local-recursive-rlm-usage","sections":[],"depth":3},{"title":"Using Different Models for Outer and Inner Loops","local":"using-different-models-for-outer-and-inner-loops","sections":[],"depth":3}],"depth":2},{"title":"Server","local":"server","sections":[],"depth":2},{"title":"API Surface","local":"api-surface","sections":[{"title":"Remote Client","local":"remote-client","sections":[],"depth":3},{"title":"Local Helpers","local":"local-helpers","sections":[],"depth":3},{"title":"Actions and Observations","local":"actions-and-observations","sections":[],"depth":3}],"depth":2},{"title":"Injected REPL Helpers","local":"injected-repl-helpers","sections":[],"depth":2},{"title":"Finalization Patterns","local":"finalization-patterns","sections":[{"title":"FINAL(...)","local":"final","sections":[],"depth":3},{"title":"FINAL_VAR(...)","local":"finalvar","sections":[],"depth":3},{"title":"answer dict","local":"answer-dict","sections":[],"depth":3}],"depth":2},{"title":"Prompt Utilities","local":"prompt-utilities","sections":[],"depth":2},{"title":"Examples","local":"examples","sections":[],"depth":2},{"title":"Environment Variables","local":"environment-variables","sections":[],"depth":2},{"title":"References","local":"references","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="repl-environment-for-openenv" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#repl-environment-for-openenv"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>REPL Environment for OpenEnv</span></h1> <p data-svelte-h="svelte-1wiagxc"><code>repl_env</code> is an OpenEnv-native Python REPL environment for Recursive Language Model style execution. It now follows the current OpenEnv client/server conventions:</p> <ul data-svelte-h="svelte-hxrrex"><li><code>REPLEnv</code> is the remote async <code>EnvClient</code></li> <li><code>.sync()</code> is the sync wrapper for remote usage</li> <li><code>LocalREPLEnv</code> is the explicit in-process helper</li> <li><code>LocalRLMRunner</code> is the higher-level orchestration loop for local recursive RLM runs</li></ul> <p data-svelte-h="svelte-id7xsr">The architecture is intentionally split the same way the official <code>rlm</code> and DSPy implementations split things:</p> <ul data-svelte-h="svelte-7yf1o7"><li>the environment executes code and exposes tools</li> <li>the runner owns the iterative prompting loop</li> <li>recursive behavior lives in backend/controller modules, not in the executor</li></ul> <h2 class="relative group"><a id="overview" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#overview"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Overview</span></h2> <p data-svelte-h="svelte-1dc1d2e">Inside the REPL, the model can:</p> <ul data-svelte-h="svelte-1qd01vt"><li>inspect <code>context</code></li> <li>execute Python code across multiple turns with persistent state</li> <li>call <code>llm_query(...)</code> and <code>llm_query_batched(...)</code></li> <li>call <code>rlm_query(...)</code> and <code>rlm_query_batched(...)</code> for recursive child runs when configured</li> <li>finish with <code>FINAL(...)</code>, <code>FINAL_VAR(...)</code>, or <code>answer = {"content": ..., "ready": True}</code></li></ul> <h2 class="relative group"><a id="current-architecture" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#current-architecture"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Current Architecture</span></h2> <p data-svelte-h="svelte-m2smw2">Main modules:</p> <ul data-svelte-h="svelte-1gupfkx"><li><a href="client.py"><code>client.py</code></a>: remote async OpenEnv client</li> <li><a href="local.py"><code>local.py</code></a>: explicit in-process local env helper</li> <li><a href="runner.py"><code>runner.py</code></a>: local RLM orchestration loop</li> <li><a href="recursive_backends.py"><code>recursive_backends.py</code></a>: direct and recursive backend implementations</li> <li><a href="recursive_controller.py"><code>recursive_controller.py</code></a>: server-side backend/broker composition</li> <li><a href="rubrics.py"><code>rubrics.py</code></a>: reward rubrics (OpenEnv RFC 004)</li> <li><a href="server/repl_environment.py"><code>server/repl_environment.py</code></a>: server-side execution environment</li> <li><a href="server/app.py"><code>server/app.py</code></a>: OpenEnv HTTP server app and env factory</li></ul> <h2 class="relative group"><a id="what-works-today" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#what-works-today"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>What Works Today</span></h2> <ul data-svelte-h="svelte-cf6q10"><li>Standard remote OpenEnv usage through <code>REPLEnv</code></li> <li>Local in-process execution through <code>LocalREPLEnv</code></li> <li>Local recursive RLM runs through <code>LocalRLMRunner</code></li> <li>Server-backed recursive calls through the current controller/broker path</li> <li>Explicit recursion controls: | |
| <ul><li><code>max_depth</code></li> <li><code>max_children_total</code></li> <li><code>max_children_per_batch</code></li> <li><code>per_child_timeout_s</code></li> <li><code>result_truncation_limit</code></li></ul></li> <li>Lightweight child trace metadata on local runner results</li> <li>Rubric-based rewards (OpenEnv RFC 004): | |
| <ul><li><code>ExactMatchRubric</code>: binary outcome reward against ground truth</li> <li><code>FuzzyMatchRubric</code>: partial credit for containment matches</li> <li><code>CustomMetricRubric</code>: user-provided <code>metric(expected, predicted) -> float</code></li> <li><code>CodeExecutionRubric</code>: per-step process reward for code errors</li> <li><code>REPLRubric</code>: composite rubric combining outcome + process</li> <li>Ground truth injectable at reset via <code>expected_answer</code></li></ul></li></ul> <h2 class="relative group"><a id="rewards" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#rewards"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Rewards</span></h2> <p data-svelte-h="svelte-14b1kcr">Rewards follow the OpenEnv Rubric system (RFC 004). The environment uses | |
| <code>REPLRubric</code> by default, which combines:</p> <ul data-svelte-h="svelte-1qsrao4"><li><strong>Outcome reward</strong> (on terminal steps): compares <code>final_answer</code> against | |
| <code>expected_answer</code> if provided. Returns 1.0 for match, 0.0 otherwise.</li> <li><strong>Process reward</strong> (on non-terminal steps): returns -0.05 for code | |
| execution errors, 0.0 for successful steps.</li> <li><strong>Failure reward</strong>: returns -0.1 when max iterations exhausted without an answer.</li></ul> <p data-svelte-h="svelte-1vzcpwu">For RL training (GRPO, etc.), pass <code>expected_answer</code> at reset time:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">with</span> LocalREPLEnv() <span class="hljs-keyword">as</span> env: | |
| env.reset( | |
| context=<span class="hljs-string">"..."</span>, | |
| task_prompt=<span class="hljs-string">"..."</span>, | |
| expected_answer=<span class="hljs-string">"42"</span>, <span class="hljs-comment"># ground truth for rubric scoring</span> | |
| ) | |
| result = env.execute(<span class="hljs-string">"print(FINAL(42))"</span>) | |
| <span class="hljs-built_in">print</span>(result.reward) <span class="hljs-comment"># 1.0 (correct)</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1qdlcvo">Custom rubrics can be injected at construction:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> repl_env <span class="hljs-keyword">import</span> LocalREPLEnv, CustomMetricRubric, REPLRubric | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">my_metric</span>(<span class="hljs-params">expected, predicted</span>): | |
| <span class="hljs-keyword">return</span> <span class="hljs-number">1.0</span> <span class="hljs-keyword">if</span> expected.strip() == predicted.strip() <span class="hljs-keyword">else</span> <span class="hljs-number">0.0</span> | |
| env = LocalREPLEnv(rubric=REPLRubric(outcome=CustomMetricRubric(my_metric)))<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="quick-start" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#quick-start"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Quick Start</span></h2> <h3 class="relative group"><a id="remote-server-usage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#remote-server-usage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Remote Server Usage</span></h3> <p data-svelte-h="svelte-1exwkxi">Async:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> asyncio | |
| <span class="hljs-keyword">from</span> repl_env <span class="hljs-keyword">import</span> REPLEnv | |
| <span class="hljs-keyword">async</span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">main</span>(): | |
| <span class="hljs-keyword">async</span> <span class="hljs-keyword">with</span> REPLEnv(base_url=<span class="hljs-string">"http://127.0.0.1:8000"</span>) <span class="hljs-keyword">as</span> env: | |
| result = <span class="hljs-keyword">await</span> env.reset( | |
| context=<span class="hljs-string">"alpha beta gamma"</span>, | |
| task_prompt=<span class="hljs-string">"Count the words"</span>, | |
| ) | |
| result = <span class="hljs-keyword">await</span> env.execute(<span class="hljs-string">"count = len(context.split())"</span>) | |
| result = <span class="hljs-keyword">await</span> env.execute(<span class="hljs-string">"print(FINAL(count))"</span>) | |
| <span class="hljs-built_in">print</span>(result.done) | |
| asyncio.run(main())<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-1dqsj3j">Sync:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> repl_env <span class="hljs-keyword">import</span> REPLEnv | |
| <span class="hljs-keyword">with</span> REPLEnv(base_url=<span class="hljs-string">"http://127.0.0.1:8000"</span>).sync() <span class="hljs-keyword">as</span> env: | |
| result = env.reset( | |
| context=<span class="hljs-string">"alpha beta gamma"</span>, | |
| task_prompt=<span class="hljs-string">"Count the words"</span>, | |
| ) | |
| result = env.execute(<span class="hljs-string">"count = len(context.split())"</span>) | |
| result = env.execute(<span class="hljs-string">"print(FINAL(count))"</span>) | |
| <span class="hljs-built_in">print</span>(result.observation.result.stdout)<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="local-environment-usage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#local-environment-usage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Local Environment Usage</span></h3> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> repl_env <span class="hljs-keyword">import</span> LocalREPLEnv | |
| <span class="hljs-keyword">with</span> LocalREPLEnv() <span class="hljs-keyword">as</span> env: | |
| result = env.reset( | |
| context=<span class="hljs-string">"The quick brown fox jumps over the lazy dog"</span>, | |
| task_prompt=<span class="hljs-string">"Count the words"</span>, | |
| ) | |
| result = env.execute(<span class="hljs-string">"count = len(context.split())"</span>) | |
| result = env.execute(<span class="hljs-string">"print(FINAL(count))"</span>) | |
| <span class="hljs-built_in">print</span>(env.state().final_answer)<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="local-recursive-rlm-usage" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#local-recursive-rlm-usage"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Local Recursive RLM Usage</span></h3> <p data-svelte-h="svelte-i6amc4"><code>LocalRLMRunner</code> takes any <code>chat_fn(messages, model=None) -> str</code>. It works | |
| with HF Inference API, vLLM, SGLang, Ollama, or any OpenAI-compatible server.</p> <p data-svelte-h="svelte-1182ypr">With HF Inference API:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient | |
| <span class="hljs-keyword">from</span> repl_env <span class="hljs-keyword">import</span> LocalRLMRunner, RLM_SYSTEM_PROMPT | |
| client = InferenceClient(model=<span class="hljs-string">"Qwen/Qwen3.5-9B"</span>, timeout=<span class="hljs-number">300</span>) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">chat_fn</span>(<span class="hljs-params">messages, model=<span class="hljs-literal">None</span></span>): | |
| response = client.chat.completions.create( | |
| model=model <span class="hljs-keyword">or</span> <span class="hljs-string">"Qwen/Qwen3.5-9B"</span>, | |
| messages=messages, | |
| max_tokens=<span class="hljs-number">2048</span>, | |
| temperature=<span class="hljs-number">0.6</span>, | |
| extra_body={<span class="hljs-string">"chat_template_kwargs"</span>: {<span class="hljs-string">"enable_thinking"</span>: <span class="hljs-literal">False</span>}}, | |
| ) | |
| <span class="hljs-keyword">return</span> response.choices[<span class="hljs-number">0</span>].message.content | |
| runner = LocalRLMRunner(chat_fn, max_iterations=<span class="hljs-number">30</span>, max_depth=<span class="hljs-number">2</span>) | |
| result = runner.run(<span class="hljs-string">"The answer is 42"</span>, <span class="hljs-string">"What number is mentioned?"</span>) | |
| <span class="hljs-built_in">print</span>(result.final_answer)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-130vp32">With a local vLLM server:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI | |
| <span class="hljs-keyword">from</span> repl_env <span class="hljs-keyword">import</span> LocalRLMRunner | |
| client = OpenAI(base_url=<span class="hljs-string">"http://localhost:8000/v1"</span>, api_key=<span class="hljs-string">"unused"</span>) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">chat_fn</span>(<span class="hljs-params">messages, model=<span class="hljs-literal">None</span></span>): | |
| response = client.chat.completions.create( | |
| model=model <span class="hljs-keyword">or</span> <span class="hljs-string">"Qwen/Qwen3.5-9B"</span>, | |
| messages=messages, | |
| max_tokens=<span class="hljs-number">2048</span>, | |
| temperature=<span class="hljs-number">0.6</span>, | |
| ) | |
| <span class="hljs-keyword">return</span> response.choices[<span class="hljs-number">0</span>].message.content | |
| runner = LocalRLMRunner(chat_fn, max_iterations=<span class="hljs-number">30</span>, max_depth=<span class="hljs-number">2</span>) | |
| result = runner.run(context, task)<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="using-different-models-for-outer-and-inner-loops" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#using-different-models-for-outer-and-inner-loops"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Using Different Models for Outer and Inner Loops</span></h3> <p data-svelte-h="svelte-8zj4v4">The outer loop (code generation) can use a large model while inner | |
| <code>llm_query</code>/<code>rlm_query</code> calls use a smaller, faster model. Pass a | |
| custom <code>backend_factory</code> to the runner:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI | |
| <span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient | |
| <span class="hljs-keyword">from</span> repl_env <span class="hljs-keyword">import</span> LocalRLMRunner | |
| <span class="hljs-keyword">from</span> repl_env.recursive_backends <span class="hljs-keyword">import</span> BackendLimits, LocalChildRLMBackend | |
| <span class="hljs-comment"># Outer loop: large local model via vLLM</span> | |
| vllm = OpenAI(base_url=<span class="hljs-string">"http://localhost:8000/v1"</span>, api_key=<span class="hljs-string">"unused"</span>) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">outer_chat</span>(<span class="hljs-params">messages, model=<span class="hljs-literal">None</span></span>): | |
| r = vllm.chat.completions.create( | |
| model=<span class="hljs-string">"Qwen/Qwen3-32B"</span>, messages=messages, max_tokens=<span class="hljs-number">2048</span>, | |
| ) | |
| <span class="hljs-keyword">return</span> r.choices[<span class="hljs-number">0</span>].message.content | |
| <span class="hljs-comment"># Inner calls (llm_query/rlm_query): smaller HF-hosted model</span> | |
| hf = InferenceClient(model=<span class="hljs-string">"Qwen/Qwen3.5-9B"</span>) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">inner_chat</span>(<span class="hljs-params">messages, model=<span class="hljs-literal">None</span></span>): | |
| r = hf.chat.completions.create( | |
| model=model <span class="hljs-keyword">or</span> <span class="hljs-string">"Qwen/Qwen3.5-9B"</span>, messages=messages, max_tokens=<span class="hljs-number">2048</span>, | |
| extra_body={<span class="hljs-string">"chat_template_kwargs"</span>: {<span class="hljs-string">"enable_thinking"</span>: <span class="hljs-literal">False</span>}}, | |
| ) | |
| <span class="hljs-keyword">return</span> r.choices[<span class="hljs-number">0</span>].message.content | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">my_backend_factory</span>(<span class="hljs-params">llm_chat_fn, **kwargs</span>): | |
| <span class="hljs-keyword">return</span> LocalChildRLMBackend( | |
| inner_chat, <span class="hljs-comment"># inner calls use the smaller model</span> | |
| runner_factory=LocalRLMRunner, | |
| system_prompt=kwargs[<span class="hljs-string">"system_prompt"</span>], | |
| max_iterations=kwargs[<span class="hljs-string">"max_iterations"</span>], | |
| env_max_iterations_multiplier=kwargs[<span class="hljs-string">"env_max_iterations_multiplier"</span>], | |
| depth=kwargs[<span class="hljs-string">"depth"</span>], | |
| limits=BackendLimits(max_depth=<span class="hljs-number">2</span>), | |
| ) | |
| runner = LocalRLMRunner( | |
| outer_chat, <span class="hljs-comment"># outer loop: large model</span> | |
| backend_factory=my_backend_factory, <span class="hljs-comment"># inner calls: small model</span> | |
| max_iterations=<span class="hljs-number">30</span>, | |
| max_depth=<span class="hljs-number">2</span>, | |
| ) | |
| result = runner.run(context, task)<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="server" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#server"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Server</span></h2> <p data-svelte-h="svelte-1l6zkxe">Run the local server:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->PYTHONPATH=src:envs uvicorn envs.repl_env.server.app:app --host 127.0.0.1 --port 8000<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-j7wuu2">The server uses a proper OpenEnv environment factory in <a href="server/app.py"><code>server/app.py</code></a>.</p> <h2 class="relative group"><a id="api-surface" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#api-surface"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>API Surface</span></h2> <h3 class="relative group"><a id="remote-client" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#remote-client"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Remote Client</span></h3> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">class</span> <span class="hljs-title class_">REPLEnv</span>(EnvClient[REPLAction, REPLObservation, REPLState]): | |
| <span class="hljs-keyword">async</span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">reset</span>(<span class="hljs-params">...</span>) | |
| <span class="hljs-keyword">async</span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">execute</span>(<span class="hljs-params">code: <span class="hljs-built_in">str</span></span>) | |
| <span class="hljs-keyword">async</span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">submit_final_answer</span>(<span class="hljs-params">answer: <span class="hljs-built_in">str</span></span>) | |
| <span class="hljs-keyword">async</span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">state</span>()<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-h1hay9">Use <code>.sync()</code> for synchronous code.</p> <h3 class="relative group"><a id="local-helpers" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#local-helpers"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Local Helpers</span></h3> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">class</span> <span class="hljs-title class_">LocalREPLEnv</span>: | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">reset</span>(<span class="hljs-params">...</span>) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">execute</span>(<span class="hljs-params">code: <span class="hljs-built_in">str</span></span>) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">state</span>()<!-- HTML_TAG_END --></pre></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">class</span> <span class="hljs-title class_">LocalRLMRunner</span>: | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">run</span>(<span class="hljs-params">context: <span class="hljs-built_in">str</span>, task_prompt: <span class="hljs-built_in">str</span>, *, model: <span class="hljs-built_in">str</span> | <span class="hljs-literal">None</span> = <span class="hljs-literal">None</span></span>) -> RLMRunResult<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="actions-and-observations" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#actions-and-observations"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Actions and Observations</span></h3> <p data-svelte-h="svelte-1jb4424"><code>REPLAction</code></p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START -->code: <span class="hljs-built_in">str</span> = <span class="hljs-string">""</span> | |
| is_final: <span class="hljs-built_in">bool</span> = <span class="hljs-literal">False</span> | |
| final_answer: <span class="hljs-built_in">str</span> | <span class="hljs-literal">None</span> = <span class="hljs-literal">None</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-dnpz08"><code>REPLObservation</code></p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START -->result: CodeBlockResult | |
| context_preview: <span class="hljs-built_in">str</span> | <span class="hljs-literal">None</span> | |
| context_length: <span class="hljs-built_in">int</span> | |
| available_variables: <span class="hljs-built_in">list</span>[<span class="hljs-built_in">str</span>] | |
| iteration: <span class="hljs-built_in">int</span> | |
| max_iterations: <span class="hljs-built_in">int</span> | |
| done: <span class="hljs-built_in">bool</span> | |
| reward: <span class="hljs-built_in">float</span> | <span class="hljs-literal">None</span> | |
| metadata: <span class="hljs-built_in">dict</span><!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="injected-repl-helpers" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#injected-repl-helpers"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Injected REPL Helpers</span></h2> <p data-svelte-h="svelte-8y9q5s">When configured, the REPL namespace exposes:</p> <ul data-svelte-h="svelte-1lvakkv"><li><code>llm_query(prompt, model=None)</code></li> <li><code>llm_query_batched(prompts, model=None)</code></li> <li><code>rlm_query(prompt, model=None)</code></li> <li><code>rlm_query_batched(prompts, model=None)</code></li> <li><code>FINAL(value)</code></li> <li><code>FINAL_VAR(name)</code></li> <li><code>SHOW_VARS()</code></li></ul> <p data-svelte-h="svelte-1biq3pv">Notes:</p> <ul data-svelte-h="svelte-1i1srng"><li><code>rlm_query</code> is the recursive child-run surface.</li> <li>At max recursion depth, recursion falls back to direct LM calls rather than spawning more children.</li> <li>Lifecycle callbacks follow the official <code>rlm</code> pattern: | |
| <ul><li><code>on_subcall_start(depth, model, prompt_preview)</code></li> <li><code>on_subcall_complete(depth, model, duration, error_or_none)</code></li></ul></li></ul> <h2 class="relative group"><a id="finalization-patterns" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#finalization-patterns"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Finalization Patterns</span></h2> <h3 class="relative group"><a id="final" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#final"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>FINAL(...)</span></h3> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START -->result = env.execute(<span class="hljs-string">"answer = 42"</span>) | |
| result = env.execute(<span class="hljs-string">"print(FINAL(answer))"</span>)<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="finalvar" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#finalvar"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>FINAL_VAR(...)</span></h3> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START -->result = env.execute(<span class="hljs-string">"my_answer = '42'"</span>) | |
| result = env.execute(<span class="hljs-string">'print(FINAL_VAR("my_answer"))'</span>)<!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="answer-dict" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#answer-dict"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>answer dict</span></h3> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START -->result = env.execute(<span class="hljs-string">"answer['content'] = '42'"</span>) | |
| result = env.execute(<span class="hljs-string">"answer['ready'] = True"</span>)<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="prompt-utilities" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#prompt-utilities"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Prompt Utilities</span></h2> <p data-svelte-h="svelte-mxil3m"><a href="prompts.py"><code>prompts.py</code></a> contains the current message-building and parsing helpers used by the examples and runner.</p> <p data-svelte-h="svelte-qfcdmz">Important exports:</p> <ul data-svelte-h="svelte-9fo0l2"><li><code>RLM_SYSTEM_PROMPT</code></li> <li><code>RLM_SYSTEM_PROMPT_QWEN</code></li> <li><code>QueryMetadata</code></li> <li><code>build_rlm_system_prompt(...)</code></li> <li><code>build_user_prompt(...)</code></li> <li><code>extract_code_blocks(...)</code></li> <li><code>format_observations(...)</code></li></ul> <p data-svelte-h="svelte-qfsf2j">These prompts were updated to reflect the actual helper surface the environment provides, rather than documenting tools that do not exist.</p> <h2 class="relative group"><a id="examples" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#examples"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Examples</span></h2> <ul data-svelte-h="svelte-lp5oz8"><li><a href="../../examples/repl_with_llm.py"><code>examples/repl_with_llm.py</code></a></li> <li><a href="../../examples/repl_oolong_simple.py"><code>examples/repl_oolong_simple.py</code></a></li></ul> <p data-svelte-h="svelte-1xx94wb">Default hosted model in the examples is currently <code>Qwen/Qwen3.5-9B</code>, but real hosted inference still depends on provider availability and token access.</p> <h2 class="relative group"><a id="environment-variables" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#environment-variables"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Environment Variables</span></h2> <p data-svelte-h="svelte-6c4o9o">Server-side configuration in <a href="server/app.py"><code>server/app.py</code></a>:</p> <ul data-svelte-h="svelte-19ynzkt"><li><code>LLM_MODEL</code></li> <li><code>HF_TOKEN</code></li> <li><code>REPL_MAX_ITERATIONS</code></li> <li><code>REPL_MAX_OUTPUT_LENGTH</code></li> <li><code>REPL_CONTEXT_PREVIEW_LENGTH</code></li> <li><code>REPL_RLM_MAX_DEPTH</code></li> <li><code>REPL_RLM_MAX_ITERATIONS</code></li></ul> <h2 class="relative group"><a id="references" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#references"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>References</span></h2> <ul data-svelte-h="svelte-15rbvtq"><li><a href="https://huggingface.co/papers/2512.24601" rel="nofollow">RLM Paper (arXiv:2512.24601)</a></li> <li><a href="https://github.com/alexzhang13/rlm" rel="nofollow">RLM Implementation</a></li> <li><a href="https://alexzhang13.github.io/blog/2025/rlm/" rel="nofollow">Alex Zhang’s RLM Blog</a></li> <li><a href="https://www.primeintellect.ai/blog/rlm" rel="nofollow">Prime Intellect RLM Blog</a></li></ul> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/openenv/blob/main/docs/source/environments/repl.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_1l28dw0 = { | |
| assets: "/docs/openenv/pr_813/en", | |
| base: "/docs/openenv/pr_813/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/openenv/pr_813/en/_app/immutable/entry/start.9c9d6cdf.js"), | |
| import("/docs/openenv/pr_813/en/_app/immutable/entry/app.b8b7485a.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 29], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 79.8 kB
- Xet hash:
- 69a7686e469e023c21e44091442f5cbb03603faf04b2c00896976c2e59a68de7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.