fix: only call setDefaultAgentForSort when user explicitly sets default_agent

The previous code read params.config.default_agent which is always populated to
"Sisyphus - Ultraworker" by existing logic (lines 196-204) even when the user
never configured default_agent. This silently overrode any custom agent_order.

Now we gate on configuredDefaultAgent (the user's explicit value) so the sort
shim rank map is only mutated when the user actually set default_agent.

Add regression test: agent_order without default_agent must preserve order.

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-18 13:42:59 +09:00
parent ec7168eb6c
commit f5e063b00a
2 changed files with 25 additions and 3 deletions
+4 -3
View File
@@ -400,9 +400,10 @@ export async function applyAgentConfig(params: {
);
}
const resolvedDefault = (params.config as { default_agent?: string }).default_agent;
if (resolvedDefault) {
setDefaultAgentForSort(resolvedDefault);
if (configuredDefaultAgent) {
setDefaultAgentForSort(
(params.config as { default_agent?: string }).default_agent ?? configuredDefaultAgent,
);
}
const agentResult = params.config.agent as Record<string, unknown>;
+21
View File
@@ -265,4 +265,25 @@ describe("agent-sort-shim", () => {
})
})
})
describe("#given agent_order configured without default_agent", () => {
describe("#when setAgentSortOrder sets a non-canonical order and setDefaultAgentForSort is NOT called", () => {
test("#then the custom agent_order is preserved without implicit override", () => {
// given
setAgentSortOrder(["hephaestus", "sisyphus", "prometheus", "atlas"])
// setDefaultAgentForSort is intentionally NOT called (user did not set default_agent)
const sisyphus = { name: "Sisyphus - Ultraworker" }
const hephaestus = { name: "Hephaestus - Deep Agent" }
const prometheus = { name: "Prometheus - Plan Builder" }
const atlas = { name: "Atlas - Plan Executor" }
const input = [atlas, sisyphus, prometheus, hephaestus]
// when
const result = input.toSorted((a, b) => a.name.localeCompare(b.name))
// then — Hephaestus must remain first per the user's agent_order
expect(result).toEqual([hephaestus, sisyphus, prometheus, atlas])
})
})
})
})