-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
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:
-
Standard Tasks (User-initiated):
- By default, the
attempt_completiontool 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.
- By default, the
-
Orchestrated Subtasks (Created via
new_taskbyorchestratormode):- The
attempt_completiontool 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.
- The
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.
- Task Context Awareness: The logic that creates a
new_taskfrom theorchestratormode needs to flag the subtask as "orchestrated". TheTaskobject insrc/core/task/Task.tsshould be updated to track this state. - Conditional Prompt Generation: The system prompt generation logic, likely in files like
src/core/prompts/tools/index.ts, must be modified. Before adding theattempt_completiontool 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.
- UI (Optional but Recommended): A new setting toggle can be added to
webview-ui/src/components/chat/AutoApproveMenu.tsxto 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
Labels
Type
Projects
Status