feat(sdk,cli): add ask_user tool for interactive questioning#1377
Open
Harrison Chase (hwchase17) wants to merge 1 commit intomainfrom
Open
feat(sdk,cli): add ask_user tool for interactive questioning#1377Harrison Chase (hwchase17) wants to merge 1 commit intomainfrom
ask_user tool for interactive questioning#1377Harrison Chase (hwchase17) wants to merge 1 commit intomainfrom
Conversation
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.
ask_user tool for interactive questioning
ask_user tool for interactive questioningask_user tool for interactive questioning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
ask_usertool 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:
enable_ask_user=Trueoncreate_deep_agent()or--ask-userCLI flaglanggraph.types.interrupt()to pause the agent and collect user input, then resumes execution with the answersChanges:
Core library (
libs/deepagents):deepagents/middleware/ask_user.py— NewAskUserMiddlewarewithask_usertool,Question/Choice/AskUserRequest/AskUserResponseTypedDicts, system prompt injectiondeepagents/graph.py— Addedenable_ask_userparameter tocreate_deep_agent()deepagents/__init__.py,deepagents/middleware/__init__.py— ExportAskUserMiddlewareCLI (
libs/cli):widgets/ask_user.py— NewAskUserMenuTextual widget with text inputs and multiple choice selectiontextual_adapter.py— Handleask_userinterrupts (distinguished from HITL approval bytype: "ask_user")app.py—_request_ask_user()method +on_ask_user_menu_answered/cancelledhandlersagent.py— Pass throughenable_ask_usertocreate_deep_agent()main.py—--ask-userCLI flagtool_display.py— Formatask_usertool calls (shows question count)app.tcss— Styles for the ask-user widgetwidgets/__init__.py— ExportAskUserMenu