fix(run): remove sessionID filter for permission.asked to fix subagent permission hang#26427
fix(run): remove sessionID filter for permission.asked to fix subagent permission hang#26427bingkxu wants to merge 1 commit intoanomalyco:devfrom
Conversation
…t permission hang The sessionID filter in the run command's event loop was introduced before subagents existed (PR anomalyco#6319). When a subagent (task tool) triggers a permission request, the event carries the child session's ID, which differs from the main sessionID. The filter causes these events to be silently dropped. With --dangerously-skip-permissions, subagent permissions are never auto-approved, causing the process to hang indefinitely. Without it, subagent permissions are never auto-rejected either, same result. The TUI's sync.tsx does NOT filter by sessionID (it uses request.sessionID as key directly), confirming this filter is unnecessary. The SSE subscription is already per-instance via Bus.subscribeAll, so no unrelated events can arrive. Verified: - With fix: integration test passes (~14s), subagent permissions are correctly processed - Without fix: integration test times out (30s), reproducing the hang that external consumers (e.g. cc-connect) experience
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR that addresses subagent permission handling: Related PR:
This PR is related because it also deals with permission propagation from nested subagents, which is the same core issue your PR addresses (subagent permissions not being processed correctly). However, PR #26427 (your current PR) appears to be the primary/only PR addressing the specific sessionID filter removal in |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Summary
if (permission.sessionID !== sessionID) continuefilter inrun.tsthat prevents subagent (task tool) permission events from being processed.sessionID. The filter silently drops these events.--dangerously-skip-permissions, subagent permissions are never auto-approved, causing the process to hang indefinitely. Without it, subagent permissions are never auto-rejected either — same result.sync.tsxdoes NOT filter by sessionID (it usesrequest.sessionIDas key directly), confirming this filter is unnecessary.Bus.subscribeAll, so no unrelated events can arrive.Testing
Added an integration test (
test/cli/cmd/run-permission.test.ts) that spawnsopencode run --format json --dangerously-skip-permissionswith a mock LLM server that triggers a task (subagent) tool call followed by a bash tool call inside the subagent, withpermission: { bash: "ask" }configured to force a permission prompt from the subagent.Verified: