Skip to content

Refactor: Replace magic boolean parameters with named options #209

@drewdrewthis

Description

@drewdrewthis

Problem

In src/execution/scenario-execution.ts, there are boolean parameters that make code hard to read at call sites:

// Line 431
private async _step(
  goToNextTurn: boolean = true,
  onTurn?: (state: ScenarioExecutionStateLike) => void | Promise<void>
): Promise<void>

// Line 508
private async callAgent(
  idx: number,
  role: AgentRole,
  judgmentRequest: boolean = false
): Promise<void>

Boolean parameters force readers to remember what true or false means at each call site.

Proposed Solution

Use named options objects or discriminated function names:

interface StepOptions {
  advanceTurnIfNeeded: boolean;
  onTurn?: (state: ScenarioExecutionStateLike) => void | Promise<void>;
}

private async _step(options: StepOptions): Promise<void>

// Or split into explicit methods:
private async stepWithTurnAdvance(): Promise<void>
private async stepWithoutTurnAdvance(): Promise<void>

Files Affected

  • src/execution/scenario-execution.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions