Skip to main content

Module runtime

Module runtime 

Source
Expand description

Long-lived Python REPL runtime.

One Python subprocess lives for the duration of an RLM turn (or an inline repl block sequence in the agent loop). Code blocks are sent over stdin framed by __RLM_RUN__/__RLM_END__ sentinels; the bootstrap exec()s them into the same global namespace so variables, imports, and even open file handles persist naturally across rounds.

Sub-LLM helpers (sub_query, sub_query_batch, sub_rlm, plus legacy llm_query, llm_query_batched, rlm_query, rlm_query_batched) are wired through a stdin/stdout RPC protocol: Python emits __RLM_REQ_<sid>__::{json} on stdout, Rust dispatches the request and writes __RLM_RESP_<sid>__::{json} back on stdin. No HTTP sidecar, no temp ports — the same pipes carry both control and data.

The session id (<sid>) is a UUID generated per spawn, so user output that happens to contain “REQ” or “FINAL” can’t be confused with control messages.

Structs§

BatchResp
PythonRuntime
Long-lived Python REPL.
ReplRound
Result of executing one code block.
SingleResp

Enums§

RpcRequest
One RPC request emitted by Python during a round.
RpcResponse
Response for one RPC request.

Traits§

RpcDispatcher
Trait-object handle for dispatching Python RPCs back into Rust.