Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Jan 24, 2026

Summary

Fixes condition block outgoing edges after hitl block

Type of Change

  • Bug fix

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 24, 2026 10:19am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 24, 2026

Greptile Summary

Fixed condition block evaluation after HITL (Human-In-The-Loop) block resumes. When a workflow execution resumes after HITL, condition blocks that follow would incorrectly trigger another pause because they inherited _pauseMetadata from the HITL block's output.

Key Changes:

  • Added filterPauseMetadata() method in condition-handler.ts to strip _pauseMetadata from source block output before using it
  • Updated block logging in human-in-the-loop-manager.ts to show submission data with internal fields filtered
  • The fix ensures condition blocks correctly evaluate conditions without re-pausing execution

How it works:
When the execution engine encounters _pauseMetadata in block output (line 373 in engine.ts), it marks the execution as paused and stops processing. After HITL resume, the pause metadata persists in the block state and would be passed through to downstream condition blocks, causing them to pause incorrectly. The new filter removes this metadata before condition evaluation.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is focused and addresses a specific bug with clear root cause analysis. The filterPauseMetadata() method uses proper defensive checks (null/object validation), and only removes the problematic _pauseMetadata field without affecting other data. The log filtering changes are purely cosmetic for better observability. No breaking changes or side effects expected.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/executor/handlers/condition/condition-handler.ts Added filterPauseMetadata() to strip _pauseMetadata from source output, preventing the engine from incorrectly treating resumed executions as new pauses
apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts Updated block logs to reflect submission data after HITL resume, filtering internal fields for cleaner log output

Sequence Diagram

sequenceDiagram
    participant Engine as Execution Engine
    participant HITL as HITL Block Handler
    participant Condition as Condition Block Handler
    participant State as Block State

    Note over Engine,State: Before Fix: Bug Scenario
    Engine->>HITL: Execute HITL block
    HITL->>State: Store output with _pauseMetadata
    HITL-->>Engine: Return output with _pauseMetadata
    Engine->>Engine: Detect _pauseMetadata, pause execution
    Note over Engine: User resumes workflow
    Engine->>Condition: Execute condition block
    Condition->>State: Get source output (includes _pauseMetadata)
    Condition->>Condition: Build evaluation context with _pauseMetadata
    Condition-->>Engine: Return output with inherited _pauseMetadata
    Engine->>Engine: Detect _pauseMetadata again ❌
    Note over Engine: Incorrectly pauses again!

    Note over Engine,State: After Fix: Correct Behavior
    Engine->>HITL: Execute HITL block
    HITL->>State: Store output with _pauseMetadata
    HITL-->>Engine: Return output with _pauseMetadata
    Engine->>Engine: Detect _pauseMetadata, pause execution
    Note over Engine: User resumes workflow
    Engine->>Condition: Execute condition block
    Condition->>State: Get rawSourceOutput (includes _pauseMetadata)
    Condition->>Condition: filterPauseMetadata(rawSourceOutput)
    Note over Condition: Strips _pauseMetadata from output
    Condition->>Condition: Build evaluation context without _pauseMetadata
    Condition->>Condition: Evaluate conditions
    Condition-->>Engine: Return output WITHOUT _pauseMetadata ✅
    Engine->>Engine: No pause detected, continue execution
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants