datarobot_genai.drtools.core.sandbox.protocol
protocol
Wire contract between the caller and the container runner.
The runner that executes user code inside the sandbox image is owned by
datarobot/datarobot-user-models (public_dropin_environments/
dr_mcp_execute_sandbox_minimal/runner.py, PR
datarobot/datarobot-user-models#2137). That runner and this module are the
two ends of a small protocol used by the container-backed sandbox
(:class:DataRobotWorkloadSandbox):
- The runner emits its return value as a final stdout line prefixed with
:data:
RESULT_MARKER; :func:parse_result_markerstrips and decodes it. - The runner exits :data:
SANDBOX_TIMEOUT_EXIT_CODEwhen its in-process wall-clock cap fires; the caller maps that toSandboxTimeout.
Only these constants + the parser are shared, so we keep them here rather than carrying a hand-synced duplicate of the whole runner in this repo (the runner body would inevitably drift from the image copy).
has_result_marker
Whether stdout contains a result-marker line (see :func:parse_result_marker).
parse_result_marker
Split the result marker off stdout.
Returns (clean_stdout, return_value): the last line that starts with
:data:RESULT_MARKER is removed from the returned stdout and its JSON
payload is decoded as the return value (None on decode failure). When no
marker line is present, stdout is returned unchanged with a None value.