Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added workflow, kb, and function as a tool for agent block
  • fix keyboard nav in tool input

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 Nov 23, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Nov 24, 2025 7:44pm

@waleedlatif1 waleedlatif1 marked this pull request as ready for review November 23, 2025 05:26
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 23, 2025

Greptile Overview

Greptile Summary

This PR adds workflow, knowledge base, and function tools as agent block capabilities, along with keyboard navigation fixes in the tool input component.

Key Changes:

  • Added workflow_executor tool with dynamic input field mapping that fetches workflow schemas at runtime
  • Made createLLMToolSchema async to support dynamic schema generation with 5-minute caching
  • Replaced Select with Combobox for better UX and added workflow/KB/document selector wrappers
  • Fixed keyboard navigation by extracting useCommandKeyDown hook and using CommandKeyboardWrapper
  • Added user-or-llm visibility to multiple tool params (knowledge, function) for proper LLM schema generation
  • Added items property support for array parameters with nested type definitions

Implementation Quality:

  • Dynamic workflow input field fetching with proper caching reduces API calls
  • Conditional rendering logic using not: true correctly shows input mapper when workflow is selected
  • Proper separation of concerns between UI components and data fetching
  • Tests updated to handle async schema generation

Confidence Score: 4/5

  • This PR is safe to merge with minor attention to the large tool-input.tsx refactor
  • The implementation is well-structured with proper async handling, caching, and type safety. The keyboard navigation fix properly delegates to context. Main complexity is in tool-input.tsx which has a large refactor but maintains existing patterns. Dynamic workflow schema generation is well-implemented with error handling.
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx - large refactor with many new selector wrappers, verify all edge cases are handled

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/tools/params.ts 4/5 Added workflow_executor special handling with dynamic schema generation for workflow input fields. Made createLLMToolSchema async to support dynamic schema enrichment. Added workflow input field caching (5min TTL).
apps/sim/tools/workflow/executor.ts 4/5 Changed workflow executor to call workflow execution API directly. Added user-or-llm visibility to params. Updated description to guide LLM on proper input mapping. Improved response transformation to handle new API format.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx 3/5 Major refactor: replaced Select with Combobox, added WorkflowSelectorSyncWrapper and WorkflowInputMapperSyncWrapper, added KnowledgeBaseSelectorSyncWrapper and DocumentSelectorSyncWrapper, fixed keyboard navigation by using useCommandKeyDown hook with CommandKeyboardWrapper.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tool-command/tool-command.tsx 4/5 Exported useCommandKeyDown hook, added handleKeyDown to context, removed onKeyDown from div (moved to consuming components), added auto-scroll to active item, simplified filtering to not sort by score.

Sequence Diagram

sequenceDiagram
    participant User
    participant AgentBlock
    participant ToolInput
    participant ToolCommand
    participant WorkflowSelector
    participant WorkflowAPI
    participant LLM
    participant WorkflowExecutor

    Note over User,WorkflowExecutor: Agent Tool Configuration Flow

    User->>AgentBlock: Configure agent tools
    AgentBlock->>ToolInput: Render tool selection UI
    
    ToolInput->>ToolCommand: Display tool command palette
    User->>ToolCommand: Search and select tool<br/>(workflow/kb/function)
    
    alt Workflow Tool Selected
        ToolCommand->>ToolInput: Add workflow_executor tool
        ToolInput->>WorkflowSelector: Render workflow selector
        User->>WorkflowSelector: Select workflow
        WorkflowSelector->>WorkflowAPI: Fetch workflow details
        WorkflowAPI-->>WorkflowSelector: Return workflow input schema
        WorkflowSelector->>ToolInput: Show input mapper for selected workflow
        User->>ToolInput: Configure input field mappings
    else Knowledge Base Tool Selected
        ToolCommand->>ToolInput: Add knowledge_search tool
        ToolInput->>ToolInput: Render KB selector & search params
        User->>ToolInput: Select KB and configure search
    else Function Tool Selected
        ToolCommand->>ToolInput: Add function_execute tool
        ToolInput->>ToolInput: Render code editor
        User->>ToolInput: Write JavaScript code
    end

    Note over User,WorkflowExecutor: Runtime Execution Flow

    User->>AgentBlock: Execute workflow
    AgentBlock->>LLM: Send prompt with tool schemas
    
    Note over AgentBlock,LLM: createLLMToolSchema filters<br/>user-provided params
    
    LLM->>LLM: Determine which tool to use
    
    alt LLM selects workflow_executor
        LLM-->>AgentBlock: Tool call with inputMapping
        AgentBlock->>WorkflowExecutor: Execute child workflow
        WorkflowExecutor->>WorkflowAPI: POST /api/workflows/{id}/execute
        WorkflowAPI-->>WorkflowExecutor: Return execution result
        WorkflowExecutor-->>AgentBlock: Return formatted output
    else LLM selects knowledge_search
        LLM-->>AgentBlock: Tool call with query
        AgentBlock->>WorkflowAPI: POST /api/knowledge/search
        WorkflowAPI-->>AgentBlock: Return search results
    else LLM selects function_execute
        LLM-->>AgentBlock: Tool call with code
        AgentBlock->>WorkflowAPI: POST /api/function/execute
        WorkflowAPI-->>AgentBlock: Return execution result
    end
    
    AgentBlock-->>LLM: Provide tool results
    LLM-->>User: Generate final response
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.

12 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

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.

16 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit c80827f into staging Nov 24, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/agent-tools branch November 24, 2025 20:16
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