-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
Problem
In src/execution/scenario-execution.ts, there are two nearly identical methods:
// Lines 1074-1089
private nextAgentForRole(role: AgentRole): { idx: number; agent: AgentAdapter | null; } {
for (const agent of this.agents) {
if (agent.role === role && this.pendingAgentsOnTurn.has(agent) && this.pendingRolesOnTurn.includes(role)) {
return { idx: this.agents.indexOf(agent), agent };
}
}
return { idx: -1, agent: null };
}
// Lines 1151-1161
private getNextAgentForRole(role: AgentRole): { index: number; agent: AgentAdapter } | null {
for (let i = 0; i < this.agents.length; i++) {
const agent = this.agents[i];
if (agent.role === role && this.pendingAgentsOnTurn.has(agent)) {
return { index: i, agent };
}
}
return null;
}These do almost the same thing with slightly different return types. This violates DRY.
Proposed Solution
Consolidate into one method with consistent naming:
private findNextAgentForRole(role: AgentRole): { index: number; agent: AgentAdapter } | null {
for (let i = 0; i < this.agents.length; i++) {
const agent = this.agents[i];
if (agent.role === role && this.pendingAgentsOnTurn.has(agent)) {
return { index: i, agent };
}
}
return null;
}Files Affected
src/execution/scenario-execution.ts
Metadata
Metadata
Assignees
Labels
No labels