mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 15:01:35 +00:00
* refactor(agents): require explicit roster defaults * feat(onboard): create named first roster agent * refactor(agents): remove runtime main fallbacks * style(agents): apply roster refactor formatting * refactor(agents): finish roster-only runtime sweep * fix(doctor): migrate legacy main session sqlite * fix(doctor): harden roster session migrations * fix(onboard): commit first agent atomically * fix(config): support empty-roster analysis * fix(agents): preserve legacy main state during creation * fix(setup): materialize baseline agent roster * fix(agents): harden legacy default transfer recovery * fix(agents): simplify roster-only legacy compatibility * fix(agents): preserve staged first-agent entries * fix(config): migrate persisted implicit-main rosters * fix(config): preserve staged empty rosters * fix(agents): finalize roster-only upgrade paths * fix(sessions): close legacy main migration outcomes * fix(config): migrate legacy roster markers at load * fix(sessions): preserve roster upgrade history * refactor(sessions): restore lean legacy main compatibility * fix(setup): prepare first-agent credentials before publish * fix(config): stabilize roster snapshot migration * refactor(sessions): shrink legacy main compatibility * fix(agents): restore roster compatibility fidelity * fix(sessions): preserve divergent legacy history * refactor(agents): narrow roster-only scope * fix(config): isolate roster migration * test(agents): align roster-only fixtures * fix(agents): keep main agent undeletable * fix(agents): harden roster migration invariants * fix(agents): close setup and audit scope gaps * fix(cron): scope session reaper throttles by agent * fix(agents): preserve scoped owner precedence * fix(config): preserve authored config ownership * fix(setup): keep default workspace and roster in sync * fix(setup): preserve default entry workspace on bare runs * fix(agents): adapt roster rebase to keyed entries * fix(agents): honor both roster representations * fix(agents): route roster reads through shared helpers * fix(config): preserve canonical roster writes * fix(cron): resolve dynamic default for session reaper * fix(agents): close dynamic default migration gaps * fix(agents): align scoped session ownership * fix(sessions): preserve legacy main directory casing * fix(agents): align cron and legacy auth ownership * fix(setup): provision the committed default workspace * fix(cron): align scoped ownership and reaping * fix(cron): treat blank agent ids as absent * fix(cron): retain configured session-store owners * fix(agents): repair roster-aware CI boundaries * fix(cron): preserve scoped ownership resolution * fix(agents): preserve rosterless maintenance paths * fix(agents): propagate roster ownership through runtime boundaries * fix(agents): preserve roster ownership across runtime paths * fix(agents): harden roster diagnostics and legacy routing * fix(agents): remove redundant diagnostic import * test(agents): type CLI policy fixture explicitly * fix(config): preserve canonical roster mutation identity * fix(doctor): read canonical agent rosters consistently * fix(config): resolve compound roster unsets safely * fix(config): finalize main-session reconciliation * fix(doctor): read canonical session state safely * fix(sessions): preserve current visibility alias * fix(config): track roster include provenance * test(config): type roster provenance cases * fix(config): refine roster include ownership * fix(agents): preserve staged roster invariants * test(config): align fixtures with explicit roster ownership * test(node-host): preserve optional plan typing * fix(config): preserve authored roster projections * test(config): keep raw roster fixtures explicit * test(config): normalize rosters at runtime fixtures * fix(config): protect authored roster ownership * fix(agents): require explicit session ownership * fix(agents): enforce scoped roster ownership * fix(sessions): merge fixed-store agent partitions * fix(agents): harden roster ownership boundaries * fix(config): reject ambiguous roster projections * fix(sessions): preserve persisted store ownership * fix(sessions): keep collision diagnostics additive * fix(security): scan malformed roster workspaces * test(config): align snapshot fixtures after rebase * test(agents): use explicit roster fixtures * fix(config): harden roster diagnostic boundaries * fix(sessions): isolate fixed-store agent databases * test(agents): type malformed default markers * refactor(sessions): extract store collision resolution * test(system-agent): split oversized setup coverage * style(system-agent): format split setup suite * fix(sessions): preserve promoted store ownership * fix(sessions): derive scoped owner before target * fix(sessions): preserve explicit sqlite ownership * fix(agents): restore roster compatibility across CI * fix(agents): enforce roster-owned runtime boundaries * fix(agents): satisfy default lookup lint * test(sessions): split known-owner coverage * fix(state): satisfy path identity lint * fix(agents): preserve malformed roster safety boundaries * fix(agents): restore roster compatibility at runtime boundaries * fix(config): satisfy roster boundary type checks * fix(agents): preserve roster ownership across runtime probes Setup inference probes now execute as the configured roster owner. Malformed agent-prefixed session rows are intentionally omitted by the fail-closed visibility contract rather than normalized by tests. * fix(agents): satisfy session list owner lint * fix(agents): preserve roster-owned runtime boundaries Restore shared logical rows for exact SQLite session locators while keeping their physical database owner separate. The ownership regression test now constructs an explicit sole-owner database directly instead of relying on first-touch capture, matching the intentional shared-store contract. * fix(sessions): preserve multiply owned exact stores * fix(sessions): restore runtime owner boundaries Keep incognito sentinels agent-owned, fold default-agent approvals into the global snapshot, and preserve the configless legacy-main CLI policy fallback. Also repair the existing CLI watchdog test lifecycle so the compact shard observes its timeout without an unawaited assertion or async timer stall; product behavior is unchanged by that test-only fix. * test(ci): align owner-scoped fixtures These assertions are unchanged. The fixtures now declare the intended non-default runner, expose the session-key constant imported by production status code, and select the main approvals bucket explicitly on Windows. * fix(agents): close final roster ownership gaps
393 lines
11 KiB
TypeScript
393 lines
11 KiB
TypeScript
// Status summary runtime tests cover model context-token resolution.
|
|
import { describe, expect, it } from "vitest";
|
|
import { ANTHROPIC_CONTEXT_1M_TOKENS } from "../agents/context-resolution.js";
|
|
import { migratePersistedImplicitMainRoster } from "../config/legacy.roster.js";
|
|
import { statusSummaryRuntime } from "./status.summary.runtime.js";
|
|
|
|
function resolveSessionRuntimeLabel(
|
|
params: Parameters<typeof statusSummaryRuntime.resolveSessionRuntimeLabel>[0],
|
|
) {
|
|
return statusSummaryRuntime.resolveSessionRuntimeLabel({
|
|
...params,
|
|
cfg: migratePersistedImplicitMainRoster(params.cfg).config as never,
|
|
});
|
|
}
|
|
|
|
describe("statusSummaryRuntime.resolveContextTokensForModel", () => {
|
|
it("does not match provider context window overrides across provider id variants", () => {
|
|
const contextTokens = statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg: {
|
|
models: {
|
|
providers: {
|
|
"z.ai": {
|
|
models: [{ id: "glm-4.7", contextWindow: 123_456 }],
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
provider: "z-ai",
|
|
model: "glm-4.7",
|
|
fallbackContextTokens: 999,
|
|
});
|
|
|
|
expect(contextTokens).toBe(999);
|
|
});
|
|
|
|
it("prefers per-model contextTokens over contextWindow", () => {
|
|
const contextTokens = statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg: {
|
|
models: {
|
|
providers: {
|
|
openai: {
|
|
models: [{ id: "gpt-5.4", contextWindow: 1_050_000, contextTokens: 272_000 }],
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
provider: "openai",
|
|
model: "gpt-5.4",
|
|
fallbackContextTokens: 999,
|
|
});
|
|
|
|
expect(contextTokens).toBe(272_000);
|
|
});
|
|
|
|
it("caps an oversized override without raising a lower override", () => {
|
|
const cfg = {
|
|
models: {
|
|
providers: {
|
|
openai: {
|
|
models: [{ id: "gpt-5.5", contextWindow: 272_000 }],
|
|
},
|
|
},
|
|
},
|
|
} as never;
|
|
const resolveOverride = (contextTokensOverride: number) =>
|
|
statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg,
|
|
provider: "openai",
|
|
model: "gpt-5.5",
|
|
contextTokensOverride,
|
|
fallbackContextTokens: 999,
|
|
});
|
|
|
|
expect(resolveOverride(1_000_000)).toBe(272_000);
|
|
expect(resolveOverride(128_000)).toBe(128_000);
|
|
});
|
|
|
|
it("caps cold-cache overrides with prepared static catalog metadata", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg: {},
|
|
provider: "openai",
|
|
model: "gpt-5.5",
|
|
modelContextWindow: 1_000_000,
|
|
modelContextTokens: 272_000,
|
|
contextTokensOverride: 1_000_000,
|
|
fallbackContextTokens: 200_000,
|
|
}),
|
|
).toBe(272_000);
|
|
});
|
|
|
|
it("combines configured native windows with lower prepared runtime caps", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg: {
|
|
models: {
|
|
providers: {
|
|
openai: {
|
|
models: [{ id: "gpt-5.5", contextWindow: 1_000_000 }],
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
provider: "openai",
|
|
model: "gpt-5.5",
|
|
modelContextTokens: 272_000,
|
|
contextTokensOverride: 1_000_000,
|
|
}),
|
|
).toBe(272_000);
|
|
});
|
|
|
|
it("matches self-prefixed configured ids through provider ownership", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg: {
|
|
models: {
|
|
providers: {
|
|
"google-gemini-cli": {
|
|
models: [
|
|
{
|
|
id: "google-gemini-cli/gemini-3.1-pro-preview",
|
|
contextTokens: 1_000_000,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
provider: "google-gemini-cli",
|
|
model: "gemini-3.1-pro-preview",
|
|
contextTokensOverride: 2_000_000,
|
|
}),
|
|
).toBe(1_000_000);
|
|
});
|
|
|
|
it("uses provider defaults and fixed Anthropic windows when capping overrides", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg: {
|
|
models: {
|
|
providers: {
|
|
ollama: {
|
|
contextWindow: 32_000,
|
|
models: [{ id: "qwen3.5:9b" }],
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
provider: "ollama",
|
|
model: "qwen3.5:9b",
|
|
contextTokensOverride: 100_000,
|
|
}),
|
|
).toBe(32_000);
|
|
|
|
expect(
|
|
statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg: {
|
|
models: {
|
|
providers: {
|
|
anthropic: {
|
|
models: [{ id: "claude-sonnet-4-6", contextWindow: 200_000 }],
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
sourceCfg: {},
|
|
provider: "anthropic",
|
|
model: "claude-sonnet-4-6",
|
|
contextTokensOverride: 1_200_000,
|
|
}),
|
|
).toBe(ANTHROPIC_CONTEXT_1M_TOKENS);
|
|
});
|
|
|
|
it.each([
|
|
{ contextTokens: 200_000, expected: 200_000 },
|
|
{ contextTokens: 2_000_000, expected: ANTHROPIC_CONTEXT_1M_TOKENS },
|
|
])(
|
|
"bounds Anthropic contextTokens=$contextTokens by the fixed native window",
|
|
({ contextTokens, expected }) => {
|
|
expect(
|
|
statusSummaryRuntime.resolveContextTokensForModel({
|
|
cfg: {
|
|
models: {
|
|
providers: {
|
|
anthropic: {
|
|
models: [
|
|
{
|
|
id: "claude-sonnet-4-6",
|
|
contextWindow: ANTHROPIC_CONTEXT_1M_TOKENS,
|
|
contextTokens,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
provider: "anthropic",
|
|
model: "claude-sonnet-4-6",
|
|
contextTokensOverride: 1_200_000,
|
|
}),
|
|
).toBe(expected);
|
|
},
|
|
);
|
|
});
|
|
|
|
describe("statusSummaryRuntime.classifySessionKey", () => {
|
|
it("classifies cron history sessions distinctly", () => {
|
|
expect(statusSummaryRuntime.classifySessionKey("agent:main:cron:daily-digest")).toBe("cron");
|
|
expect(
|
|
statusSummaryRuntime.classifySessionKey("agent:avery:cron:daily-digest:run:abc123"),
|
|
).toBe("cron");
|
|
});
|
|
});
|
|
|
|
describe("statusSummaryRuntime.resolveSessionRuntimeLabel", () => {
|
|
it("uses the shared /status runtime label for the implicit OpenAI Codex route", () => {
|
|
expect(
|
|
resolveSessionRuntimeLabel({
|
|
cfg: {} as never,
|
|
entry: {
|
|
sessionId: "session-1",
|
|
updatedAt: 0,
|
|
},
|
|
provider: "openai",
|
|
model: "gpt-5.5",
|
|
sessionKey: "agent:main:main",
|
|
}),
|
|
).toBe("OpenAI Codex");
|
|
});
|
|
|
|
it("preserves configured default model CLI runtimes", () => {
|
|
expect(
|
|
resolveSessionRuntimeLabel({
|
|
cfg: {
|
|
agents: {
|
|
defaults: {
|
|
models: {
|
|
"anthropic/claude-sonnet-4-6": { agentRuntime: { id: "claude-cli" } },
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
entry: {
|
|
sessionId: "session-1",
|
|
updatedAt: 0,
|
|
},
|
|
provider: "anthropic",
|
|
model: "claude-sonnet-4-6",
|
|
sessionKey: "agent:main:main",
|
|
}),
|
|
).toBe("Claude CLI");
|
|
});
|
|
|
|
it("preserves configured agent model runtimes before harness selection", () => {
|
|
expect(
|
|
resolveSessionRuntimeLabel({
|
|
cfg: {
|
|
agents: {
|
|
defaults: {
|
|
models: {
|
|
"openai/gpt-5.5": { agentRuntime: { id: "openclaw" } },
|
|
},
|
|
},
|
|
list: [
|
|
{
|
|
id: "research",
|
|
models: {
|
|
"openai/gpt-5.5": { agentRuntime: { id: "codex" } },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
} as never,
|
|
entry: {
|
|
sessionId: "session-1",
|
|
updatedAt: 0,
|
|
},
|
|
provider: "openai",
|
|
model: "gpt-5.5",
|
|
agentId: "research",
|
|
sessionKey: "agent:research:main",
|
|
}),
|
|
).toBe("OpenAI Codex");
|
|
});
|
|
|
|
it("reports the owning Codex harness for a locked session with stale OpenClaw metadata", () => {
|
|
expect(
|
|
resolveSessionRuntimeLabel({
|
|
cfg: {
|
|
agents: {
|
|
defaults: {
|
|
models: {
|
|
"openai/gpt-5.5": { agentRuntime: { id: "openclaw" } },
|
|
},
|
|
},
|
|
},
|
|
} as never,
|
|
entry: {
|
|
sessionId: "locked-codex-session",
|
|
updatedAt: 0,
|
|
agentHarnessId: "codex",
|
|
agentRuntimeOverride: "openclaw",
|
|
modelSelectionLocked: true,
|
|
},
|
|
provider: "openai",
|
|
model: "gpt-5.5",
|
|
sessionKey: "agent:main:main",
|
|
}),
|
|
).toBe("OpenAI Codex");
|
|
});
|
|
});
|
|
|
|
describe("statusSummaryRuntime.resolveSessionModelRef", () => {
|
|
const cfg = {
|
|
agents: {
|
|
defaults: {
|
|
model: { primary: "anthropic/claude-sonnet-4-6" },
|
|
},
|
|
},
|
|
} as never;
|
|
|
|
it("preserves explicit runtime providers for vendor-prefixed model ids", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveSessionModelRef(cfg, {
|
|
modelProvider: "openrouter",
|
|
model: "anthropic/claude-haiku-4.5",
|
|
}),
|
|
).toEqual({
|
|
provider: "openrouter",
|
|
model: "anthropic/claude-haiku-4.5",
|
|
});
|
|
});
|
|
|
|
it("splits legacy combined overrides when provider is missing", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveSessionModelRef(cfg, {
|
|
modelOverride: "ollama-beelink2/qwen2.5-coder:7b",
|
|
}),
|
|
).toEqual({
|
|
provider: "ollama-beelink2",
|
|
model: "qwen2.5-coder:7b",
|
|
});
|
|
});
|
|
|
|
it("uses the configured default provider for providerless runtime models", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveSessionModelRef(
|
|
{
|
|
agents: {
|
|
defaults: {
|
|
model: { primary: "openai/gpt-5.5" },
|
|
},
|
|
},
|
|
} as never,
|
|
{
|
|
model: "gpt-5.5",
|
|
},
|
|
),
|
|
).toEqual({
|
|
provider: "openai",
|
|
model: "gpt-5.5",
|
|
});
|
|
});
|
|
|
|
it("prefers explicit overrides ahead of fallback runtime fields", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveSessionModelRef(cfg, {
|
|
providerOverride: "openai",
|
|
modelOverride: "gpt-5.4",
|
|
modelProvider: "amazon-bedrock",
|
|
model: "minimax.minimax-m2.5",
|
|
}),
|
|
).toEqual({
|
|
provider: "openai",
|
|
model: "gpt-5.4",
|
|
});
|
|
});
|
|
|
|
it("falls back to configured defaults when persisted session model fields are malformed", () => {
|
|
expect(
|
|
statusSummaryRuntime.resolveSessionModelRef(cfg, {
|
|
modelProvider: { provider: "openai" },
|
|
model: false,
|
|
providerOverride: ["anthropic"],
|
|
modelOverride: 123,
|
|
} as never),
|
|
).toEqual({
|
|
provider: "anthropic",
|
|
model: "claude-sonnet-4-6",
|
|
});
|
|
});
|
|
});
|