Skip to content

fix(run): remove sessionID filter for permission.asked to fix subagent permission hang#26427

Closed
bingkxu wants to merge 1 commit intoanomalyco:devfrom
bingkxu:fix/subagent-permission-stdout
Closed

fix(run): remove sessionID filter for permission.asked to fix subagent permission hang#26427
bingkxu wants to merge 1 commit intoanomalyco:devfrom
bingkxu:fix/subagent-permission-stdout

Conversation

@bingkxu
Copy link
Copy Markdown

@bingkxu bingkxu commented May 9, 2026

Summary

  • Remove the if (permission.sessionID !== sessionID) continue filter in run.ts that prevents subagent (task tool) permission events from being processed.
  • This filter was introduced in the Permission rework (Permission rework #6319) before subagents existed. When a subagent triggers a permission request, the event carries the child session's ID, which differs from the main sessionID. The filter silently drops these events.
  • 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.

Testing

Added an integration test (test/cli/cmd/run-permission.test.ts) that spawns opencode run --format json --dangerously-skip-permissions with a mock LLM server that triggers a task (subagent) tool call followed by a bash tool call inside the subagent, with permission: { bash: "ask" } configured to force a permission prompt from the subagent.

Verified:

  • With fix: test passes in ~14s — subagent permissions are correctly processed
  • Without fix (reverted): test times out at 30s — reproducing the hang that external consumers experience

…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
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

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 run.ts. The other results are PRs about related functionality (permission flags, subagent delegation) but don't duplicate your specific fix.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

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.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
@github-actions github-actions Bot closed this May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant