[PR #13750] feat(acp): enable question tool for ACP clients #14801

Open
opened 2026-02-16 18:19:33 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13750

State: open
Merged: No


Summary

Enable question tool support for ACP (Agent Client Protocol) clients like Zed. This allows ACP-compatible editors to handle AI assistant questions through their native permission UI.

Fixes #13752

What Changed

For ACP Users (Zed, etc.)

When the AI assistant asks a question (e.g., "Which test file should I create?"), ACP clients now display it as a native permission prompt with selectable options:

┌─────────────────────────────────────────┐
│  Create test file?                      │
│                                         │
│  ○ Unit tests (recommended)             │
│  ○ Integration tests                    │
│  ○ Skip this step                       │
│                                         │
│           [Cancel]                      │
└─────────────────────────────────────────┘

Implementation Details

  1. Registry Update - QuestionTool is now available for ACP mode

    • Previously only available for app, cli, desktop clients
    • Now includes acp client type
  2. Event Handler - New question.asked event handler in ACP Agent

    • Maps question options to ACP PermissionOption format
    • Generates unique option IDs from labels (kebab-case)
    • Always includes a "Cancel" option for dismissal
    • Uses existing permission queue for sequential per-session handling
  3. Response Flow

    • User selects an option → calls sdk.question.reply() with the label
    • User clicks Cancel → calls sdk.question.reject()
    • Errors → gracefully rejected to prevent hanging promises

Scope & Limitations

This implements Phase 1 with the following constraints:

  • Single-select only (first question if multiple)
  • No text input (custom answers)
  • Multiple options supported (array-based)
  • Cancellation always available

Multi-select and text input support will come in a future update.

Testing

  • 6 new integration tests in test/acp/question.test.ts
  • All existing ACP tests pass (no regressions)
  • bun test test/acp/ - 12 tests passing

Verification

# Run ACP tests
bun test packages/opencode/test/acp/question.test.ts

# Type check
bun run typecheck
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13750 **State:** open **Merged:** No --- ## Summary Enable **question tool support for ACP (Agent Client Protocol) clients** like Zed. This allows ACP-compatible editors to handle AI assistant questions through their native permission UI. Fixes #13752 ## What Changed ### For ACP Users (Zed, etc.) When the AI assistant asks a question (e.g., "Which test file should I create?"), ACP clients now display it as a native permission prompt with selectable options: ``` ┌─────────────────────────────────────────┐ │ Create test file? │ │ │ │ ○ Unit tests (recommended) │ │ ○ Integration tests │ │ ○ Skip this step │ │ │ │ [Cancel] │ └─────────────────────────────────────────┘ ``` ### Implementation Details 1. **Registry Update** - `QuestionTool` is now available for ACP mode - Previously only available for `app`, `cli`, `desktop` clients - Now includes `acp` client type 2. **Event Handler** - New `question.asked` event handler in ACP Agent - Maps question options to ACP `PermissionOption` format - Generates unique option IDs from labels (kebab-case) - Always includes a "Cancel" option for dismissal - Uses existing permission queue for sequential per-session handling 3. **Response Flow** - User selects an option → calls `sdk.question.reply()` with the label - User clicks Cancel → calls `sdk.question.reject()` - Errors → gracefully rejected to prevent hanging promises ### Scope & Limitations This implements **Phase 1** with the following constraints: - ✅ Single-select only (first question if multiple) - ✅ No text input (custom answers) - ✅ Multiple options supported (array-based) - ✅ Cancellation always available Multi-select and text input support will come in a future update. ## Testing - 6 new integration tests in `test/acp/question.test.ts` - All existing ACP tests pass (no regressions) - `bun test test/acp/` - 12 tests passing ## Verification ```bash # Run ACP tests bun test packages/opencode/test/acp/question.test.ts # Type check bun run typecheck ```
yindo added the pull-request label 2026-02-16 18:19:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14801