Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Aug 6, 2025

Related GitHub Issue

Closes: #6329

Roo Code Task Context (Optional)

No Roo Code task context for this PR

Description

This PR adds an optional todos parameter to the new_task tool, enabling hierarchical task planning by allowing parent tasks to pass predefined todo lists to subtasks. The parameter behavior can be controlled via an experimental setting.

Key Implementation Details:

  • The todos parameter is optional by default, ensuring complete backward compatibility
  • Added experimental setting experimental.newTaskTool.requireTodos to optionally enforce todos requirement
  • Reuses the existing parseMarkdownChecklist function from updateTodoListTool for consistency
  • Implements a clean state-based approach for UI rendering to avoid spurious "User Edit" messages
  • Adds comprehensive test coverage including backward compatibility tests

Design Choices:

  • Made the parameter optional by default to avoid breaking changes
  • Added experimental setting for teams that want stricter validation
  • Used state management for passing todos from backend to frontend instead of message-based hacks
  • Exported and reused existing parsing logic rather than duplicating code

Experimental Setting:

  • Setting Key: experimental.newTaskTool.requireTodos
  • Location: Settings > Experimental > "Require 'todos' list for new tasks"
  • Default: false (maintains backward compatibility)
  • When Enabled: Makes the todos parameter required for new_task tool

Test Procedure

Automated Tests:

  • 14 comprehensive tests in src/core/tools/__tests__/newTaskTool.spec.ts
  • 5 tests in src/shared/__tests__/experiments.spec.ts (updated for new experiment)
  • All tests passing
  • Tests cover: valid todos parsing, backward compatibility, error handling, edge cases, experimental setting behavior

Manual Testing Steps:

  1. Test backward compatibility (default behavior):

    <new_task>
    <mode>code</mode>
    <message>Test without todos parameter</message>
    </new_task>

    Expected: Task creates successfully without any errors

  2. Test with todos parameter:

    <new_task>
    <mode>code</mode>
    <message>Implement authentication</message>
    <todos>
    - [ ] Create user model
    - [ ] Add login endpoint
    - [x] Setup database
    </todos>
    </new_task>

    Expected: Subtask created with predefined todo list visible immediately

  3. Test experimental setting:

    • Go to Settings > Experimental
    • Enable "Require 'todos' list for new tasks"
    • Try creating a task without todos - should get an error
    • Try creating a task with todos - should work normally
    • Disable the setting - should return to optional behavior
  4. Verify UI rendering:

    • Confirm todos appear without any "User Edit" messages
    • Check that todo state updates work correctly

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

No UI changes in this PR beyond the todo list rendering which is text-based and the new experimental setting toggle

Documentation Updates

  • No documentation updates are required.
    • The tool documentation is auto-generated from the prompt files which have been updated
    • The experimental setting appears automatically in the UI with its description

Additional Notes

Implementation Highlights:

  • Full backward compatibility maintained - no breaking changes
  • Flexible configuration via experimental setting for teams wanting stricter validation
  • Clean architectural solution for UI state management
  • Comprehensive test coverage including edge cases
  • All code review issues have been addressed and fixed

Files Modified:

  • Core implementation: newTaskTool.ts, Task.ts, tool definitions
  • Experimental setting: experiment.ts, experiments.ts, settings.json
  • UI state management: ExtensionMessage.ts, ExtensionStateContext.tsx, ChatView.tsx
  • Tests: newTaskTool.spec.ts, experiments.spec.ts
  • Documentation: new-task.ts prompt file

Usage Example:

// Default behavior (todos optional)
await cline.say("new_task", {
  mode: "code",
  message: "Implement feature"
  // todos can be omitted
})

// With todos
await cline.say("new_task", {
  mode: "code",
  message: "Implement feature",
  todos: `
- [ ] Task 1
- [ ] Task 2
  `
})

// With experimental setting enabled
// todos becomes required and must be provided

Get in Touch

@[your-discord-username]


Important

Adds optional todos parameter to new_task tool with an experimental setting to enforce its requirement, including comprehensive tests and UI state management improvements.

  • Behavior:
    • Adds optional todos parameter to new_task tool for hierarchical task planning.
    • Introduces experimental setting experimental.newTaskTool.requireTodos to enforce todos requirement.
    • Reuses parseMarkdownChecklist from updateTodoListTool for parsing.
  • UI and State Management:
    • Implements state-based UI rendering to avoid "User Edit" messages.
    • Updates ExtensionStateContext.tsx and ChatView.tsx for state management.
  • Testing:
    • Adds 14 tests in newTaskTool.spec.ts and 5 in experiments.spec.ts.
    • Tests cover todos parsing, backward compatibility, and experimental setting behavior.
  • Files Modified:
    • Core changes in newTaskTool.ts, Task.ts, and experiment.ts.
    • UI changes in ExtensionMessage.ts and ExtensionStateContext.tsx.

