Expand description
Tool for asking structured questions to the user.
Question provides a way for LLM agents to ask the user for
information in a structured, efficient way. Supports free-text and
choice questions (single/multi select) and allows asking several
questions at once to minimize back-and-forth.
§Design principles
- Market-standard wire format: the schema mirrors Claude Code’s
AskUserQuestion(and its ports — Qwen Code, OpenCode, Crush): aquestionsarray of{ question, header, options: [{label, description}], multiSelect }items. Models trained on any of those harnesses emit a valid call on the first attempt. - Lenient decoding of model emission variants: plain-string options,
string-encoded arrays, the
multiplealias, and header-only items all parse — seetypes::QuestionItem’s custom deserializer. These are model behaviors, not alternate schemas. - Batch questions: ask multiple questions in a single call.
- Purpose field: each question may explain why the information is needed.
- Recommendations by convention: the recommended option is the FIRST
option carrying a
" (Recommended)"label suffix — the convention models already know. The suffix is stripped wherever it appears and turned into the internalrecommendedbadge.
§Example
ⓘ
use cosh_tools::question::Question;
use cosh_tools::question::types::QuestionInput;
let q = Question::new();
let input: QuestionInput = serde_json::from_value(serde_json::json!({
"questions": [{
"question": "Which auth method?",
"header": "Auth method",
"options": [
{"label": "OAuth 2.0 (Recommended)", "description": "Browser flow"},
{"label": "API key", "description": "Static token"}
]
}]
}))?;
let output = q.ask(&input)?;Modules§
Structs§
- Question
- Tool for asking structured questions to the user.