chore: promote read_file args to info log, fix content parsing
This commit is contained in:
+14
-3
@@ -307,10 +307,21 @@ async function runOllamaLoop(ctx: AgentRunContext): Promise<AgentResult> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Track read_file calls so we can reconstruct context after pruning.
|
// 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") {
|
if (toolName === "read_file") {
|
||||||
const path = (toolArgs as Record<string, unknown>)?.path;
|
const args = toolArgs as Record<string, unknown>;
|
||||||
if (typeof path === "string" && !readFileLog.has(path)) {
|
log.info(` read_file args keys: ${Object.keys(args).join(", ")} | path type: ${typeof args.path} | path: ${String(args.path).slice(0, 120)}`);
|
||||||
readFileLog.set(path, result.slice(0, 500));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user