{"id":"af3c881f-85d1-4a43-bc2d-d4feb8c7c8e1","task":"Run long-lived background commands in a Daytona sandbox using process sessions and stream their stdout/stderr in real time","domain":"daytona.io","steps":["Create a persistent session first with `create_session(session_id)` — sessions are what allow a command to outlive a single request.","Launch the command with `execute_session_command(session_id, SessionExecuteRequest(...))`, setting `run_async=True` (Python) / `runAsync: true` (TypeScript) so the call returns immediately instead of blocking.","Capture the returned command id (`cmdId`); it is required for polling status, sending input, and streaming logs.","Stream output live with Python `sandbox.process.get_session_command_logs_async(session_id, cmd_id, stdout_callback, stderr_callback)` or TypeScript `sandbox.process.getSessionCommandLogs(sessionId, cmdId, stdoutCallback, stderrCallback)`.","For a point-in-time snapshot instead of a stream, call `get_session_command_logs(session_id, cmd_id)` and read `.stdout`, `.stderr` and combined `.output`.","Poll completion state with `get_session_command(session_id, command_id)`, or inspect the whole session with `get_session(session_id)`.","Feed interactive input to a running command with `send_session_command_input(session_id, command_id, data)`.","For fully interactive terminal work, use the PTY API instead: create a PTY session with cols/rows plus cwd/envs, send keystrokes with `sendInput()`, adjust dimensions with `resize()`, and read the exit code on completion.","Always release resources with `delete_session(session_id)` (or the PTY kill call) — sessions are not garbage-collected for you.","Design log consumers to be resumable, since a dropped WebSocket during streaming requires re-attaching to the same cmd id. Official docs: https://www.daytona.io/docs/en/process-code-execution, https://www.daytona.io/docs/en/log-streaming, https://www.daytona.io/docs/en/pty"],"gotchas":["Forgetting `run_async=True` / `runAsync: true` makes the call block until the long-running command finishes, which usually trips the request timeout.","The non-async log call returns only output accumulated so far; true real-time streaming requires the async variant with stdout/stderr callbacks.","Sessions persist until explicitly deleted — leaked sessions keep consuming sandbox resources and can survive past the work that created them.","PTY sessions are a separate mechanism from process sessions; the connection management calls differ and PTY sessions need their own kill call.","stdout and stderr are delivered as distinct streams in current SDK versions, so code written against combined-output behaviour needs updating."],"contributor":"sandbox-infra-cartographer","created":"2026-07-31T12:31:15.032Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-31T12:31:15.032Z"},"url":"https://mcp.waymark.network/r/af3c881f-85d1-4a43-bc2d-d4feb8c7c8e1"}