Class: Rubino::Tools::QuestionTool
- Defined in:
- lib/rubino/tools/question_tool.rb
Overview
Tool that asks the user interactive questions with predefined options. Allows the agent to gather clarification or preferences from the user.
Constant Summary collapse
- NO_ANSWER =
Deterministic result when no user answer is available — the UI’s #ask returned nil (non-interactive / piped session, or the user gave no response). Fail closed instead of reading ambient stdin or silently picking an option (#107): never assume a choice on the user’s behalf.
"No answer: no interactive user input available " \ "(non-interactive session, or the user gave no response). " \ "Do not assume a choice on the user's behalf; proceed with the " \ "safest option and state the assumption, or finish and report " \ "the open question."
- TIMED_OUT =
#552: clean, NON-ERROR outcome when the human did not answer within the generous clarify timeout. Mirrors ask_parent’s “proceed with your best judgement” expiry and Hermes’ falsy clarify response — the run continues, nothing is raised, no choice is assumed on the user’s behalf.
"No answer: the question timed out waiting for a reply. " \ "Do not assume a choice on the user's behalf; proceed with the " \ "safest option and state the assumption, or finish and report " \ "the open question."
- DEFAULT_CLARIFY_TIMEOUT =
Fallback bound (seconds) when no configuration is reachable (a bare tool in a unit test). The live value comes from clarify.timeout.
600- EXPIRED =
Distinct from a plain nil (non-interactive session): EXPIRED means the human was asked but did not answer within clarify.timeout, so the caller surfaces TIMED_OUT (still a clean, non-error outcome) rather than the NO_ANSWER “no interactive input available” message.
Object.new.freeze
Instance Attribute Summary
Attributes inherited from Base
#cancel_token, #read_tracker, #stream_chunk, #stream_kind
Instance Method Summary collapse
- #call(arguments) ⇒ Object
- #description ⇒ Object
- #input_schema ⇒ Object
- #name ⇒ Object
- #risk_level ⇒ Object
Methods inherited from Base
#cancellation_requested?, #config_key, #display_name, #emit_chunk, #mcp?, #risky?, #to_tool_definition, workspace_root, workspace_roots
Instance Method Details
#call(arguments) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rubino/tools/question_tool.rb', line 82 def call(arguments) question = arguments["question"] || arguments[:question] = arguments["options"] || arguments[:options] multiple = arguments["multiple"] || arguments[:multiple] || false ui = Rubino.ui if && !.empty? (ui, question, , multiple) else ask_freeform(ui, question) end end |
#description ⇒ Object
14 15 16 17 18 |
# File 'lib/rubino/tools/question_tool.rb', line 14 def description "Ask the user a question with optional predefined choices. " \ "Use this when you need clarification, user preferences, or a decision. " \ "The user can select from options or type a custom answer." end |
#input_schema ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubino/tools/question_tool.rb', line 20 def input_schema { type: "object", properties: { question: { type: "string", description: "The question to ask the user" }, options: { type: "array", items: { type: "object", properties: { label: { type: "string", description: "Short display text for the option" }, description: { type: "string", description: "Explanation of this choice" } }, required: %w[label] }, description: "Available choices (optional). A 'Type your own' option is added automatically." }, multiple: { type: "boolean", description: "Allow selecting multiple choices (default: false)" } }, required: %w[question] } end |
#name ⇒ Object
10 11 12 |
# File 'lib/rubino/tools/question_tool.rb', line 10 def name "question" end |
#risk_level ⇒ Object
49 50 51 |
# File 'lib/rubino/tools/question_tool.rb', line 49 def risk_level :low end |