Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added workflow tools to agent tools dropdown for discoverability
  • enforce perms on client for redeploying child workflow via the agent and via the workflow block

Type of Change

  • New feature

Testing

Tested manually

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 12, 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 12, 2026 7:38pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 12, 2026

Greptile Overview

Greptile Summary

This PR adds workflow tools to the agent tools dropdown for improved discoverability and enforces admin permissions for workflow deployment operations.

Key Changes

  1. Workflow Tools in Dropdown (tool-input.tsx):

    • Added a new "Workflows" section to the tools dropdown
    • Lists all available workflows (excluding current workflow) as selectable tools
    • Each workflow is added with toolId: 'workflow_executor' for execution
  2. Permission Enforcement (tool-input.tsx, workflow-block.tsx):

    • Added userPermissions.canAdmin checks before allowing workflow deployment
    • Updated UI to show "cursor-not-allowed" and appropriate tooltip messages for non-admin users
    • Prevents non-admin users from deploying/redeploying child workflows
  3. Parameter Visibility Change (params.ts):

    • Changed workflowId parameter from 'user-or-llm' to 'user-only'
    • This prevents LLMs from dynamically selecting workflows during execution

Integration with Existing Code

The changes integrate with the existing workflow execution system:

  • Uses useWorkflows() hook to fetch available workflows
  • Leverages useChildDeployment() hook for deployment status
  • Adds workflows alongside existing tool types (Custom Tools, MCP Tools, Built-in Tools, Integrations)
  • Consistent with existing permission patterns using useUserPermissionsContext()

Critical Issues Found

  1. Breaking Behavioral Change: The workflowId visibility change to 'user-only' removes LLM's ability to select workflows dynamically - this is not mentioned in the PR description
  2. Filter Logic Error: The toolBlocks filter doesn't respect the hideFromToolbar flag, potentially causing the generic Workflow block to appear despite being marked as hidden

Confidence Score: 2/5

  • This PR has critical issues that need resolution before merging
  • Score reflects two significant issues: (1) an undocumented breaking change to workflow parameter visibility that removes LLM's ability to select workflows, and (2) a filter logic error that doesn't respect the hideFromToolbar flag. The permission enforcement changes are well-implemented, but the core functionality changes need careful review.
  • Pay close attention to apps/sim/tools/params.ts (breaking change) and the toolBlocks filter in tool-input.tsx (logic error)

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/tools/params.ts 2/5 Changed workflowId parameter visibility from 'user-or-llm' to 'user-only', breaking LLM's ability to dynamically select workflows - needs review
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx 3/5 Added workflows to tools dropdown and permission checks for deployment. Filter doesn't respect hideFromToolbar flag, may cause duplication
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx 5/5 Added permission check for workflow deployment badge - clean implementation with proper tooltip messaging

Sequence Diagram

sequenceDiagram
    participant User
    participant ToolInput as Tool Input Dropdown
    participant Perms as Permission Context
    participant WorkflowAPI as Workflow API
    participant Agent as LLM Agent
    
    Note over User,Agent: Workflow Discovery & Selection
    User->>ToolInput: Opens tools dropdown
    ToolInput->>ToolInput: Fetch available workflows
    ToolInput->>ToolInput: Filter out current workflow
    ToolInput->>User: Show "Workflows" section with workflow list
    User->>ToolInput: Selects workflow from dropdown
    ToolInput->>ToolInput: Create tool with type='workflow', toolId='workflow_executor'
    
    Note over User,Agent: Deployment Permission Check (NEW)
    User->>ToolInput: Clicks deploy badge
    ToolInput->>Perms: Check userPermissions.canAdmin
    alt User is NOT admin
        Perms-->>ToolInput: canAdmin=false
        ToolInput->>User: Show "cursor-not-allowed", tooltip: "Admin permission required"
    else User IS admin
        Perms-->>ToolInput: canAdmin=true
        ToolInput->>WorkflowAPI: POST /api/workflows/{id}/deploy
        WorkflowAPI-->>ToolInput: Deployment successful
        ToolInput->>User: Update badge status
    end
    
    Note over User,Agent: Workflow Execution (CHANGED)
    User->>Agent: Execute workflow with agent
    Agent->>Agent: Check workflow_executor schema
    Note right of Agent: workflowId is 'user-only'<br/>NOT in LLM schema
    Agent->>Agent: Can only provide inputMapping<br/>Cannot select workflowId
    Agent->>WorkflowAPI: Execute with user-selected workflow
    WorkflowAPI-->>Agent: Return workflow results
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 12, 2026

Additional Comments (1)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx
The toolBlocks filter doesn't respect the hideFromToolbar flag, which may cause the generic "Workflow" block to appear in the tools dropdown despite being marked as hidden.

Issue:

  • The workflow block (apps/sim/blocks/blocks/workflow.ts) has hideFromToolbar: true (line 74)
  • Line 1037 explicitly includes block.type === 'workflow' in the filter
  • Line 850-866: BUILT_IN_TOOL_TYPES includes 'workflow'
  • Result: The workflow block would appear in the "Built-in Tools" section

Impact:
Users would see both:

  1. A generic "Workflow" block in "Built-in Tools"
  2. Individual workflow instances in the new "Workflows" section

This creates confusing duplication. The generic workflow block should remain hidden.

Fix:
Add a check to exclude blocks with hideFromToolbar: true:

  const toolBlocks = useMemo(() => {
    const allToolBlocks = getAllBlocks().filter(
      (block) =>
        !block.hideFromToolbar &&
        (block.category === 'tools' ||
          block.type === 'api' ||
          block.type === 'webhook_request' ||
          block.type === 'workflow' ||
          block.type === 'knowledge' ||
          block.type === 'function') &&
        block.type !== 'evaluator' &&
        block.type !== 'mcp' &&
        block.type !== 'file'
    )
    return filterBlocks(allToolBlocks)
  }, [filterBlocks])
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx
Line: 1031:1045

Comment:
The `toolBlocks` filter doesn't respect the `hideFromToolbar` flag, which may cause the generic "Workflow" block to appear in the tools dropdown despite being marked as hidden.

**Issue:**
- The workflow block (`apps/sim/blocks/blocks/workflow.ts`) has `hideFromToolbar: true` (line 74)
- Line 1037 explicitly includes `block.type === 'workflow'` in the filter
- Line 850-866: `BUILT_IN_TOOL_TYPES` includes `'workflow'`
- Result: The workflow block would appear in the "Built-in Tools" section

**Impact:**
Users would see both:
1. A generic "Workflow" block in "Built-in Tools"
2. Individual workflow instances in the new "Workflows" section

This creates confusing duplication. The generic workflow block should remain hidden.

**Fix:**
Add a check to exclude blocks with `hideFromToolbar: true`:

```suggestion
  const toolBlocks = useMemo(() => {
    const allToolBlocks = getAllBlocks().filter(
      (block) =>
        !block.hideFromToolbar &&
        (block.category === 'tools' ||
          block.type === 'api' ||
          block.type === 'webhook_request' ||
          block.type === 'workflow' ||
          block.type === 'knowledge' ||
          block.type === 'function') &&
        block.type !== 'evaluator' &&
        block.type !== 'mcp' &&
        block.type !== 'file'
    )
    return filterBlocks(allToolBlocks)
  }, [filterBlocks])
```

How can I resolve this? If you propose a fix, please make it concise.

@waleedlatif1 waleedlatif1 merged commit a3dff10 into staging Jan 12, 2026
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/badge branch January 12, 2026 19:54
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