Remember a failure to avoid repeating
(
&self,
prompt: &str,
error: &str,
attempted_tools: &[String],
)
| 181 | |
| 182 | /// Remember a failure to avoid repeating |
| 183 | pub async fn remember_failure( |
| 184 | &self, |
| 185 | prompt: &str, |
| 186 | error: &str, |
| 187 | attempted_tools: &[String], |
| 188 | ) -> anyhow::Result<()> { |
| 189 | let content = format!( |
| 190 | "Failure: {}\nError: {}\nAttempted tools: {}", |
| 191 | prompt, |
| 192 | error, |
| 193 | attempted_tools.join(", ") |
| 194 | ); |
| 195 | let item = MemoryItem::new(content) |
| 196 | .with_importance(0.9) |
| 197 | .with_tag("failure") |
| 198 | .with_tag("avoid") |
| 199 | .with_type(MemoryType::Episodic) |
| 200 | .with_metadata("prompt", prompt) |
| 201 | .with_metadata("error", error); |
| 202 | self.remember(item).await |
| 203 | } |
| 204 | |
| 205 | /// Recall similar past experiences |
| 206 | pub async fn recall_similar( |