feat(FN-3914): add durable heartbeat model fallback
Adds durable heartbeat model fallback logic to the engine's heartbeat subsystem (`agent-heartbeat.ts`, `agent-session-helpers.ts`, `pi.ts`), allowing heartbeats to gracefully use alternative AI models when the primary model is unavailable, with documentation updates to `agents.md` and `settings-refe Fusion-Task-Id: FN-3914
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { extractRuntimeHint, resolveMergerSessionModel } from "../agent-session-helpers.js";
|
||||
import {
|
||||
extractRuntimeHint,
|
||||
resolveHeartbeatSessionModels,
|
||||
resolveMergerSessionModel,
|
||||
} from "../agent-session-helpers.js";
|
||||
|
||||
describe("extractRuntimeHint", () => {
|
||||
it("returns undefined for undefined config", () => {
|
||||
@@ -23,6 +27,53 @@ describe("extractRuntimeHint", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveHeartbeatSessionModels", () => {
|
||||
it("uses agent runtime model as primary and execution settings as fallback", () => {
|
||||
expect(resolveHeartbeatSessionModels(
|
||||
{
|
||||
executionProvider: "openai",
|
||||
executionModelId: "gpt-4.1",
|
||||
},
|
||||
{ model: "anthropic/claude-sonnet-4-5" },
|
||||
)).toEqual({
|
||||
defaultProvider: "anthropic",
|
||||
defaultModelId: "claude-sonnet-4-5",
|
||||
fallbackProvider: "openai",
|
||||
fallbackModelId: "gpt-4.1",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses execution settings model when runtime override is missing", () => {
|
||||
expect(resolveHeartbeatSessionModels(
|
||||
{
|
||||
executionProvider: "openai",
|
||||
executionModelId: "gpt-4.1",
|
||||
},
|
||||
{},
|
||||
)).toEqual({
|
||||
defaultProvider: "openai",
|
||||
defaultModelId: "gpt-4.1",
|
||||
fallbackProvider: undefined,
|
||||
fallbackModelId: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("does not duplicate fallback when runtime and execution model are the same", () => {
|
||||
expect(resolveHeartbeatSessionModels(
|
||||
{
|
||||
executionProvider: "openai",
|
||||
executionModelId: "gpt-4.1",
|
||||
},
|
||||
{ modelProvider: "openai", modelId: "gpt-4.1" },
|
||||
)).toEqual({
|
||||
defaultProvider: "openai",
|
||||
defaultModelId: "gpt-4.1",
|
||||
fallbackProvider: undefined,
|
||||
fallbackModelId: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveMergerSessionModel", () => {
|
||||
it("uses assigned agent runtime model when both provider and modelId are present", () => {
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user