fix(agents): preserve model overrides with team mode

Filter host config agent aliases with the same protected builtin-name rules used for external agent sources so stale display-name entries cannot replace resolved user-configured models when team mode is enabled.

Fixes #4429

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-25 11:06:37 +09:00
parent 222adeb606
commit 21713dcd86
3 changed files with 184 additions and 27 deletions
+98
View File
@@ -30,6 +30,104 @@ afterEach(() => {
})
describe("createBuiltinAgents with model overrides", () => {
test("user config models take priority when team_mode is enabled", async () => {
// #given
const providerModelsSpy = spyOn(connectedProvidersCache, "readProviderModelsCache").mockReturnValue(null)
const fetchSpy = spyOn(shared, "fetchAvailableModels").mockResolvedValue(new Set())
const overrides = {
sisyphus: { model: "openai/gpt-5.5" },
explore: { model: "minimax-cn-coding-plan/MiniMax-M2.5-highspeed" },
atlas: { model: "google/antigravity-claude-opus-4-5-thinking" },
hephaestus: { model: "github-copilot/gpt-5.5" },
}
try {
// #when
const agentsWithTeamMode = await createBuiltinAgents(
[],
overrides,
undefined,
TEST_DEFAULT_MODEL,
undefined,
undefined,
[],
undefined,
undefined,
undefined,
undefined,
false,
false,
true
)
// #then
expect(agentsWithTeamMode.sisyphus.model).toBe("openai/gpt-5.5")
expect(agentsWithTeamMode.explore.model).toBe("minimax-cn-coding-plan/MiniMax-M2.5-highspeed")
expect(agentsWithTeamMode.atlas.model).toBe("google/antigravity-claude-opus-4-5-thinking")
expect(agentsWithTeamMode.hephaestus.model).toBe("github-copilot/gpt-5.5")
} finally {
providerModelsSpy.mockRestore()
fetchSpy.mockRestore()
}
})
test("team_mode does not change resolved models for user overrides", async () => {
// #given
const providerModelsSpy = spyOn(connectedProvidersCache, "readProviderModelsCache").mockReturnValue(null)
const fetchSpy = spyOn(shared, "fetchAvailableModels").mockResolvedValue(new Set())
const overrides = {
sisyphus: { model: "openai/gpt-5.5" },
explore: { model: "minimax-cn-coding-plan/MiniMax-M2.5-highspeed" },
atlas: { model: "google/antigravity-claude-opus-4-5-thinking" },
hephaestus: { model: "github-copilot/gpt-5.5" },
}
try {
// #when
const agentsWithoutTeamMode = await createBuiltinAgents(
[],
overrides,
undefined,
TEST_DEFAULT_MODEL,
undefined,
undefined,
[],
undefined,
undefined,
undefined,
undefined,
false,
false,
false
)
const agentsWithTeamMode = await createBuiltinAgents(
[],
overrides,
undefined,
TEST_DEFAULT_MODEL,
undefined,
undefined,
[],
undefined,
undefined,
undefined,
undefined,
false,
false,
true
)
// #then
expect(agentsWithTeamMode.sisyphus.model).toBe(agentsWithoutTeamMode.sisyphus.model)
expect(agentsWithTeamMode.explore.model).toBe(agentsWithoutTeamMode.explore.model)
expect(agentsWithTeamMode.atlas.model).toBe(agentsWithoutTeamMode.atlas.model)
expect(agentsWithTeamMode.hephaestus.model).toBe(agentsWithoutTeamMode.hephaestus.model)
} finally {
providerModelsSpy.mockRestore()
fetchSpy.mockRestore()
}
})
test("Sisyphus with default model has thinking config when all models available", async () => {
// #given
const fetchSpy = spyOn(shared, "fetchAvailableModels").mockResolvedValue(