fix(FN-2090): log and cover engine warning fallbacks

- Add structured warning logs for plugin-runner fallback paths instead of silent catches
- Add warning telemetry in agent-tools for agent-memory directory, QMD search, and index refresh failures
- Log cron-runner session disposal failures and update agent-logger persistence warnings to use logger output
- Expand engine tests to cover warning behavior across plugin-runner, agent-tools, cron-runner, and agent-logger
This commit is contained in:
Fusion
2026-04-18 22:18:55 -07:00
committed by gsxdsm
parent fce07dacbc
commit d1c097e825
8 changed files with 388 additions and 137 deletions

View File

@@ -6,8 +6,6 @@ const FLUSH_SIZE_BYTES = 1024;
/** Default timer interval (ms) for periodic flush of small writes. */
const FLUSH_INTERVAL_MS = 500;
const log = createLogger("agent-logger");
/**
* Produce a human-readable summary from tool arguments.
* Returns the full argument value without truncation.
@@ -92,6 +90,7 @@ export class AgentLogger {
private readonly agent?: AgentRole;
private readonly externalTextCb?: (taskId: string, delta: string) => void;
private readonly externalToolCb?: (taskId: string, toolName: string) => void;
private readonly log = createLogger("agent-logger");
constructor(options: AgentLoggerOptions) {
this.store = options.store;
@@ -151,12 +150,7 @@ export class AgentLogger {
this.flushThinkingBuffer();
const detail = summarizeToolArgs(name, args);
this.store.appendAgentLog(this.taskId, name, "tool", detail, this.agent).catch((err) => {
log.warn(
"Failed to persist tool-start log for task %s (tool: %s): %s",
this.taskId,
name,
err instanceof Error ? err.message : String(err),
);
this.log.warn(`Failed to log tool start "${name}" for ${this.taskId}: ${err instanceof Error ? err.message : String(err)}`);
});
}
@@ -176,13 +170,7 @@ export class AgentLogger {
detail = str.length > 500 ? str.slice(0, 500) + "…" : str;
}
this.store.appendAgentLog(this.taskId, name, type, detail, this.agent).catch((err) => {
log.warn(
"Failed to persist tool-end log for task %s (tool: %s, type: %s): %s",
this.taskId,
name,
type,
err instanceof Error ? err.message : String(err),
);
this.log.warn(`Failed to log tool end "${name}" (${type}) for ${this.taskId}: ${err instanceof Error ? err.message : String(err)}`);
});
}
@@ -204,11 +192,7 @@ export class AgentLogger {
const chunk = this.textBuffer;
this.textBuffer = "";
return this.store.appendAgentLog(this.taskId, chunk, "text", undefined, this.agent).catch((err) => {
log.warn(
"Failed to persist text log for task %s: %s",
this.taskId,
err instanceof Error ? err.message : String(err),
);
this.log.warn(`Failed to flush text buffer for ${this.taskId}: ${err instanceof Error ? err.message : String(err)}`);
});
}
@@ -217,11 +201,7 @@ export class AgentLogger {
const chunk = this.thinkingBuffer;
this.thinkingBuffer = "";
return this.store.appendAgentLog(this.taskId, chunk, "thinking", undefined, this.agent).catch((err) => {
log.warn(
"Failed to persist thinking log for task %s: %s",
this.taskId,
err instanceof Error ? err.message : String(err),
);
this.log.warn(`Failed to flush thinking buffer for ${this.taskId}: ${err instanceof Error ? err.message : String(err)}`);
});
}