Skip to content

Conversation

@James-Cherished
Copy link

@James-Cherished James-Cherished commented Jan 3, 2026

Hello!

This enables Kilo to automatically discover and execute workflows, replacing the current ineffective experimental setting.

Workflows in Kilo Code can now be:

  • Automatically discovered and displayed in environment details
  • Executed by AI agents using the run_slash_command tool

Implementation

Workflow Execution Tool

New Backend Services:

  • src/services/workflow/workflows.ts - Discovers workflows from .kilocode/workflows/
  • src/core/tools/RunSlashCommandTool.ts - Handles execution with approval flow and parameter passing
  • src/core/prompts/tools/native-tools/run_slash_command.ts - Tool interface for AI models

Smart UI Integration:

  • Extended SlashCommandItem component for workflow execution display
  • Integrated into ChatRow.tsx for seamless chat experience
  • Expandable workflow details showing arguments, descriptions, and source badges

Workflow Discovery

Fixed Configuration Issues:

  • Enabled WORKFLOW_DISCOVERY experiment by default in src/shared/experiments.ts
  • Fixed experiment check in getWorkflowsForEnvironment.ts using Experiments.isEnabled() helper
  • Updated getEnvironmentDetails.ts to properly pass experiment configuration

Impact: AI agents now see all available workflows in their environment details automatically

Technical Highlights

Code Reuse: Extended existing SlashCommandItem component rather than creating duplicate infrastructure, maintaining clean architecture.

Comprehensive Testing:

  • 22 UI component tests for workflow execution
  • 10 workflow service tests
  • 10 tool execution tests
  • 3 ChatRow integration tests
  • All passing ✅

Merge-Friendly: All Kilo Code-specific changes marked with kilocode_change comments for easy upstream synchronization.

Files Changed

New Files (8):

  • Workflow service + tests
  • UI component tests
  • Example workflows (3)
  • Changesets (2)
  • Implementation plan

Modified Files (14):

  • Backend tool implementation and integration
  • UI components (SlashCommandItem, ChatRow)
  • Experiment configuration
  • Localization files (6 languages)
  • Type definitions

Total: 22 files changed, bringing complete workflow functionality to Kilo Code[1]

How to Test

  1. Enable experimental setting

  2. Create a workflow if none: .kilocode/workflows/user-favorite-color-is.md

  3. Start task: "tell me what's user favorite color, without using any tool except the workflow tool, including without listing or reading any file."

  4. Agent sees the workflow and can execute it using the tool

  5. Workflow provides the agent with new instructions

  6. Disable experimental setting

  7. Start a new chat with the same prompt: "tell me what's user favorite color, without using any tool except the workflow tool, including without listing or reading any file."

  8. Agent won't know, can't know which workflows are available, will quit or cheat to answer

Screenshots

Setting off

Setting off

Setting on

Setting on Setting UI

Get in touch

james_cherished_13573 (discord)
https://x.com/JamesCherished (preferred)