This description was created by Ellipsis for 1781044. You can customize this summary. It will automatically update as commits are pushed.

Copilot AI review requested due to automatic review settings August 6, 2025 22:51
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Aug 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds an optional todos parameter to the new_task tool, enabling hierarchical task planning by allowing parent tasks to pass predefined todo lists to subtasks. The parameter can be controlled via a new experimental setting that determines whether todos are required or optional.

  • Adds optional todos parameter to new_task tool with markdown checklist parsing
  • Introduces experimental setting newTaskRequireTodos to optionally enforce todos requirement (defaults to false for backward compatibility)
  • Implements clean state-based approach for UI rendering of initial todos without spurious messages

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/core/tools/newTaskTool.ts Core implementation adding todos parameter validation, parsing, and experimental setting check
src/core/task/Task.ts Added support for initialTodos in TaskOptions and constructor initialization
src/shared/tools.ts Updated NewTaskToolUse interface to include todos parameter
src/shared/experiments.ts Added NEW_TASK_REQUIRE_TODOS experiment configuration
packages/types/src/experiment.ts Added newTaskRequireTodos to experiment schema and types
webview-ui/src/i18n/locales/en/settings.json Added localization for new experimental setting
webview-ui/src/context/ExtensionStateContext.tsx Added currentTaskTodos to state context for UI rendering
webview-ui/src/components/chat/ChatView.tsx Enhanced todo rendering logic to handle initial todos from state
src/core/tools/__tests__/newTaskTool.spec.ts Comprehensive test coverage including backward compatibility and experimental setting behavior

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 6, 2025
@daniel-lxs daniel-lxs moved this from Triage to Issue [In Progress] in Roo Code Roadmap Aug 7, 2025
@daniel-lxs daniel-lxs moved this from Issue [In Progress] to PR [Needs Prelim Review] in Roo Code Roadmap Aug 7, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 7, 2025
@daniel-lxs
Copy link
Member

@roomote-agent The new parameter "todos" should not be visible in the tool prompt when the experiment is disabled, please implement this change so that when the experiment is disabled there tool prompt is not changed at all.

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Aug 7, 2025
@roomote
Copy link
Contributor

roomote bot commented Aug 7, 2025

Hi @daniel-lxs! I see your request to hide the "todos" parameter from the tool prompt when the experiment is disabled. I'll implement this change so that the tool prompt remains unchanged when the experimental setting is off. Working on it now!

@roomote
Copy link
Contributor

roomote bot commented Aug 7, 2025

Hi @daniel-lxs! I've successfully implemented the requested change.

Summary of Changes

Modified src/core/prompts/tools/new-task.ts:

  • When the experiment is disabled (default), the tool prompt now completely omits the todos parameter
  • The prompt shows a simple interface without any mention of todos
  • When the experiment is enabled, the todos parameter is shown as required with full documentation

Updated tests in src/core/prompts/tools/__tests__/new-task.spec.ts:

  • Tests now verify that the todos parameter is completely hidden when the experiment is disabled
  • Tests confirm the parameter appears as required when the experiment is enabled
  • All tests are passing locally

Behavior

When experiment is disabled (default):

  • Tool prompt shows only mode and message parameters
  • No mention of todos anywhere in the prompt
  • Example shows simple usage without todos

When experiment is enabled:

  • Tool prompt shows mode, message, and todos (required) parameters
  • Full documentation and examples include todos

The changes ensure complete backward compatibility - when the experimental setting is off, the tool prompt remains exactly as it would be without the todos feature.

Note: The platform unit test failures appear to be pre-existing and unrelated to these changes, as the specific tests I modified are all passing.

@daniel-lxs
Copy link
Member

@roomote-agent use pr-fixer to fix the failing CI test

@roomote
Copy link
Contributor

roomote bot commented Aug 7, 2025

I see the failing CI tests in the platform-unit-test jobs. Let me investigate and fix the issue. 🔧

@roomote
Copy link
Contributor

