Skip to content

fix(cli): answer subagent asks in run and keep parallel rejections continuing - #52146

Merged
jlongster merged 1 commit into
v2from
run-subagent-asks
Sep 29, 2026
Merged

jlongster merged 1 commit into
v2from
run-subagent-asks

Conversation

@jlongster

Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix

What does this PR do?

Two edge cases left opencode run stopping or hanging after #51968. Both were found with an opencode-drive edge-case matrix.

1. Parallel permission asks stopped the run (core). When one ask is rejected, Permission.reply also rejects every other pending ask in the session, always with a plain DeclinedError. So run's reject-with-feedback for the first ask still ended the step for the second:

! permission requested: read (.env); auto-rejecting
! permission requested: external_directory (/etc/*); auto-rejecting
Error: Session interrupted: shutdown
…
Error: The user declined this tool call

The other pending asks now get the same feedback (CorrectedError) when the rejection carries a message. They still get DeclinedError when it doesn't. This also fixes the TUI case where rejecting one ask with feedback while another is pending ended the turn.

2. Subagent asks hung the run forever (CLI). run only answered permission asks and forms for its own session ID. A subagent runs in a child session, so its ask was never answered and the run waited indefinitely. This predates #51968. run now also handles asks and forms from descendant sessions. It resolves the parentID chain once per session and caches it, so unrelated sessions on a shared server (for example the TUI's) are still left alone. Permission replies now use the asking session's ID.

How did you verify your code works?

  • packages/cli: bun typecheck; bun test test/run is 11 pass / 0 fail.
  • packages/core: bun typecheck; bun test test/permission.test.ts test/session-runner.test.ts is 325 pass / 0 fail.
  • opencode-drive matrix (server and CLI from this branch, simulated LLM). All pass:
    • ask, ask retried ×3, --auto, deny
    • two asks in one step → both get feedback, model continues, exit 0 (was: exit 1)
    • subagent hits an ask → rejected with feedback, child finishes, parent answers, exit 0 (was: hang)
    • subagent hits two asks in one step → same, exit 0
    • unrelated session on the same server with a pending ask → still pending after run exits
  • Together with feat(core): let form cancellation carry a message #52137 (question cancellation with a message), the full 19-case matrix passes, including question/ask mixes, --format json, and a subagent trying the question tool.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@jlongster
jlongster merged commit bc5ff1c into v2 Sep 29, 2026
9 of 10 checks passed
@jlongster
jlongster deleted the run-subagent-asks branch September 29, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant