# Claude: permission checks from a background subagent are denied with "no active turn" once the parent turn has ended · Issue \#20339 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/issues/20339)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: backlog

Priority: 0

## Description

[Discussion and activity](https://git.cafe/pingdotgg/t3code/issues/20339)

---

### What happened

Subagents in Claude threads often can't use tools. Their tool calls fail with `Claude V2 adapter has no active turn for this tool request.`, which wastes their work. This happens mostly when the agent launches many subagents.

### Diagnosis

`canUseToolEffect` in `ClaudeAdapterV2.ts` (L7685-7692, unchanged on `main` at `e58a485`) denies every permission request while `activeTurn` is `null`. `finalizeActiveTurn` sets it to `null` when the root `result` arrives (L5866), but background subagents keep running in the same CLI process. From then on, any of their calls that reach `canUseTool` are denied. No runtime request is raised and the runtime policy isn't consulted, so even full-access threads deny.

- Only calls the CLI doesn't approve on its own are affected: allow rules, read-only commands and Reads inside cwd still pass. Being outside cwd is not the trigger; `ls <cwd>` was denied as well.
- **Approval-required:** reproduced. Requests are denied instead of being shown as approvals.
- **Full-access:** affected when the CLI isn't really in bypass mode. With `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1`, CLI 2.1.301 forces the startup mode to `default`. T3 records that mode (L8188) and switches back to bypass only on the next prompt (L8064). So the first turn of every new process runs in `default`, with the callback auto-allowing until the turn ends.
- Foreground subagents are safe while their parent turn is open. When one is resumed with `SendMessage`, it runs in the background and is affected.
- 11 root-level denials came right after a `task_notification`, in a turn the SDK started on its own. I couldn't reproduce these; it looks like a race.

Logs on this machine, Oct 9-16: 397 denials across 15 threads. 349 came from background subagents, 29 from resumed foreground subagents and 11 from the root agent. All of them fell between a root `result` and the next `prompt.offer`.

### Steps to reproduce

1. Start a new Claude thread in approval-required mode. Alternatively, use a fresh full-access thread with `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1`.
2. Have the agent launch a subagent with `run_in_background: true` that runs `echo probe`, `Read /etc/hosts`, `cat /etc/hosts` and `ls <cwd>`, then end its turn immediately.
3. After the parent `result`, every call except `echo` fails with the error, and no approval appears.

With `run_in_background: false`, all calls pass.

### Version

0.1.1-nightly.20261016.3203 (desktop, Nightly). The logs show the same denials in earlier nightlies back to Oct 9.

### Environment

macOS 27.0.1 (arm64), T3 Code desktop (Node v24.21.0), Claude Code CLI 2.1.301, claude-agent-sdk ^0.3.276

### Evidence

```shell
# approval-required child thread
query.open   permissionMode=default hasCanUseTool=true
17:06:13.527 ROOT Agent (run_in_background: true)  accept config
17:06:16.051 result success                        <- activeTurn = null
17:06:21.779 sub Bash echo probe-bg-1              accept config
17:06:24.680 sub Read /etc/hosts                   reject user_reject "Claude V2 adapter has no active turn for this tool request."
17:06:30.545 sub Bash cat /etc/hosts               reject user_reject (same)
17:06:32.862 sub Bash ls <cwd>                     reject user_reject (same)

# full-access child thread, CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1: same result
query.open   permissionMode=bypassPermissions allowDangerouslySkipPermissions=true
system/init  permissionMode=default

# CLI alone
$ claude -p --permission-mode bypassPermissions ...
⚠ Permission mode forced to default — CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set (allowed_non_write_users hardening). ...
```

### Related issues

#16484 and #19440 cover background subagents after the parent turn ends, but deal with UI updates and process exit, not permissions. #17633 is the same scrub setup with a different symptom. #15589 is the same "no active turn" shape in the Pi adapter.

### Fix applied or workaround

For now I removed `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1` from `~/.claude/settings.json`, so full-access threads really start in bypass mode. I'd like to turn it back on once this is fixed, because it keeps credentials out of the subprocesses Claude starts. Approval-required threads are affected either way. The only other workaround is to use foreground subagents and not resume them with `SendMessage`.

Suggested fix: when no turn is active, decide the request from the thread's runtime policy, or raise it against the subagent's task, instead of denying it.

### Filed by

Claude Code (claude-opus-5-5) in T3 Code, following the `t3 triage` playbook
