Skip to content

[Bug]: Auto-settle on merge detaches a Claude session the instant an awaited background task ends, so the wake turn never runs #38480

Closed as duplicate

Description

@Sergio-CVM00

Area

apps/server

Steps to reproduce

  1. Use a Claude thread with a linked PR that has merged after the latest user message. sidebarAutoSettleOnMerge is on (the default). The thread is not pinned.
  2. Have the agent start a Bash command with run_in_background, register it with t3_background_wait, and end its turn.
  3. Wait for the command to exit.

Expected behavior

Claude's wake turn runs and the agent continues. Auto-settle waits until that wake turn has finished.

Actual behavior

The settle is held only while the task is on the pending roster. On completion Claude sends task_updated, task_notification and background_tasks_changed {tasks: []}. Within about 10 ms T3 runs provider-session.detach with command id server:auto-settle:<threadId>:<uuid> and sends query.close. The CLI never emits the wake system init, so the agent never sees the result. The thread stays idle until a human sends a message. In our case that took almost 5 hours, during an unattended release.

Evidence from one Mac (2026-11-12 to 2026-11-18), joining the provider event logs with orchestration_v2_effect_outbox:

  • 91 background completions arrived while a Claude thread was idle. 75 woke normally.
  • 16 ended with query.close 7 to 14 ms after task_notification. In 14 of them, a server:auto-settle provider-session.detach was created 2 to 8 ms after the notification. The other 2 were a manual interrupt and a simultaneous close of two threads.
  • Example: task_notification at 01:18:47.393Z, outbox detach server:auto-settle:… at 01:18:47.401Z, query.close at 01:18:47.403Z, next query.open at 06:10:17Z (a manual message).
  • Workaround check: the same thread state, pinned, with a 150 s background sleep registered through t3_background_wait. task_notification arrived at 07:30:46.479Z and the wake system init followed at 07:30:46.541Z, with no detach. Pinning excludes the thread from isAutoSettlementCandidate.

This is close to #31448 (settling detaches running background work), but that issue covers the case where the work is still running. Here the hold from backgroundWorkHoldsCompletion works until the task ends, and then it releases one step too early: the buffered wake (wakeBuffers / wakeEligibleBackgroundTasksByNativeThread in ClaudeAdapterV2) has not started yet. A possible fix is to keep holding auto-settle while a wake is buffered or within CLAUDE_WAKE_TURN_START_DEADLINE, or to make the settle detach skip a session whose wake is pending. Related: #30156.

Impact

Major degradation or frequent failure

Version or commit

T3 Code (Beta) desktop 0.1.9. Source read at upstream 22b52524.

Environment

macOS arm64, desktop app with its local server, provider claudeAgent (claude-opus-5-5), Claude Code 2.1.323.

Activity

  1. juliusmarminge commented on Nov 18, 2026

    @juliusmarminge
    Member

    This is the same problem as #26083, so I'm closing it in favour of that one. If it is different, say how and it will be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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