background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

Sandbox inactivity timeout stops active long-running processes

Open ajanraj opened this issue 4 months ago • 2 comments

Description

The sandbox inactivity timeout can stop a sandbox while an agent tool call is still actively running.

This occurs with long-running processes such as embedding generation. An agent may start the process and then execute a long sleep command while waiting. Because no new tool or step events are emitted during the sleep, last_activity is not refreshed.

For Slack-originated sessions, there is normally no connected web client. Once the default 10-minute inactivity threshold is reached, the control plane treats the sandbox as inactive, fails the processing message, snapshots the sandbox, and stops it—even though the command is still running.

A running process should not be classified as sandbox inactivity.

Steps to reproduce

  1. Start an agent session from Slack without opening the session in the web UI.

  2. Run a process that takes longer than 10 minutes, or execute:

    sleep 900
    
  3. Leave the process running without additional tool or step events.

  4. Wait for the default inactivity timeout.

Actual behavior

After approximately 10 minutes, the sandbox is stopped for inactivity and the active processing message is failed.

Expected behavior

The inactivity timeout should not stop a sandbox while a message or tool call is actively processing.

The existing hard execution timeout and provider sandbox lifetime can continue to protect against genuinely stuck executions.

Cause

Sandbox heartbeats update heartbeat health but intentionally do not update last_activity:

Activity is refreshed for discrete events such as step_start, step_finish, and tool_call, but not while a long-running tool remains active:

The inactivity decision applies to both ready and running sandboxes and times out when no web clients are connected:

Suggested direction

Distinguish user inactivity from execution inactivity.

While a processing message is active, either:

  • suspend the normal 10-minute inactivity timeout; or
  • treat healthy sandbox heartbeats as activity only for the duration of that processing message.

This should remain bounded by the configured execution timeout and provider sandbox lifetime so a genuinely stuck execution cannot run indefinitely.

ajanraj avatar Aug 03 '26 21:08 ajanraj

this should be resolved by: https://github.com/ColeMurray/background-agents/pull/1611

ColeMurray avatar Aug 26 '26 19:08 ColeMurray

Verified resolved on main by #1611. Processing heartbeats now refresh last_activity, idle heartbeats retain existing cleanup behavior, and the relevant unit, lifecycle/alarm, integration, and typecheck suites all pass.

open-inspect avatar Aug 26 '26 20:08 open-inspect