Skip to content

fix(acp): bridge question prompts via extMethod#33482

Open
Jayl1n wants to merge 3 commits into
anomalyco:devfrom
Jayl1n:for-cotaya
Open

fix(acp): bridge question prompts via extMethod#33482
Jayl1n wants to merge 3 commits into
anomalyco:devfrom
Jayl1n:for-cotaya

Conversation

@Jayl1n

@Jayl1n Jayl1n commented Jun 23, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #17920. Also addresses #13752.

Type of change

  • Bug fix

What does this PR do?

In ACP mode the question tool hangs forever: question.asked is published, a Deferred waits for the answer, but nothing forwards it to the ACP client, so the tool blocks indefinitely (#17920).

This adds an ACP bridge for question.asked, gated behind a client capability so existing clients keep their current behavior. When OPENCODE_ENABLE_QUESTION_TOOL=1 is set and the client advertises clientCapabilities._meta["opencode/question"] at initialize, the question request is forwarded over the ACP extension method opencode/question (connection.extMethod), and the response is mapped back to sdk.question.reply / sdk.question.reject. If the client declines, throws, or doesn't advertise the capability, the question is rejected so the agent isn't left waiting.

The handler mirrors the existing permission.ts Handler (per-session serialization via a promise queue), wired into ACPEvent.Subscription. The capability is parsed in ACPService.initialize via setQuestionEnabled.

Note: this is a port of #20017, which was written against the old monolithic agent.ts before the ACP layer was split into service.ts / event.ts / permission.ts. The original PR also wrote process.env.OPENCODE_ENABLE_QUESTION_TOOL inside initialize() to register the tool at runtime — that no longer works because the flag is now an Effect RuntimeFlags value snapshotted once at boot when the tool registry is built, so registering the question tool still requires the env var before server start (documented in the new acp/README.md).

Files:

  • src/acp/question.ts (new) — Handler, mirrors permission.ts
  • src/acp/event.tsConnection gains extMethod; Subscription owns the handler + setQuestionEnabled
  • src/acp/service.tsinitialize parses the capability
  • src/acp/README.md (new) — capability contract
  • test/acp/question.test.ts (new) — reply / reject / no-capability / extMethod-throws

How did you verify your code works?

  • bun typecheck (run from packages/opencode)
  • bun test test/acp/question.test.ts test/acp/permission.test.ts test/acp/event.test.ts — 26 pass / 0 fail

A reviewer can reproduce the fix by enabling the tool against an ACP client that advertises the capability:

OPENCODE_ENABLE_QUESTION_TOOL=1 ./packages/opencode/dist/opencode-darwin-arm64/bin/opencode acp

Screenshots / recordings

N/A (no UI changes)

Checklist

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

Re-implements PR anomalyco#20017 for the refactored ACP layer. question.asked
events are forwarded to ACP clients that advertise the opencode/question
capability via connection.extMethod('opencode/question', ...), mapping the
response back to sdk.question.reply/reject. Mirrors the permission handler
pattern (per-session serialization) in a new acp/question.ts module wired
into ACPEvent.Subscription.

The tool registration still requires OPENCODE_ENABLE_QUESTION_TOOL=1 before
server start (the flag is snapshotted at boot); the defunct runtime
process.env write from the original PR is intentionally not carried over.
@github-actions

Copy link
Copy Markdown
Contributor

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 github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Related PR Found:

No other duplicate or conflicting open PRs found.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

Question tool hangs in ACP mode

1 participant