Fire IntentDetection hook and wait for harness decision. This is called on every prompt to detect user intent via the AHP harness. Returns the detected intent if the harness provides one, or None if blocked/failed.
(
&self,
prompt: &str,
session_id: &str,
workspace: &str,
)
| 282 | /// This is called on every prompt to detect user intent via the AHP harness. |
| 283 | /// Returns the detected intent if the harness provides one, or None if blocked/failed. |
| 284 | async fn fire_intent_detection( |
| 285 | &self, |
| 286 | prompt: &str, |
| 287 | session_id: &str, |
| 288 | workspace: &str, |
| 289 | ) -> Option<context_perception::IntentDetectionResult> { |
| 290 | let event = IntentDetectionEvent { |
| 291 | session_id: session_id.to_string(), |
| 292 | prompt: prompt.to_string(), |
| 293 | workspace: workspace.to_string(), |
| 294 | language_hint: context_perception::detect_language_hint(prompt), |
| 295 | }; |
| 296 | |
| 297 | let hook_result = if let Some(he) = &self.config.hook_engine { |
| 298 | let hook_event = HookEvent::IntentDetection(event); |
| 299 | he.fire(&hook_event).await |
| 300 | } else { |
| 301 | return None; |
| 302 | }; |
| 303 | |
| 304 | match hook_result { |
| 305 | HookResult::Continue(Some(modified)) => { |
| 306 | // Parse the intent detection result |
| 307 | serde_json::from_value::<context_perception::IntentDetectionResult>(modified).ok() |
| 308 | } |
| 309 | HookResult::Block(_) => { |
| 310 | // Harness blocked intent detection - use fallback |
| 311 | tracing::info!("AHP harness blocked intent detection"); |
| 312 | None |
| 313 | } |
| 314 | _ => None, |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /// Apply injected context from AHP harness decision. |
| 319 | #[cfg(feature = "ahp")] |
no test coverage detected