(
&self,
effective_prompt: &str,
tool_name: &str,
output: &str,
exit_code: i32,
event_tx: &Option<mpsc::Sender<AgentEvent>>,
)
| 3 | |
| 4 | impl AgentLoop { |
| 5 | pub(super) async fn remember_tool_result( |
| 6 | &self, |
| 7 | effective_prompt: &str, |
| 8 | tool_name: &str, |
| 9 | output: &str, |
| 10 | exit_code: i32, |
| 11 | event_tx: &Option<mpsc::Sender<AgentEvent>>, |
| 12 | ) { |
| 13 | let Some(ref memory) = self.config.memory else { |
| 14 | return; |
| 15 | }; |
| 16 | |
| 17 | let tools_used = [tool_name.to_string()]; |
| 18 | let remember_result = if exit_code == 0 { |
| 19 | memory |
| 20 | .remember_success(effective_prompt, &tools_used, output) |
| 21 | .await |
| 22 | } else { |
| 23 | memory |
| 24 | .remember_failure(effective_prompt, output, &tools_used) |
| 25 | .await |
| 26 | }; |
| 27 | |
| 28 | match remember_result { |
| 29 | Ok(()) => { |
| 30 | if let Some(tx) = event_tx { |
| 31 | let item_type = if exit_code == 0 { "success" } else { "failure" }; |
| 32 | tx.send(AgentEvent::MemoryStored { |
| 33 | memory_id: uuid::Uuid::new_v4().to_string(), |
| 34 | memory_type: item_type.to_string(), |
| 35 | importance: if exit_code == 0 { 0.8 } else { 0.9 }, |
| 36 | tags: vec![item_type.to_string(), tool_name.to_string()], |
| 37 | }) |
| 38 | .await |
| 39 | .ok(); |
| 40 | } |
| 41 | } |
| 42 | Err(e) => { |
| 43 | tracing::warn!("Failed to store memory after tool execution: {}", e); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } |
no test coverage detected