Skip to content

fix(server): a changed repository list no longer blocks Claude sends during background work - #40492

Open
juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-40477
Open

juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-40477

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

When a project's list of nested repositories changed (for example after editing ignoreRepositories in t3.json, or cloning or removing a nested repo) while Claude was running a background command, every message to that thread was refused with an error blaming a model or setting change. This lasted until the background work ended or the user pressed Stop. Now, when the repository list is the only difference, the message goes to the running Claude process, and the new list takes effect the next time the process restarts.

Fixes #40477

Reproduction on main

Commit 194025e (origin/main). Fresh dev server (T3CODE_DEV_SEED=0 vp run dev). Scratch project: a git repo with a nested git repo at vendor/foo; t3 project add reported 'It also covers 1 other folder'. t3 thread start --provider claudeAgent --model claude-haiku-5-5 --wait <proj> "Use the Bash tool with run_in_background ... sleep 900 ... end your turn" replied 'started', and sleep 900 was running. Wrote t3.json {"ignoreRepositories":["vendor/foo"]} without touching model or settings. t3 thread send --wait <thread> "Reply with the word ok." stopped with status failed: 'Claude is still running background agents or commands, and this model or setting change would end them...'. A second send failed the same way. Control: after deleting t3.json (repo list back to the original), the next send on the same live process succeeded ('back') while sleep 900 was still running, so the workspace part of the reuse key alone triggers the refusal. Added a unit test in ClaudeAdapterV2.test.ts that uses the existing background-shell wake harness: turn 1 with workspace folders [vendor/foo], a background task, then turn 2 with the same selection and no workspace. On main it fails with ClaudeBackgroundWorkBlocksQueryReplacementError.

Evidence

Started live Claude Haiku 5.5 background work (sleep 900) with a nested repository included, excluded vendor/foo through t3.json, then sent “Reply with the word ok.” without changing model or settings. Both apps used fresh databases, Chromium 151, 1440×1000, and light theme.

Before After
194025ef11 ae16743929
Before: send refused while background command runs After: ok reply while original background command runs
Before recording After recording

Synthetic seed script · Reproduction driver

Not shown:

  • Repository changes caused by cloning or deleting nested repositories were not separately exercised; the demonstrated trigger was ignoreRepositories.
  • The no-background-work process-restart behavior was not separately captured.

Tests

  • vp test run src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts (apps/server): 475 passed
  • same file with -t "repositories change" on the base, without the fix: fails with ClaudeBackgroundWorkBlocksQueryReplacementError (as expected)
  • vp run check:changed: format, lint, knip, graphql, typecheck (3 packages), tests (2 files, 477) all pass
  • PR CI on ae16743: all 38 checks pass

Not in this change

  • With no background work, a changed repository list still silently restarts the Claude process; this is intended, since folders are fixed when the query opens.
  • The ClaudeBackgroundWorkBlocksQueryReplacementError message still says 'model or setting change' for any non-workspace policy difference, such as MCP server changes.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 9fdcd08 · PR result: ae16743 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Claude query contexts now retain a policy key that excludes workspace data. When the native thread and workspace-independent policy match, openQuery keeps the existing query key while background work is running. A regression test covers a changed or empty repository list.

Changes: Claude query reuse

Layer / File(s) Summary
Workspace policy comparison and regression coverage
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
The query context stores policy keys with and without workspace data. When the native thread and workspace-independent key match while background work is running, openQuery retains the existing query key. The regression test checks that a turn succeeds without replacing the query.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: yash-singh1, rishabhx29

Merge Risk: Minimal · up to ae167

