Manage async code runs and files produced by code execution.
Queued async code run creation, waiting, and cancellation are not part of the
hosted private beta launch surface. Remote host-agent routing for queued code
runs is not implemented yet, so use machine.run_code() or
machine.code_interpreter.run_code() for hosted beta workloads.
list_runs() is available for read-only hosted beta inspection. The mutation
snippets below document the queued-run API shape for local/self-hosted control
planes that can route the assigned runtime host. They are not acceptance
criteria for hosted private beta.
Future queued run mutations
ctx = machine.code_interpreter.create_code_context(cwd="/workspace")run = machine.code_interpreter.create_run( "import time\nfor i in range(5): time.sleep(1)\nprint('done')", context=ctx, timeout=60,)print(run.id, run.status)
Wait or cancel
current = machine.code_interpreter.get_run(run.id)print(current.status)finished = machine.code_interpreter.wait_for_run(run.id, timeout_secs=120)print(finished.status)# machine.code_interpreter.cancel_run(run.id)
List runs
page = machine.code_interpreter.list_runs(status="succeeded", limit=20)for item in page["items"]: print(item.id, item.status)
nullspace machine code run-job list mch_123 --status succeeded --limit 20
list_artifacts() returns paginated raw artifact dictionaries. Use
get_artifact() for a typed CodeArtifact, and use download_artifact() or
preview_artifact() for bytes.