Skip to content

Feature: Conditionally Include attempt_completion Tool Based on Task Context #7529

@VooDisss

Description

@VooDisss

Problem Description

Currently, the attempt_completion tool is always available and its automatic invocation can prematurely end a user's session, especially in a standard, non-orchestrated task. This forces a workflow where the user's task is considered "complete" even if they intended to continue.

However, for subtasks created by the orchestrator mode, attempt_completion is a necessary mechanism to signal completion and return results to the parent task. A global toggle would break this critical workflow.

This proposal suggests a more intelligent, context-aware approach to making the attempt_completion tool available.

Proposed Solution

Instead of a simple on/off switch, the attempt_completion tool's availability in the system prompt should be conditional based on the task's context:

  1. Standard Tasks (User-initiated):

    • By default, the attempt_completion tool should NOT be included in the system prompt.
    • This prevents the LLM from prematurely ending the task and allows for a more continuous, conversational workflow until the user is truly finished.
  2. Orchestrated Subtasks (Created via new_task by orchestrator mode):

    • The attempt_completion tool MUST be included in the system prompt for these subtasks.
    • This is essential for the subtask to signal that it has finished its work and to pass the results back to the parent orchestrator task, allowing the main workflow to proceed.

A user setting could still be provided in the AutoApproveMenu, but it would only control the behavior for standard tasks. For example, a setting like "Allow Assistant to End Session" could be off by default but could be enabled by users who prefer the current behavior. Orchestrated tasks would ignore this setting.

Implementation Details

This implementation requires the system to be aware of the context in which a task is running.

  1. Task Context Awareness: The logic that creates a new_task from the orchestrator mode needs to flag the subtask as "orchestrated". The Task object in src/core/task/Task.ts should be updated to track this state.
  2. Conditional Prompt Generation: The system prompt generation logic, likely in files like src/core/prompts/tools/index.ts, must be modified. Before adding the attempt_completion tool to the prompt, it should check:
    • Is this an orchestrated subtask? If yes, include the tool.
    • If not, is the "Allow Assistant to End Session" user setting enabled? If yes, include the tool.
    • Otherwise, exclude the tool.
  3. UI (Optional but Recommended): A new setting toggle can be added to webview-ui/src/components/chat/AutoApproveMenu.tsx to control the behavior for standard tasks.

Impact

This change makes the assistant's behavior much more intuitive. It preserves the essential attempt_completion mechanism for automated workflows (orchestrator) while providing a more flexible and user-friendly experience for standard, conversational tasks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions