chore: promote read_file args to info log, fix content parsing

This commit is contained in:
2026-06-01 13:51:26 -05:00
parent 3501548543
commit a9bcdd77dd
+14 -3
View File
@@ -307,10 +307,21 @@ async function runOllamaLoop(ctx: AgentRunContext): Promise<AgentResult> {
});
// Track read_file calls so we can reconstruct context after pruning.
// read_file returns { content: "..." } JSON — parse out the actual content.
// Promote args logging to info so we can diagnose the path key format.
if (toolName === "read_file") {
const path = (toolArgs as Record<string, unknown>)?.path;
if (typeof path === "string" && !readFileLog.has(path)) {
readFileLog.set(path, result.slice(0, 500));
const args = toolArgs as Record<string, unknown>;
log.info(` read_file args keys: ${Object.keys(args).join(", ")} | path type: ${typeof args.path} | path: ${String(args.path).slice(0, 120)}`);
const path = typeof args.path === "string" ? args.path : undefined;
if (path && !readFileLog.has(path)) {
let excerpt: string;
try {
const parsed = JSON.parse(result) as { content?: string };
excerpt = (parsed.content ?? result).slice(0, 500);
} catch {
excerpt = result.slice(0, 500);
}
readFileLog.set(path, excerpt);
}
}