feat(FN-2088): merge fusion/fn-2088

This commit is contained in:
gsxdsm
2026-04-18 23:22:26 -07:00
parent 456c8ed6e6
commit c77a4a572e
11 changed files with 756 additions and 74 deletions

View File

@@ -34,6 +34,7 @@ import {
} from "./skill-resolver.js";
import { isContextLimitError } from "./context-limit-detector.js";
import { createFusionAuthStorage, getModelRegistryModelsPath } from "./auth-storage.js";
import { piLog } from "./logger.js";
export interface AgentResult {
session: AgentSession;
@@ -292,8 +293,9 @@ export async function compactSessionContext(
};
}
return null;
} catch {
// Compaction failed — return null so caller can fall through to kill/requeue
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
piLog.warn(`Context compaction failed (will fall through to kill/requeue): ${msg}`);
return null;
}
}
@@ -826,8 +828,9 @@ export async function createKbAgent(options: AgentOptions): Promise<AgentResult>
usingFallback = true;
try {
session.dispose();
} catch {
// ignore dispose errors while swapping sessions
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
piLog.warn(`Failed to dispose session during model fallback swap: ${msg}`);
}
const fallbackSessionResult = await createSessionWithModel(fallbackModel);