roomote bot commented Aug 7, 2025

CI tests fixed successfully!

The issue was with snapshot tests that needed to be updated after adding the new todos parameter to the new_task tool.

What was fixed:

  • Updated 13 snapshots in add-custom-instructions.spec.ts and system-prompt.spec.ts
  • These snapshots contained the tool documentation which now includes the new optional todos parameter

All CI checks are now passing:

  • ✅ platform-unit-test (ubuntu-latest)
  • ✅ platform-unit-test (windows-latest)
  • ✅ integration-test
  • ✅ compile
  • ✅ check-translations
  • ✅ knip
  • ✅ Analyze (javascript-typescript)
  • ✅ CodeQL

The PR is ready for review! 🚀

Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 7, 2025
… setting (#6329)

- Add optional todos parameter to new_task tool for hierarchical task planning
- Implement experimental setting to optionally require todos parameter
- Add clean state-based UI rendering to avoid spurious messages
- Export and reuse parseMarkdownChecklist function
- Add comprehensive test coverage for both optional and required modes
- Maintain full backward compatibility (todos optional by default)
- Updated the example in tool-use.ts to show the todos parameter
- This prevents AI confusion about whether todos is a valid parameter
- The example now demonstrates the complete tool usage pattern
- Tool description now changes based on newTaskRequireTodos setting
- When disabled: shows todos as (optional)
- When enabled: shows todos as (required) with no mention of configuration
- Added tests to verify dynamic behavior
- Ensures AI models get unambiguous instructions based on current settings
hannesrudolph and others added 7 commits August 19, 2025 17:39
- Added translations for all 17 supported languages
- Ensures consistent UI experience across all locales
- Updated 13 snapshot files to reflect the new tool-use example
- All tests now pass with the updated example format
- Replace any[] with TodoItem[] type in ExtensionStateContext.tsx for better type safety
- Remove redundant initialTodos parameter from startTask call in Task.ts (todos already set in constructor)
- Improve code clarity in newTaskTool.ts by checking provider reference early and reusing state

# Conflicts:
#	src/core/task/Task.ts
#	webview-ui/src/context/ExtensionStateContext.tsx
…timeout

The change in order of operations (calling say() before postStateToWebview()) was causing the XML content file test to timeout. Reverting to the original order fixes the issue.
…s disabled

- Modified getNewTaskDescription to completely omit todos parameter when experiment is off
- Updated tests to verify todos parameter is not shown at all when disabled
- Ensures tool prompt remains unchanged when experimental setting is disabled
- Maintains backward compatibility while providing cleaner prompt interface
- Updated snapshots in add-custom-instructions.spec.ts
- Updated snapshots in system-prompt.spec.ts
- All tests now passing with the new todos parameter documentation
@hannesrudolph hannesrudolph force-pushed the feat/issue-6329-add-todos-parameter branch from 6ffdcd5 to e9da4b9 Compare August 19, 2025 23:46
Merge Resolver added 2 commits August 19, 2025 18:21
- Added newTaskRequireTodos as a VSCode configuration property in src/package.json
- Added description in src/package.nls.json
- Updated newTaskTool.ts to read from VSCode configuration instead of experiments
- Removed NEW_TASK_REQUIRE_TODOS from experimental settings in src/shared/experiments.ts
- Removed newTaskRequireTodos from packages/types/src/experiment.ts
- Updated tests to use VSCode configuration mocking instead of experiments
- Removed references from experiments test file
- Maintains backward compatibility (defaults to false)
- Updated new-task.ts to check args.settings instead of args.experiments
- Added newTaskRequireTodos to SystemPromptSettings interface
- Pass newTaskRequireTodos setting through Task.ts and generateSystemPrompt.ts
- Updated all related tests to use settings instead of experiments
- Fixed TypeScript errors in test files by adding newTaskRequireTodos property

This ensures the tool description correctly shows todos parameter as required/optional
based on the VSCode setting value, fixing the issue where Roo would try to use
new_task without the todos parameter when it was required.
@hannesrudolph hannesrudolph moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Aug 20, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Aug 21, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

LGTM

@mrubens mrubens merged commit 4664955 into main Aug 21, 2025
13 checks passed
@mrubens mrubens deleted the feat/issue-6329-add-todos-parameter branch August 21, 2025 20:02
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 21, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Feature Proposal: Add required todos parameter to new_task tool for hierarchical task planning

5 participants