Skip to content

Background exec sessions silently killed after ~30 minutes (SIGTERM on compaction) #23303

@vksvikas

Description

@vksvikas

Summary

Background exec sessions launched via the exec tool with background: true are silently terminated (SIGTERM) after approximately 30 minutes. This appears to happen both on context compaction and potentially via a hard timeout.

Reproduction Steps

  1. Launch a long-running background exec:
    exec({ command: "while true; do echo tick; sleep 300; done", background: true })
    
  2. Continue chatting normally for 30+ minutes
  3. Check process status — session shows failed with signal SIGTERM

Observed Behavior

  • All background exec sessions die at approximately the 30-minute mark with SIGTERM
  • Multiple processes killed simultaneously, suggesting compaction is the trigger
  • Exec failed (session-id, signal SIGTERM) notifications arrive bundled with the next user message, not as real-time events
  • The agent cannot proactively restart failed processes since it only "wakes" on user messages, cron jobs, or heartbeats

Real-World Impact

I was running:

  1. Batch audio transcription (Whisper processing 930 .wav files, ~20 min job) — killed 3 times
  2. Tesla location polling loop (every 5 min) — killed repeatedly
  3. Both had to be restarted manually by the user noticing and asking

Expected Behavior

  • Background exec sessions should survive context compaction
  • Or: a configurable maxDurationMs parameter should allow agents to set longer timeouts
  • Or: exec failure should trigger an agent turn so the agent can self-heal

Current Workaround

Launch processes as fully detached OS processes:

nohup bash /path/to/script.sh > /tmp/output.log 2>&1 &

This works but loses all integration with the process tool (log, poll, kill).

Related Issues

Proposed Solutions

  1. Compaction-safe exec: Don't SIGTERM background processes on compaction. Re-attach them to the new context.
  2. Configurable timeout: Add maxDurationMs parameter to exec tool for known long-running tasks.
  3. Failure callbacks: Exec failures should optionally trigger an agent turn for self-healing.

Environment

  • OpenClaw version: 2026.2.17
  • OS: macOS (Apple Silicon, M-series)
  • Model: Claude Opus 4
  • Shell: zsh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions