Skip to content

feat(sdk,cli): add ask_user tool for interactive questioning#1377

Open
Harrison Chase (hwchase17) wants to merge 1 commit intomainfrom
open-swe/3604dc97-be5e-4154-dc5d-c7ec858f75e3
Open

feat(sdk,cli): add ask_user tool for interactive questioning#1377
Harrison Chase (hwchase17) wants to merge 1 commit intomainfrom
open-swe/3604dc97-be5e-4154-dc5d-c7ec858f75e3

Conversation

@hwchase17
Copy link
Contributor

@hwchase17 Harrison Chase (hwchase17) commented Feb 17, 2026

Add ask_user tool that allows the agent to ask the user one or more questions during execution. Uses LangGraph interrupts to pause execution and resume with user answers.

Key design decisions:

  • Opt-in: Enabled via enable_ask_user=True on create_deep_agent() or --ask-user CLI flag
  • Question types: Text (free-form) and multiple choice (with always-available "Other" option)
  • Interrupt-based: Uses langgraph.types.interrupt() to pause the agent and collect user input, then resumes execution with the answers
  • CLI modal: Renders as an inline widget in the chat (like the approval menu) with text inputs and selectable choices

Changes:

Core library (libs/deepagents):

  • deepagents/middleware/ask_user.py — New AskUserMiddleware with ask_user tool, Question/Choice/AskUserRequest/AskUserResponse TypedDicts, system prompt injection
  • deepagents/graph.py — Added enable_ask_user parameter to create_deep_agent()
  • deepagents/__init__.py, deepagents/middleware/__init__.py — Export AskUserMiddleware

CLI (libs/cli):

  • widgets/ask_user.py — New AskUserMenu Textual widget with text inputs and multiple choice selection
  • textual_adapter.py — Handle ask_user interrupts (distinguished from HITL approval by type: "ask_user")
  • app.py_request_ask_user() method + on_ask_user_menu_answered/cancelled handlers
  • agent.py — Pass through enable_ask_user to create_deep_agent()
  • main.py--ask-user CLI flag
  • tool_display.py — Format ask_user tool calls (shows question count)
  • app.tcss — Styles for the ask-user widget
  • widgets/__init__.py — Export AskUserMenu

Adds AskUserMiddleware to the core library and integrates it into the CLI.
The tool uses LangGraph interrupts to pause execution and collect user
answers via an inline Textual widget. Opt-in via enable_ask_user=True
or --ask-user CLI flag. Supports text and multiple choice questions.
@github-actions github-actions bot added cli Related to `deepagents-cli` deepagents Related to the `deepagents` SDK / agent harness internal User is a member of the `langchain-ai` GitHub organization feature New feature/enhancement or request for one labels Feb 17, 2026
@mdrxy Mason Daugherty (mdrxy) changed the title feat: add ask_user tool for interactive questioning [closes LC-482] feat(cli): add ask_user tool for interactive questioning Mar 5, 2026
@github-actions github-actions bot added feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Mar 5, 2026
@mdrxy Mason Daugherty (mdrxy) changed the title feat(cli): add ask_user tool for interactive questioning feat(sdk,cli): add ask_user tool for interactive questioning Mar 7, 2026
@github-actions github-actions bot added feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to `deepagents-cli` deepagents Related to the `deepagents` SDK / agent harness feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant