Skip to content

[Bug]: runStep() has broken method signature (syntax error) and runStepWithRetry passes swapped arguments #40

@rishab11250

Description

@rishab11250

Bug Description

There are two separate bugs in packages/core/src/lib/runtime.ts affecting the runStep method:

Bug A — Syntax error: The runStep() method at lines 365-375 has two ): Promise<...> { return-type declarations, making the file invalid TypeScript.

Bug B — Swapped arguments: runStepWithRetry() at line 303 passes args.correlationId as the tenantId parameter and the retry attempt number as the correlationId parameter. Every step event (tool.called, llm.requested) emitted to the event pipeline has wrong tenant and correlation IDs, breaking tenant isolation.

Prerequisites

  • I have verified that this issue has not already been reported.
  • I have checked the documentation and believe this is a genuine malfunction, not a configuration error.
  • I am using the latest stable release or the main branch of PulseStack.

Steps to Reproduce

  1. Open packages/core/src/lib/runtime.ts.
  2. Observe the runStep method signature at lines 365-375 — it has two return declarations.
  3. Observe the call at line 303 in runStepWithRetry:
const result = await this.runStep(
    args.step,
    args.state,
    args.correlationId,   // passed as tenantId
    attempt,              // passed as correlationId
);
  1. Compare with the method signature parameter order at lines 369-370:
    tenantId: string,      // 3rd param
    correlationId: string,  // 4th param

Expected Behavior

The method should have a single valid signature, and runStepWithRetry should pass args.tenantId as the 3rd argument and args.correlationId as the 4th argument. All step events should carry the correct tenant and correlation identifiers.

Actual Behavior

Bug A — Line 371 and 375 both have ): Promise<...> {:

// Line 371 — first return declaration
): Promise<StepResult> {

// Lines 373-374 — orphaned param declarations between two function headers
    correlationId: string,
    attempt: number,

// Line 375 — second return declaration
): Promise<Omit<StepResult, 'attempts' | 'retry'>> {

Bug B — Line 303 passes args.correlationId as the 3rd argument (tenantId) and attempt as the 4th (correlationId):

const result = await this.runStep(
    args.step,
    args.state,
    args.correlationId,   // ❌ should be args.tenantId
    attempt,              // ❌ should be args.correlationId
);

This causes every tool.called, llm.requested, step.retrying, and step.failed event to carry incorrect tenant and correlation data.

Diagnostic Information

Environment Details

Additional Context

The method also has duplicate parameter declarations at lines 372-375 that appear to be a failed attempt at method overloading. The fix requires: (1) removing lines 372-375 to leave a single clean signature, and (2) swapping the arguments at line 306-307 to pass args.tenantId and args.correlationId in the correct order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions