22//!
33//! This is the client-side state machine that decides, after a turn ends, what
44//! (if anything) to send next: the incomplete-todo poke, the one-shot
5- //! long-session review, the deferred gate digest , the ownership gate, the
6- //! completion-confidence and confidence-spike checks, and the final-response
5+ //! long-session review, the ownership gate, the completion-confidence and
6+ //! confidence-spike checks, and the final-response
77//! handoff. It is a faithful port of the TUI's `schedule_auto_poke_followup`
88//! so every client (TUI, Desktop, SDK users) runs the same policy.
99//!
1414use crate :: {
1515 ConfidenceState , GateObservation , TODO_FINAL_RESPONSE_CONTINUATION_MESSAGE ,
1616 TODO_LONG_SESSION_REVIEW_MESSAGE , TodoGoal , TodoItem , TodoPlan , build_auto_poke_message,
17- build_gate_digest , build_todo_completion_continuation_message ,
18- build_todo_confidence_spike_continuation_message , build_todo_ownership_continuation_message ,
19- completed_groups_have_sufficient_delivery , completion_confidence_passes, spike_completed_todos,
20- todo_status_is_cancelled , todo_status_is_completed,
17+ build_todo_completion_continuation_message , build_todo_confidence_spike_continuation_message ,
18+ build_todo_ownership_continuation_message , completed_groups_have_sufficient_delivery ,
19+ completion_confidence_passes, spike_completed_todos, todo_status_is_cancelled ,
20+ todo_status_is_completed,
2121} ;
2222use serde:: { Deserialize , Serialize } ;
2323
@@ -113,7 +113,6 @@ pub struct FollowUpPolicy {
113113 default_on : bool ,
114114 final_response_requested : bool ,
115115 final_response_fingerprint : Option < String > ,
116- digest_delivered : bool ,
117116 gate_attempts : u8 ,
118117 spike_challenged : bool ,
119118 last_ownership_fingerprint : Option < String > ,
@@ -180,7 +179,6 @@ impl FollowUpPolicy {
180179 }
181180 self . final_response_fingerprint = None ;
182181 self . final_response_requested = false ;
183- self . digest_delivered = false ;
184182 self . gate_attempts = 0 ;
185183 self . spike_challenged = false ;
186184 self . last_ownership_fingerprint = None ;
@@ -213,22 +211,12 @@ impl FollowUpPolicy {
213211 return Decision :: default ( ) ;
214212 }
215213
216- // Deferred quality checks land once, at the end of the work.
217- let mut effects = TodoEffects :: default ( ) ;
218- if !self . digest_delivered && !snapshot. gate_observations . is_empty ( ) {
219- effects. clear_gate_observations = true ;
220- if let Some ( digest) =
221- build_gate_digest ( & snapshot. gate_observations , & snapshot. plan , goals)
222- {
223- self . digest_delivered = true ;
224- return Decision :: send (
225- FollowUpKind :: GateDigest ,
226- digest,
227- "🔍 We asked the agent to double-check this turn's weak points." ,
228- )
229- . with_effects ( effects) ;
230- }
231- }
214+ // Weak-point observations remain diagnostic data, not a reason to
215+ // inject another conversation turn before the agent can finish.
216+ let effects = TodoEffects {
217+ clear_gate_observations : !snapshot. gate_observations . is_empty ( ) ,
218+ ..TodoEffects :: default ( )
219+ } ;
232220
233221 let ownership_needs_followup = !completed_groups_have_sufficient_delivery ( todos, goals) ;
234222 let gate_budget_left = self . gate_attempts < MAX_GATE_ATTEMPTS ;
@@ -278,7 +266,6 @@ impl FollowUpPolicy {
278266 self . armed = false ;
279267 self . spike_challenged = false ;
280268 self . gate_attempts = 0 ;
281- self . digest_delivered = false ;
282269 return Decision {
283270 notice : Some (
284271 "⚠️ We nudged the agent several times but its validation still isn't holding up. We stopped poking; review the remaining todos yourself."
@@ -291,7 +278,6 @@ impl FollowUpPolicy {
291278
292279 // Cycle finished cleanly.
293280 self . armed = self . default_on ;
294- self . digest_delivered = false ;
295281 self . gate_attempts = 0 ;
296282 if !self . final_response_requested {
297283 self . final_response_requested = true ;
0 commit comments