Merge pull request #2833 from kuitos/feat/agent-order-support

feat(agent-priority): inject order field for deterministic agent Tab cycling
This commit is contained in:
YeonGyu-Kim
2026-03-26 08:49:58 +09:00
committed by GitHub
2 changed files with 21 additions and 10 deletions

View File

@@ -60,6 +60,7 @@ describe("applyAgentConfig builtin override protection", () => {
name: "Builtin Sisyphus",
prompt: "builtin prompt",
mode: "primary",
order: 1,
}
const builtinOracleConfig: AgentConfig = {

View File

@@ -1,11 +1,21 @@
import { getAgentDisplayName } from "../shared/agent-display-names";
const CORE_AGENT_ORDER = [
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
] as const;
const CORE_AGENT_ORDER: ReadonlyArray<{ displayName: string; order: number }> = [
{ displayName: getAgentDisplayName("sisyphus"), order: 1 },
{ displayName: getAgentDisplayName("hephaestus"), order: 2 },
{ displayName: getAgentDisplayName("prometheus"), order: 3 },
{ displayName: getAgentDisplayName("atlas"), order: 4 },
];
function injectOrderField(
agentConfig: unknown,
order: number,
): unknown {
if (typeof agentConfig === "object" && agentConfig !== null) {
return { ...agentConfig, order };
}
return agentConfig;
}
export function reorderAgentsByPriority(
agents: Record<string, unknown>,
@@ -13,10 +23,10 @@ export function reorderAgentsByPriority(
const ordered: Record<string, unknown> = {};
const seen = new Set<string>();
for (const key of CORE_AGENT_ORDER) {
if (Object.prototype.hasOwnProperty.call(agents, key)) {
ordered[key] = agents[key];
seen.add(key);
for (const { displayName, order } of CORE_AGENT_ORDER) {
if (Object.prototype.hasOwnProperty.call(agents, displayName)) {
ordered[displayName] = injectOrderField(agents[displayName], order);
seen.add(displayName);
}
}