INNER CODE UNIT · Python

eval_code

deeplethe/forkd · sdk/mcp/sandstorm_mcp/server.py:349

def eval_code(
    sandbox_id: str,
    code: str,
    sandbox_token: str | None = None,
    timeout_secs: int = 30,
) -> dict[str, Any]:
    """Run a code snippet in a sandbox and return what it printed.

    The snippet runs with the template's eval_argv, python3 -c by default, in
    a fresh process. Only printed output comes back, so use print(2+2), not a
    bare expression.

    sandbox_token: Token from the creation response; required by v0.6.

    Returns: {result, exit_code}, or {error, exit_code} if it failed.
    """
    body = {"code": code, "timeout_secs": timeout_secs}
    with _client(sandbox_token, _command_timeout(timeout_secs)) as c:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…