From 406ab0f4ac247e444bd96c4de14960f195621ea8 Mon Sep 17 00:00:00 2001 From: bonigo1998 Date: Sun, 27 Sep 2026 03:30:32 -0500 Subject: [PATCH] feat: log workspace file tool outcomes --- src/agent_loop.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/agent_loop.cpp b/src/agent_loop.cpp index cb4af7a..5fc3e11 100644 --- a/src/agent_loop.cpp +++ b/src/agent_loop.cpp @@ -135,17 +135,42 @@ std::string AgentLoop::run( {"tool_calls", response.tool_calls} }); + logger_.log("tool_start", { + {"step", step + 1}, + {"tool", "read_file"} + }); + std::cout << "Using read_file tool...\n" << std::flush; std::string tool_result; try { tool_result = file_tool_.read(path); + const auto bytes = tool_result.size(); + + if (bytes > max_file_bytes) { + logger_.log("tool_error", { + {"step", step + 1}, + {"tool", "read_file"}, + {"reason", "file_too_large"}, + {"bytes", bytes} + }); - if (tool_result.size() > max_file_bytes) { tool_result = "File is too large to send to the model."; + } else { + logger_.log("tool_success", { + {"step", step + 1}, + {"tool", "read_file"}, + {"bytes", bytes} + }); } } catch (const std::exception& error) { + logger_.log("tool_error", { + {"step", step + 1}, + {"tool", "read_file"}, + {"reason", "read_failed"} + }); + tool_result = std::string("File error: ") + error.what(); }