Messages can now reach a running Claude process when only the repository list changed during background work. The new list applies at the next restart. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a changed repository list no longer blocks Claude sends during background work. It also follows the conventional commit form. It matches the objectives and the raw sum…
Linked Issues check Passed Directly linked issue #40477 requires that a repository-list change not block messages while Claude runs background work. The PR changes ClaudeLiveQueryContext in ClaudeAdapterV2.ts to keep a second…
Out of Scope Changes check Passed The changes are limited to ClaudeAdapterV2.ts (query-context keys and the openQuery reuse decision) and its test file ClaudeAdapterV2.test.ts. Both connect directly to the reuse-key behavior describ…
Description check Passed The description follows the repository template closely. It explains the problem (refused messages during background work after a repository-list change), the change (route the message to the running …
Full details: Title check

Explanation

The title names the main change: a changed repository list no longer blocks Claude sends during background work. It also follows the conventional commit form. It matches the objectives and the raw summary, which describe a workspace-only policy difference no longer triggering the refusal while background work runs.

Full details: Linked Issues check

Explanation

Directly linked issue #40477 requires that a repository-list change not block messages while Claude runs background work. The PR changes ClaudeLiveQueryContext in ClaudeAdapterV2.ts to keep a second query-policy key that excludes the workspace. When only the workspace key differs and background work runs, openQuery keeps the existing process and the message is sent to it. The new repository list applies at the next process restart. This matches the approach the issue lists as a possible direction. The added regression test in ClaudeAdapterV2.test.ts (turn 1 with workspace [vendor/foo] and a background task, turn 2 with no workspace) covers the reported trigger. The PR reports that this test fails on the base and passes at the head. The issue's second suggestion, naming the actual difference in the error, is not implemented. The PR states this explicitly as out of scope, and the issue presents it as a direction, not a firm requirement. The raw diff of ClaudeAdapterV2.ts could not be read (changed blobs unavailable), so the verdict relies on the PR summary and the reported test results. The real-app before/after evidence is still pending, but it is not a coding requirement.

Full details: Out of Scope Changes check

Explanation

The changes are limited to ClaudeAdapterV2.ts (query-context keys and the openQuery reuse decision) and its test file ClaudeAdapterV2.test.ts. Both connect directly to the reuse-key behavior described in #40477. The PR does not change the error message text, discovery logic, or unrelated adapters. The PR description lists the unchanged error message and the unchanged no-background-work behavior as deliberate exclusions. The raw diff could not be read, so this verdict relies on the PR summary and description rather than the full diff.

Full details: Description check

Explanation

The description follows the repository template closely. It explains the problem (refused messages during background work after a repository-list change), the change (route the message to the running process and apply the new list on restart), the scope (links issue #40477 and a reproduction on main), and verification (specific test commands, a before/after failure, a check run, and CI status). It also lists what was not shown and what is out of scope. The Scope section does not explain why a fix needs no issue, but it links one, so the gap is minor. The author attribution is present. The evidence section includes screenshots and recordings. Overall the description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9fdcd08 and ae16743.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@henrik092

Copy link
Copy Markdown

Note

🤖 Claude Opus 5.5 responding on behalf of henrik092

+1. This also hits without any t3.json edit: on 0.1.13, a nested repo created by a different thread in the same project was auto-discovered as a tracked folder mid-turn (discovered: true in tracked_folders_json). The next plain message to a Claude thread that still had two background commands running was refused with the "model or setting change" error. Model selection, native session id and MCP setup were unchanged between the two runs; only the folder list had grown.

So the trigger is broader than editing ignoreRepositories: any thread that creates a git repo inside the project blocks every other Claude thread there that has background work running.

Checked locally on current main: the same change as this PR, plus a test in the direction we hit (turn 1 without folders, turn 2 with one folder added). The test fails with ClaudeBackgroundWorkBlocksQueryReplacementError without the fix and passes with it. check:changed is green. This PR currently shows merge conflicts with main.

@mcarkade

mcarkade commented Dec 2, 2026

Copy link
Copy Markdown

Hit this on Windows with T3 Code Nightly 0.1.14-nightly.20261201.5580 (claudeAgent, claude-opus-5-5). Here the agent changed the repository list itself, once in each direction:

  1. 07:36 UTC: the Claude process opens. The project has no nested repos.
  2. 07:39: the agent runs git clone into <project>/Riemann_Theorem/riemann-hypothesis, two levels down, so discovery picks it up. The clone keeps running as a background command after the turn ends.
  3. 07:50: three plain sends with the composer unchanged. All are refused with ClaudeBackgroundWorkBlocksQueryReplacementError.
  4. 07:51: Stop. The new process opens with the partial clone in its folder list.
  5. 07:52: the agent deletes the partial clone and restarts the clone outside the project, again as a background command.
  6. 07:55: two more sends are refused, this time because the repo is gone.
  7. 08:01: the agent copies the repo back to the same path. The folder list matches the live process again, so sends work.

The provider event log has only two query.open calls, at 07:36 and 07:52. Their options differ only in sessionId vs resume, so neither the model nor any setting changed.

This branch now conflicts with main. The conflict is with #38528, which added the replaceStaleProcess block in the same place. Keep both blocks, with this PR's queryPolicyKey block first, because the stale-process block reads queryPolicyKey. With that resolution on fa2ebe4442:

  • The new test fails against main's adapter with ClaudeBackgroundWorkBlocksQueryReplacementError and passes with the fix.
  • ClaudeAdapterV2.test.ts + ProviderSwitch.integration.test.ts: 642 passed, 3 failed. The same 3 also fail on unmodified main on Windows (symlink EPERM without Developer Mode, and a /workspace vs C:\workspace path assertion), so they are unrelated to this change.
  • vp run typecheck in apps/server exits 0.

This branch has not been deployed

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

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing a project's repositories while Claude runs background work blocks every message with a "model or setting change" error

3 participants