feat: add agent runtime info tracking with model detection from rollout files

This commit is contained in:
Mohamed Boudra
2025-12-21 23:16:49 +07:00
parent a70842d9ef
commit abe3a42478
23 changed files with 1243 additions and 159 deletions
@@ -0,0 +1,22 @@
import { describe, expect, it } from "vitest";
import type { Agent } from "@/stores/session-store";
import { extractAgentModel } from "./extract-agent-model";
describe("extractAgentModel", () => {
it("returns runtime model when present", () => {
const agent = {
runtimeInfo: { model: "gpt-5.2-codex" },
} as Partial<Agent> as Agent;
expect(extractAgentModel(agent)).toBe("gpt-5.2-codex");
});
it("returns null when runtime model missing even if config model is set", () => {
const agent = {
model: "gpt-5.1-codex",
runtimeInfo: {},
} as Partial<Agent> as Agent;
expect(extractAgentModel(agent)).toBeNull();
});
});
@@ -0,0 +1,9 @@
import type { Agent } from "@/stores/session-store";
export function extractAgentModel(agent?: Agent | null): string | null {
if (!agent) return null;
const runtimeModel = agent.runtimeInfo?.model;
return typeof runtimeModel === "string" && runtimeModel.trim().length > 0
? runtimeModel.trim()
: null;
}