Skip to content

Refactor: Consider segregating ScenarioExecutionLike interface #212

@drewdrewthis

Description

@drewdrewthis

Problem

The ScenarioExecutionLike interface may be too fat. Not every consumer needs all methods:

async message(message: ModelMessage): Promise<void>;
async user(content?: string | ModelMessage): Promise<void>;
async agent(content?: string | ModelMessage): Promise<void>;
async judge(content?: string | ModelMessage): Promise<ScenarioResult | null>;
async proceed(turns?: number, ...): Promise<ScenarioResult | null>;
async succeed(reasoning?: string): Promise<ScenarioResult>;
async fail(reasoning?: string): Promise<ScenarioResult>;

Script steps only need a subset. The judge only needs certain methods. This may violate the Interface Segregation Principle.

Proposed Solution

Consider segregating into focused interfaces:

interface ScenarioControlFlow {
  proceed(turns?: number): Promise<ScenarioResult | null>;
  succeed(reasoning?: string): Promise<ScenarioResult>;
  fail(reasoning?: string): Promise<ScenarioResult>;
}

interface ScenarioMessaging {
  message(message: ModelMessage): Promise<void>;
  user(content?: string | ModelMessage): Promise<void>;
  agent(content?: string | ModelMessage): Promise<void>;
}

interface ScenarioJudging {
  judge(content?: string | ModelMessage): Promise<ScenarioResult | null>;
}

Files Affected

  • src/domain/core/execution.ts
  • 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