-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: builtin subagents #10830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
uinstinct
wants to merge
9
commits into
continuedev:main
Choose a base branch
from
uinstinct:cli-default-subagents
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+200
−72
Open
feat: builtin subagents #10830
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e6c04e9
remove unnecessary lint
uinstinct ce5cf78
add tool result in chat history for subagent
uinstinct 4125fb2
prevent nested subagent execution
uinstinct bbcf04e
add builtin subagents
uinstinct d5676db
refine subagent tool description
uinstinct e19a8b1
put subagent tool out of beta
uinstinct 40394bc
Merge branch 'main' into cli-default-subagents
uinstinct c116640
rename to getAgents
uinstinct af13df6
change code review to generalist subagent
uinstinct File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import type { ModelConfig } from "@continuedev/config-yaml"; | ||
|
|
||
| import { logger } from "src/util/logger.js"; | ||
|
|
||
| export interface BuiltInSubagent { | ||
| name: string; | ||
| systemPrompt: string; | ||
| model: string; | ||
| } | ||
|
|
||
| export const NAVIGATOR_SUBAGENT: BuiltInSubagent = { | ||
| name: "navigator", | ||
| model: "claude-haiku-4-5", | ||
| systemPrompt: `You are a Codebase Navigator subagent specialized in exploring, searching, and mapping large codebases. | ||
|
|
||
| When to use: | ||
|
|
||
| Use this subagent whenever you need to explore or find or understand a codebase or a folder. | ||
|
|
||
| When navigating a codebase, you will: | ||
|
|
||
| 1. **Locate Relevant Code**: Use file and code search tools to find the most relevant files, modules, functions, and types. Prefer a small, high-signal set of locations over exhaustive listings. | ||
|
|
||
| 2. **Trace Behavior and Dependencies**: Follow call chains, imports, and data flow to understand how the relevant pieces interact, including upstream/downstream dependencies and important side effects. | ||
|
|
||
| 3. **Map the Codebase for Others**: Build a concise mental map: which components are core, which are helpers, where entry points live, and how configuration or environment affects behavior. | ||
|
|
||
| Your output should be concise and actionable, starting with a brief summary of what you found and listing the key files/paths, functions, symbols, and important relationships or flows between them in plain language. If you cannot find something, describe what you searched for, where you looked, and suggest next places or strategies to investigate.`, | ||
| }; | ||
|
|
||
| export const GENERALIST_SUBAGENT: BuiltInSubagent = { | ||
| name: "general-tasker", | ||
| model: "claude-sonnet-4-6", | ||
| systemPrompt: `You are a Generalist subagent capable of handling any development task delegated to you. | ||
|
|
||
| When to use: | ||
|
|
||
| Use this subagent for any task that doesn't require a specialized subagent, including but not limited to: implementing features, fixing bugs, refactoring, code review, documentation, research, debugging, and analysis. | ||
|
|
||
| When handling a task, you will: | ||
|
|
||
| 1. **Interpret the Request**: Understand what is being asked, whether it's exploration, implementation, review, analysis, or something else entirely. Adapt your approach based on the nature of the task. | ||
|
|
||
| 2. **Gather Context**: Use available tools to explore the codebase, read relevant files, and understand the surrounding architecture before taking action or forming conclusions. | ||
|
|
||
| 3. **Communicate Results**: Provide clear, actionable output tailored to the task. Summarize what you did or discovered, highlight key insights or changes, and note any open questions or recommended next steps. | ||
|
|
||
| You are flexible and resourceful. If a task is ambiguous, make reasonable assumptions and state them. If you encounter blockers, describe what you attempted and suggest alternatives.`, | ||
| }; | ||
|
|
||
| export const BUILT_IN_SUBAGENTS: BuiltInSubagent[] = [ | ||
| NAVIGATOR_SUBAGENT, | ||
| GENERALIST_SUBAGENT, | ||
| ]; | ||
|
|
||
| export function createBuiltInSubagentModel( | ||
| subagent: BuiltInSubagent, | ||
| baseModel: ModelConfig, | ||
| ): ModelConfig { | ||
| return { | ||
| ...baseModel, | ||
| name: subagent.name, | ||
| model: subagent.model, | ||
| roles: ["subagent"], | ||
| chatOptions: { | ||
| ...baseModel.chatOptions, | ||
| baseSystemMessage: subagent.systemPrompt, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| export function isLocalAnthropicModel(model: ModelConfig | null): boolean { | ||
| if (!model) { | ||
| return false; | ||
| } | ||
|
|
||
| const isAnthropic = model.provider === "anthropic"; | ||
| const hasDirectApiKey = | ||
| typeof model.apiKey === "string" && model.apiKey.length > 0; | ||
|
|
||
| logger.debug("subagent_enabled_for_anthropic", { | ||
| enabled: isAnthropic && hasDirectApiKey, | ||
| }); | ||
|
|
||
| return isAnthropic && hasDirectApiKey; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { createLlmApi } from "../config.js"; | ||
| import { ModelService } from "../services/ModelService.js"; | ||
| import type { ModelServiceState } from "../services/types.js"; | ||
|
|
||
| import { | ||
| BUILT_IN_SUBAGENTS, | ||
| createBuiltInSubagentModel, | ||
| isLocalAnthropicModel, | ||
| } from "./builtInSubagents.js"; | ||
|
|
||
| function getAllSubagentModels(modelState: ModelServiceState) { | ||
| const configSubagents = ModelService.getSubagentModels(modelState); | ||
|
|
||
| if (!isLocalAnthropicModel(modelState.model)) { | ||
| return configSubagents; | ||
| } | ||
|
|
||
| const builtInSubagents = BUILT_IN_SUBAGENTS.map((subagent) => { | ||
| const subagentModel = createBuiltInSubagentModel( | ||
| subagent, | ||
| modelState.model!, | ||
| ); | ||
| return { | ||
| llmApi: createLlmApi(subagentModel, modelState.authConfig), | ||
| model: subagentModel, | ||
| assistant: modelState.assistant, | ||
| authConfig: modelState.authConfig, | ||
| }; | ||
| }); | ||
|
|
||
| return [...configSubagents, ...builtInSubagents]; | ||
| } | ||
|
|
||
| export function getSubagent(modelState: ModelServiceState, name: string) { | ||
| return ( | ||
| getAllSubagentModels(modelState).find( | ||
| (model) => model.model.name === name, | ||
| ) ?? null | ||
| ); | ||
| } | ||
|
|
||
| export function generateSubagentToolDescription( | ||
| modelState: ModelServiceState, | ||
| ): string { | ||
| const agentList = getAllSubagentModels(modelState) | ||
| .map( | ||
| (subagentModel) => | ||
| ` - ${subagentModel.model.name}: ${subagentModel.model.chatOptions?.baseSystemMessage}`, | ||
| ) | ||
| .join("\n"); | ||
|
|
||
| return `Launch an autonomous specialized subagent to handle a specific task. | ||
|
|
||
| You have the independence to make decisions within you scope. You should focus on the specific task given by the main agent. | ||
|
|
||
| Remember: You are part of a larger system. Your specialized focus helps the main agent handle multiple concerns efficiently. | ||
|
|
||
| Here are the available subagents: | ||
| ${agentList} | ||
| `; | ||
| } | ||
|
|
||
| export function getAgentNames(modelState: ModelServiceState): string[] { | ||
| return getAllSubagentModels(modelState).map((model) => model.model.name); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Mock path no longer matches the imported module path, so getAgentNames/getSubagent won’t be mocked and vi.mocked(...).mockReturnValue may fail or run real logic.
Prompt for AI agents