Skip to main content
IntentLang
← All examples

GroundedAnswer

examples/GroundedAnswer.intent

GroundedAnswer.intent
1mission GroundedAnswer
2use product
3use delivery
4
5title "Answer a support question, grounded in retrieved documents, or escalate"
6for SupportSeeker
7
8goal
9 Answer only what the retrieved documents support, and escalate the rest to a human.
10
11# The heart of an AI feature stated as intent: the model assists, but grounding, authorization,
12# and escalation are DETERMINISTIC guardrails , not left to a prompt.
13guarantee every answer is grounded in at least one retrieved document
14 because an ungrounded answer is a confident guess, and confident guesses erode trust
15 verify grounding test on retrievedCount
16
17guarantee a low-confidence question is escalated, never answered by guess
18 because a wrong answer costs more than a slower one
19 verify escalation-on-low-confidence test
20
21never present generated text as a cited fact when retrieval did not support it
22 verify citation-grounding test
23never return a document the requester is not authorized to see
24 verify authorization test
25
26outcome SelfServeDeflection
27 "more questions are answered well without a human, without lowering answer quality"
28
29metric deflection_rate
30 baseline 41%
31 target 65%
32 window 30 days after release
33
34# What the system does with a drafted answer. The AI drafts; this decides.
35# intent run GroundedAnswer.intent
36# --inputs '{"retrievedCount":3,"confidence":88,"authorized":true}'
37decision AnswerAction
38 inputs
39 retrievedCount
40 confidence
41 authorized
42 rule noRetrieval
43 when retrievedCount == 0
44 return Refuse
45 rule unauthorized
46 when authorized == false
47 return Refuse
48 rule lowConfidence
49 when confidence < 70
50 return Escalate
51 default
52 return Answer
53
54# The life of a question. Walk it: intent simulate GroundedAnswer.intent
55# --events retrieve,draft,ground,answer
56lifecycle AnswerFlow
57 state Received
58 state Retrieved
59 state Drafted
60 state Grounded
61 state Answered
62 state Escalated
63 transition retrieve
64 from Received
65 to Retrieved
66 transition draft
67 from Retrieved
68 to Drafted
69 transition ground
70 from Drafted
71 to Grounded
72 transition answer
73 from Grounded
74 to Answered
75 transition escalate
76 from Drafted
77 to Escalated
78 terminal Answered, Escalated
79
80# The commitment + the delivery result: intent outcomes GroundedAnswer.intent
81outcome_contract AnswerDeflection
82 outcome SelfServeDeflection
83 metric deflection_rate
84 baseline 41%
85 target 65%
86 window 30 days after release
87 owner SupportLead
88
89result Q3Deflection
90 measures SelfServeDeflection
91 metric deflection_rate
92 value 67%
93 baseline 41%
94
95# The spec proves itself: intent test GroundedAnswer.intent
96test AnswerAction
97 case grounded and confident is answered
98 given retrievedCount 3, confidence 88, authorized true
99 expect Answer
100 case no retrieval refuses
101 given retrievedCount 0, confidence 90, authorized true
102 expect Refuse
103 case unauthorized refuses
104 given retrievedCount 3, confidence 90, authorized false
105 expect Refuse
106 case low confidence escalates
107 given retrievedCount 3, confidence 55, authorized true
108 expect Escalate
109
110test AnswerFlow
111 scenario grounded answer
112 events retrieve, draft, ground, answer
113 expect Answered
114 valid
115 scenario escalated from draft
116 events retrieve, draft, escalate
117 expect Escalated
118 valid
119 scenario cannot answer before grounding
120 events retrieve, draft, answer
121 invalid
Draft syntax. This file is illustrative and does not run yet.