Let a stream-json host declare an attended session, so background commands have no time limit

Status Open
Reported on v2.1.288
Maintainer reply None cached
Activity 0 comments · opened Oct 13, 2026

Problem

2.1.288 limited the background-command time limit to unattended sessions: "-p, Agent SDK, CI, cloud; terminal, desktop app and VS Code sessions have no limit".

An IDE extension that hosts Claude Code has to start the CLI with -p --input-format stream-json --output-format stream-json. A person drives that session the same way they drive the VS Code extension. The CLI still treats it as unattended: a dev server or a watcher that Claude starts with run_in_background stops after 30 minutes, and no timeout can keep it longer than 2 hours.

I contribute to such a host for Visual Studio (VsAgentic, https://github.com/adospace/vs-agentic, issue adospace/vs-agentic#110). As far as I can read the 2.1.296 binary, a host has only two ways to change this:

  • CLAUDE_CODE_ENTRYPOINT=claude-vscode. This removes the limit, but many other code paths read the value (telemetry attribution, feature gates, the AskUserQuestion preview format, artifact links). A different host must not claim to be the VS Code extension.
  • BASH_MAX_TIMEOUT_MS. This raises the maximum. The 30-minute default stays, so the model must know to ask for more. BASH_DEFAULT_TIMEOUT_MS also changes the foreground default, as #100648 notes.

claude mcp serve can turn the limit off internally (backgroundDeadlineDisabled), but nothing exposes that switch to a stream-json host.

Reproduction (2.1.296, Windows)

Prompt: run sleep 60 with run_in_background: true and timeout: 10000, then run a 40-second foreground loop.

  • claude -p … --output-format stream-json --verbose: task_notification with status: "stopped", "stopped after reaching its background time limit".
  • The same run with CLAUDE_CODE_ENTRYPOINT=claude-vscode: status: "completed" after 60 s.

For the second run, CLAUDECODE and CLAUDE_CODE_CHILD_SESSION must be unset. If they are inherited from a parent Claude Code session, the VS Code exemption does not apply.

Request

A supported way for a host to declare that a person is attending the session, independent of the entrypoint. Any of these would work:

  • a CLI flag, for example --attended
  • a field in the initialize control request
  • an environment variable such as CLAUDE_CODE_SESSION_ATTENDED=1 for the top-level process (today the CLI sets this variable only for its child processes)

With it, an attended host gets the same behaviour as the VS Code and desktop app sessions: no background-command time limit.

Related: #98273 (the limit is not configurable), #100648 (Remote Control sessions get the unattended limit).

View original on GitHub ↗