[Feature] Let an SDK / -p host declare its session attended, so background commands aren't stopped at 30 minutes (as in VS Code since 2.1.288)

Status Open
Reported on v2.1.288
Maintainer reply None cached
Activity 1 comment · opened Oct 6, 2026

Summary

Since 2.1.288, the background command time limit applies only to unattended sessions (-p, Agent SDK, CI, cloud); terminal, desktop and VS Code sessions have none. An SDK host has no way to say that its session is attended, so a chat UI built on the Agent SDK / -p --input-format stream-json still stops every run_in_background command at 30 minutes (2 h at most), even with a person watching the chat.

Current behaviour (read from the 2.1.291 bundle)

  • The limit applies when the session is non-interactive and is neither the desktop app nor CLAUDE_CODE_ENTRYPOINT=claude-vscode.
  • The only other way out is the host object's disableBackgroundDeadline(), which only claude mcp serve calls. No setting, environment variable or initialize option reaches it.
  • CLAUDE_CODE_SESSION_ATTENDED exists (the CLI sets it for its child processes), but the deadline does not read it.
  • So a third-party editor integration (ours is a VS Code extension that hosts Claude Code chats in its own webview) can only:
  • spoof the native panel's entrypoint, which also changes everything else that entrypoint means (telemetry, IDE integration checks); or
  • raise BASH_MAX_TIMEOUT_MS and fill in a long timeout on every background call.

We ship the second for now. It also raises the foreground maximum, and it can't cover a foreground command the CLI moves to the background later (Ctrl+B or auto-background), since no new tool call happens for that move.

Request

A supported way for an SDK host to declare its session attended, so it gets the same background-command behaviour as the VS Code panel. Any of these would work for us:

  1. Honour CLAUDE_CODE_SESSION_ATTENDED=1 in the session's own environment for the deadline check.
  2. An initialize control-request option (for example attended: true) or an SDK option that calls disableBackgroundDeadline().
  3. A setting such as backgroundTaskTimeout: "none".

Related: #80372 (background tasks stopped in long sessions, before 2.1.288).

Environment: Claude Code 2.1.291, Windows 11 and Linux, claude -p --input-format stream-json --output-format stream-json, entrypoint sdk-cli.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