Skip to content

Conversation

@durutheguru
Copy link

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).

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
@airtonix
Copy link
Contributor

airtonix commented Jan 3, 2026

this is about the fifth or sixth pr for this.

did you test this with opencode run ... and opencode web ?

the team is working on ability for UI plugins. I'd wait for that.

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.

2 participants