Skip to content

Conversation

@kels-ng
Copy link

@kels-ng kels-ng commented Feb 11, 2026

Add a subagent tool (experiment-gated) that runs a focused sub-task in the background. Parent task stays in view; result is returned as the tool result. Supports explore (read-only) and general modes. Inspired by Cursors's Task tool.

Context

Big projects require a lot of intermediate research, web fetching and code explorations. It's filled chat's context with unnecessary information. With this PR the main task stays in view while the model runs focused sub-tasks (research, exploration, or multi-step work) in the background with its own context. The subagent’s result is returned as a single tool result, so the main chat isn’t filled with the sub-task’s intermediate steps and tool calls. As a result, reducing context pollution and keeping the main thread readable.

Implementation

  • New subagent tool. Tool is only available when the experiment is on.
  • Flow: Parent invokes the tool → SubagentTool posts "running", provider creates a child task and runs its loop. Child has restricted tools (explore = read-only + attempt_completion; no nested subagent or interactive tools). Child’s attempt_completion resolves the parent’s promise with the result; parent continues.
  • Task/Provider: Task gets subagentType, needUpdateHistory, backgroundCompletionResolve, progress callback, and runBackgroundSubagentLoop. Provider implements runSubagentInBackground; cancel only stops the subagent and returns a cancellation message.
  • UI: Chat shows "Running subagent" and "Subagent completed" rows (ChatRow + i18n).

Screenshots

Example:
Example

Before:
Before

After:
After

Context pollution is reduced.

How to Test

  1. Enable the Subagent experiment: Settings → Experiments → turn on “Subagent tool”.
  2. Start a Code (or applicable) task that can trigger a subagent, e.g. “Use subagent to list all exports from src/index.ts and summarize what each does”.
  3. When the model calls the subagent tool: the main task should remain the active/visible task (no switch to a new task); you should see a chat row like “Running subagent: <description>”. When the subagent finishes, “Subagent completed” and the main task should receive the tool result and continue (e.g. next turn using that result).
  4. Optional: trigger an explore subagent (read-only) and confirm the subagent cannot edit files or run commands; trigger a general one and confirm it can.
  5. Optional: while a subagent is running, cancel the task; only the subagent should stop and the parent should get a cancellation message and remain in view.

Get in Touch

Email me or telegram: @kelsnewman

… task

Add a subagent tool (experiment-gated) that runs a focused sub-task in the
background. Parent task stays in view; result is returned as the tool result.
Supports explore (read-only) and general modes.
@changeset-bot
Copy link

changeset-bot bot commented Feb 11, 2026

⚠️ No Changeset found

Latest commit: 9868b9d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Ruslan Andreev added 2 commits February 12, 2026 16:11
Updated the SubagentTool to handle structured results when a subagent is cancelled. Introduced new constants for cancellation messages and updated the execution flow to return structured results. Added tests to verify the correct payload is sent when a subagent is cancelled. Updated localization files to include new messages for subagent statuses.
@kels-ng
Copy link
Author

kels-ng commented Feb 12, 2026

Added locales for the rest languages. We can start from this point.
PR is pretty big, but most of the changes from locales. I'm open for discussions!

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.

1 participant