Fire PrePrompt hook event before prompt augmentation. Returns optional modified prompt text from the hook.
(
&self,
session_id: &str,
prompt: &str,
system_prompt: &Option<String>,
message_count: usize,
)
| 402 | /// Fire PrePrompt hook event before prompt augmentation. |
| 403 | /// Returns optional modified prompt text from the hook. |
| 404 | async fn fire_pre_prompt( |
| 405 | &self, |
| 406 | session_id: &str, |
| 407 | prompt: &str, |
| 408 | system_prompt: &Option<String>, |
| 409 | message_count: usize, |
| 410 | ) -> Option<String> { |
| 411 | if let Some(he) = &self.config.hook_engine { |
| 412 | let event = HookEvent::PrePrompt(PrePromptEvent { |
| 413 | session_id: session_id.to_string(), |
| 414 | prompt: prompt.to_string(), |
| 415 | system_prompt: system_prompt.clone(), |
| 416 | message_count, |
| 417 | }); |
| 418 | let result = he.fire(&event).await; |
| 419 | if let HookResult::Continue(Some(modified)) = result { |
| 420 | // Extract modified prompt from hook response |
| 421 | if let Some(new_prompt) = modified.get("prompt").and_then(|v| v.as_str()) { |
| 422 | return Some(new_prompt.to_string()); |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | None |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | /// Render the always-on `<env>` grounding block. |
no test coverage detected