Implements the execute_workflow tool enabling AI assistants to discover and execute slash command workflows stored in .kilocode/workflows/ without manual file reading. This resolves a critical limitation where workflows couldn't be properly utilized, forcing users to work around the system.
What Changed
Backend Infrastructure:
New workflow service (src/services/workflow/workflows.ts) - Discovers and manages workflows from .kilocode/workflows/ with support for project-level and global workflows
Workflow execution tool (src/core/tools/RunSlashCommandTool.ts) - Handles workflow discovery, parameter passing, approval flow, and execution with comprehensive error handling
Tool description (src/core/prompts/tools/native-tools/run_slash_command.ts) - Defines tool interface for AI models with clear usage examples
Experiment flag integration - Feature gated behind runSlashCommand experiment flag for gradual rollout
UI Components:
Extended SlashCommandItem component - Added workflow execution mode to existing component (avoiding duplication)
Chat integration (ChatRow.tsx) - Displays workflow execution requests and results inline
Workflow execution display - Shows workflow name, description, source badges (project/global/built-in), and optional arguments with expand/collapse support
Testing:
22 comprehensive UI tests covering both command list and workflow execution modes
Backend unit tests for workflow service and execution tool
Integration tests ensuring proper message routing and display
Why This Matters
Before this change, AI assistants had to read workflow files directly to utilize them, defeating their purpose as reusable templates. Now workflows are first-class citizens with proper discovery, validation, and execution support.
Key Features
Automatic discovery - List available workflows without file system access
Parameter support - Pass arguments to customize workflow execution
Source tracking - Distinguish between project, global, and built-in workflows
Approval flow - User approval required before workflow execution
Error handling - Graceful handling of missing workflows and invalid parameters
Experiment flag - Safe rollout behind runSlashCommand feature flag
Implementation Highlights
Smart architectural decision to extend existing SlashCommandItem component rather than create duplicate infrastructure, maintaining code reusability while adding workflow-specific functionality. All Kilo Code-specific changes marked with kilocode_change comments for future upstream merge compatibility.
Testing
All tests pass successfully:
✅ 22 SlashCommandItem tests (command list + workflow execution modes)
✅ 3 ChatRow integration tests
✅ Backend service and tool tests
✅ Type safety verified throughout
Changed translation key from RUN_SLASH_COMMAND to AUTO_EXECUTE_WORKFLOW to match experiment constant. Updated name from "Enable model-initiated slash commands" to "Enable workflow access" and description to better reflect the feature's actual behavior of accessing workflow content without approval.

- Updated 18 locale files (en, ar, ko, hi, fr, tr, pl, cs, pt-BR, zh-TW, ja, nl, id, vi, uk, es, de, th, zh-CN, it)
- Created changeset for release notes
- Fix experiment configuration passing in getWorkflowsForEnvironment
- Enable WORKFLOW_DISCOVERY experiment by default
- Use Experiments.isEnabled helper for proper fallback to defaults
- This allows workflows to appear in environment details that AI agent sees
@changeset-bot
Copy link

changeset-bot bot commented Jan 3, 2026

🦋 Changeset detected

Latest commit: 8ef1782

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

- Filter WORKFLOW_DISCOVERY from experimental settings UI
- Update getWorkflowsForEnvironment to use AUTO_EXECUTE_WORKFLOW instead
- Remove WORKFLOW_DISCOVERY from experiment definitions
- Remove WORKFLOW_DISCOVERY from experiment type definitions
- Update tests accordingly
@James-Cherished
Copy link
Author

The last commits polished the UI.

@M-Kepler
Copy link

M-Kepler commented Jan 3, 2026

It is already supported in the experimental options.

image

@James-Cherished
Copy link
Author

James-Cherished commented Jan 3, 2026

What this PR fixes is that this button is currently a placeholder/bad roo import. It does not allow the model to run self-initiated slash commands.

Here's the last release with this setting on:
Screenshot1

Screenshot2 Screenshot3 Screenshot4 Screenshot5

As stated in the PR and the solved issue, it does not discover workflows, and getting it to even think about the tool is always a big loss of API requests (I've tried a lot).

Root Cause

The workflow system had a synchronization gap between file creation and toggle state updates. When a user created a new workflow file in .kilocode/workflows/, the toggle state (localWorkflowToggles) was not automatically updated, causing the new workflow to not be recognized. The workflow discovery happened through two separate code paths that didn't automatically trigger each other.

Fix Implemented

Modified src/core/webview/ClineProvider.ts to call refreshWorkflowToggles() before getEnabledRules() in the postRulesDataToWebview() method. This ensures that whenever the webview needs to display workflow data, the toggle state is synchronized with actual files on disk.

The fix includes:

Added import for refreshWorkflowToggles from src/core/context/instructions/workflows.ts
Modified postRulesDataToWebview() to call await refreshWorkflowToggles(this.context, workspacePath) before retrieving enabled rules
This ensures newly created workflow files (like .kilocode/workflows/read-a-story-as-a-test.md) are now properly loaded and can be used as slash commands.

Happy to learn more if you have a video of it working

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