Skip to main content

ag_protocol/
question.rs

1//! Clarification question model shared across domain, UI, and protocol code.
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6/// One extracted question with predefined answer choices.
7///
8/// The UI, persistence, and structured agent protocol all use this as the
9/// canonical clarification question representation.
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
11#[schemars(
12    title = "QuestionItem",
13    description = "One clarification question emitted by the assistant protocol payload. Keep \
14                   each item focused to one actionable decision."
15)]
16pub struct QuestionItem {
17    /// Predefined answer choices the user can select from.
18    #[serde(default)]
19    #[schemars(
20        title = "options",
21        description = "Predefined answer choices the user can select from. Keep this list focused \
22                       to 1-3 likely answers, put the recommended choice first, and omit deferral \
23                       or non-answer choices. Defaults to an empty list when omitted."
24    )]
25    pub options: Vec<String>,
26    /// The clarification question text.
27    #[schemars(
28        title = "text",
29        description = "Human-readable markdown text for this question. Ask one specific \
30                       actionable question instead of bundling multiple decisions into one item."
31    )]
32    pub text: String,
33}
34
35impl QuestionItem {
36    /// Constructs one clarification question without predefined answer
37    /// options.
38    pub fn new(text: impl Into<String>) -> Self {
39        Self {
40            options: Vec::new(),
41            text: text.into(),
42        }
43    }
44
45    /// Constructs one clarification question with predefined answer options.
46    pub fn with_options(text: impl Into<String>, options: Vec<String>) -> Self {
47        Self {
48            options,
49            text: text.into(),
50        }
51    }
52}