[PR #6681] feat: add ask_user tool for interactive user questions #12039

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

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

State: open
Merged: No


Similar to AskUserQuestion tool in ClaudeCode. Adds a new tool that allows the AI to pause execution and present clarifying questions with selectable options to the user. Useful for gathering user preferences before proceeding with implementation.

  • Tool: ask_user with question, options (2-6), and optional context
  • TUI: DialogAsk component with keyboard navigation (↑/↓/j/k, 1-6, Enter, Esc)
  • Server: POST /ask/:id/reply endpoint for user responses
  • Events: askuser.question, askuser.answer, askuser.cancelled

Summary

  • Adds ask_user tool enabling the AI to pause and present clarifying questions with selectable options
  • Implements TUI dialog with full keyboard navigation for option selection
  • Follows existing permission system architecture (Bus events → SSE → TUI → API reply)
  • Events: askuser.question, askuser.answer, askuser.cancelled

Changes

New Files:

  • src/tool/ask.ts - Tool definition with Bus events and promise-based execution
  • src/tool/ask.txt - LLM description explaining when to use/avoid the tool
  • src/cli/cmd/tui/ui/dialog-ask.tsx - SolidJS dialog component

Modified Files:

  • src/server/server.ts - Added POST /ask/:id/reply endpoint
  • src/tool/registry.ts - Registered AskUserTool
  • src/cli/cmd/tui/context/sync.tsx - Added ask event handlers to sync state
  • src/cli/cmd/tui/routes/session/index.tsx - Renders DialogAsk, handles responses
  • src/id/id.ts - Added "ask" prefix for ID generation
  • packages/sdk/ - Regenerated client SDK

Testing

cd packages/opencode && bun dev

Try prompts like:

  • "Help me choose a testing framework for TypeScript"
  • "Interview me about building a REST API"

The AI should present options with keyboard navigation (↑ / ↓ / j / k , 1-6 number keys, Enter to select, Esc to cancel).

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6681 **State:** open **Merged:** No --- Similar to AskUserQuestion tool in ClaudeCode. Adds a new tool that allows the AI to pause execution and present clarifying questions with selectable options to the user. Useful for gathering user preferences before proceeding with implementation. - Tool: ask_user with question, options (2-6), and optional context - TUI: DialogAsk component with keyboard navigation (↑/↓/j/k, 1-6, Enter, Esc) - Server: POST /ask/:id/reply endpoint for user responses - Events: askuser.question, askuser.answer, askuser.cancelled ## Summary - Adds ask_user tool enabling the AI to pause and present clarifying questions with selectable options - Implements TUI dialog with full keyboard navigation for option selection - Follows existing permission system architecture (Bus events → SSE → TUI → API reply) - Events: askuser.question, askuser.answer, askuser.cancelled ## Changes New Files: - src/tool/ask.ts - Tool definition with Bus events and promise-based execution - src/tool/ask.txt - LLM description explaining when to use/avoid the tool - src/cli/cmd/tui/ui/dialog-ask.tsx - SolidJS dialog component ## Modified Files: - src/server/server.ts - Added POST /ask/:id/reply endpoint - src/tool/registry.ts - Registered AskUserTool - src/cli/cmd/tui/context/sync.tsx - Added ask event handlers to sync state - src/cli/cmd/tui/routes/session/index.tsx - Renders DialogAsk, handles responses - src/id/id.ts - Added "ask" prefix for ID generation - packages/sdk/ - Regenerated client SDK ## Testing cd packages/opencode && bun dev Try prompts like: - "Help me choose a testing framework for TypeScript" - "Interview me about building a REST API" The AI should present options with keyboard navigation (↑ / ↓ / j / k , 1-6 number keys, Enter to select, Esc to cancel).
yindo added the pull-request label 2026-02-16 18:16:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12039