Add result to execution history (internal method)
(&self, result: ToolResult)
| 401 | |
| 402 | /// Add result to execution history (internal method) |
| 403 | fn add_to_history(&self, result: ToolResult) -> PyResult<()> { |
| 404 | let mut history = self.execution_history.write().map_err(|e| { |
| 405 | PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!( |
| 406 | "Failed to acquire history lock: {}", |
| 407 | e |
| 408 | )) |
| 409 | })?; |
| 410 | |
| 411 | history.push(result); |
| 412 | |
| 413 | // Keep only last 1000 executions to prevent memory bloat |
| 414 | if history.len() > 1000 { |
| 415 | let len = history.len(); |
| 416 | history.drain(0..len - 1000); |
| 417 | } |
| 418 | |
| 419 | Ok(()) |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | impl Default for ToolRegistry { |