xonecas.io
64875
Mc

mini-coder / commit 1e8c453

fix: log turn errors before context is cleared

Add logError call inside the setLogContext scope so stream failures
(e.g. silent provider disconnects mid-tool-loop) are captured in the
session logs for debugging. Previously the error was only caught after
the log context was nulled, so nothing was recorded.

xonecas2026-03-21 1e8c453bc608de309831481a3b5d3fa3a6941d22 parent ba9632c

1 file changed

src/agent/session-runner.ts+4−1
@@ -10,7 +10,7 @@ import {
1010 compactToolResultPayloads,
1111 } from "../llm-api/turn-context.ts";
1212 import type { ToolDef } from "../llm-api/types.ts";
13-import { setLogContext } from "../logging/context.ts";
13+import { logError, setLogContext } from "../logging/context.ts";
1414 import { getDb, getMaxTurnIndex, saveMessages } from "../session/db/index.ts";
1515 import { LogsRepo } from "../session/db/logs-repo.ts";
1616 import type { ActiveSession } from "../session/manager.ts";
@@ -242,6 +242,9 @@ export class SessionRunner {
242242 this.coreHistory = compactToolResultPayloads(
243243 applyContextPruning(this.coreHistory),
244244 );
245+ } catch (err) {
246+ logError(err, "processUserInput turn failed");
247+ throw err;
245248 } finally {
246249 setLogContext(null);
247250 }