@@ -152,7 +152,7 @@ def respond():
152152# =============================================================================
153153
154154
155- def _build_exec_script (code : str , broker_port : int = 8080 ) -> str :
155+ def _build_exec_script (code : str , broker_port : int = 8080 , depth : int = 1 ) -> str :
156156 """
157157 Build a script that executes code with state persistence.
158158 LLM queries go through the local broker server.
@@ -185,7 +185,7 @@ def llm_query(prompt, model=None):
185185 try:
186186 response = requests.post(
187187 f"{{BROKER_URL}}/enqueue",
188- json={{"type": "single", "prompt": prompt, "model": model}},
188+ json={{"type": "single", "prompt": prompt, "model": model, "depth": { depth } }},
189189 timeout=300,
190190 )
191191 data = response.json()
@@ -201,7 +201,7 @@ def llm_query_batched(prompts, model=None):
201201 try:
202202 response = requests.post(
203203 f"{{BROKER_URL}}/enqueue",
204- json={{"type": "batched", "prompts": prompts, "model": model}},
204+ json={{"type": "batched", "prompts": prompts, "model": model, "depth": { depth } }},
205205 timeout=300,
206206 )
207207 data = response.json()
@@ -329,6 +329,8 @@ def __init__(
329329 lm_handler_address : tuple [str , int ] | None = None ,
330330 context_payload : dict | list | str | None = None ,
331331 setup_code : str | None = None ,
332+ persistent : bool = False ,
333+ depth : int = 1 ,
332334 ** kwargs ,
333335 ):
334336 """
@@ -347,9 +349,15 @@ def __init__(
347349 lm_handler_address: (host, port) tuple for LM Handler server.
348350 context_payload: Initial context to load into the environment.
349351 setup_code: Optional code to run during setup.
352+ persistent: Whether to persist state across calls (not yet supported).
353+ depth: Depth level for LLM request routing (used by LMHandler).
350354 **kwargs: Additional arguments passed to base class.
351355 """
352- super ().__init__ (** kwargs )
356+ if persistent :
357+ raise NotImplementedError (
358+ "Persistent REPLs are currently not supported for environment: DaytonaREPL"
359+ )
360+ super ().__init__ (persistent = persistent , depth = depth , ** kwargs )
353361
354362 self .api_key = api_key or os .getenv ("DAYTONA_API_KEY" )
355363 self .target = target
@@ -489,7 +497,7 @@ def _handle_llm_request(self, req_data: dict) -> dict:
489497
490498 if req_type == "single" :
491499 prompt = req_data .get ("prompt" )
492- request = LMRequest (prompt = prompt , model = model )
500+ request = LMRequest (prompt = prompt , model = model , depth = self . depth )
493501 response = send_lm_request (self .lm_handler_address , request )
494502
495503 if not response .success :
@@ -503,7 +511,9 @@ def _handle_llm_request(self, req_data: dict) -> dict:
503511
504512 elif req_type == "batched" :
505513 prompts = req_data .get ("prompts" , [])
506- responses = send_lm_request_batched (self .lm_handler_address , prompts , model = model )
514+ responses = send_lm_request_batched (
515+ self .lm_handler_address , prompts , model = model , depth = self .depth
516+ )
507517
508518 results = []
509519 for resp in responses :
@@ -539,7 +549,7 @@ def execute_code(self, code: str) -> REPLResult:
539549 self .pending_llm_calls .clear ()
540550
541551 # Build and execute the script
542- script = _build_exec_script (code , self .BROKER_PORT )
552+ script = _build_exec_script (code , self .BROKER_PORT , self . depth )
543553
544554 # Upload the script as a temporary file
545555 script_path = "/tmp/rlm_exec_script.py"
0 commit comments