Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ public static class Builder {
boolean disableWorkspaceContext = false;
boolean disableAtPathExpansion = false;
boolean disableSubagents = false;
boolean disableGeneralPurposeSubagent = false;
boolean disableDynamicSkills = false;
boolean disableDefaultWorkspaceSkills = false;
boolean disableDynamicSubagents = false;
Expand Down Expand Up @@ -1937,6 +1938,17 @@ public Builder disableSubagents() {
return this;
}

/**
* Disables the built-in {@code general-purpose} subagent while keeping declared and custom
* subagents available.
*
* @return this builder
*/
public Builder disableGeneralPurposeSubagent() {
this.disableGeneralPurposeSubagent = true;
return this;
}

public Builder disableToolsConfig() {
this.disableToolsConfig = true;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,15 @@ static List<SubagentEntry> buildSubagentEntries(

List<SubagentEntry> entries = new ArrayList<>();

entries.add(
new SubagentEntry(
"general-purpose",
"General-purpose subagent with same capabilities as the main agent."
+ " Use for any isolated task that can be fully delegated.",
buildGeneralPurposeFactory(b, resolvedWorkspace, sandboxFs),
null));
if (!b.disableGeneralPurposeSubagent) {
entries.add(
new SubagentEntry(
"general-purpose",
"General-purpose subagent with same capabilities as the main agent."
+ " Use for any isolated task that can be fully delegated.",
buildGeneralPurposeFactory(b, resolvedWorkspace, sandboxFs),
null));
}

for (SubagentDeclaration decl : allDeclarations) {
entries.add(
Expand Down Expand Up @@ -240,13 +242,15 @@ static List<SubagentEntry> buildStaticSubagentEntries(
HarnessAgent.Builder b, Path resolvedWorkspace, SandboxBackedFilesystem sandboxFs) {
List<SubagentEntry> entries = new ArrayList<>();

entries.add(
new SubagentEntry(
"general-purpose",
"General-purpose subagent with same capabilities as the main agent."
+ " Use for any isolated task that can be fully delegated.",
buildGeneralPurposeFactory(b, resolvedWorkspace, sandboxFs),
null));
if (!b.disableGeneralPurposeSubagent) {
entries.add(
new SubagentEntry(
"general-purpose",
"General-purpose subagent with same capabilities as the main agent."
+ " Use for any isolated task that can be fully delegated.",
buildGeneralPurposeFactory(b, resolvedWorkspace, sandboxFs),
null));
}

for (SubagentDeclaration decl : b.subagentDeclarations) {
entries.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,53 @@ void subagentMarkdown_registersIdsAndSubagentTools() throws Exception {
"built-in general-purpose entry should be listed");
}

@Test
void disableGeneralPurposeSubagent_keepsDeclaredSubagentsAvailable() throws Exception {
Files.createDirectories(workspace);
Files.writeString(workspace.resolve(WorkspaceConstants.AGENTS_MD), "# workspace\n");
Path subagents = workspace.resolve("subagents");
Files.createDirectories(subagents);
Files.writeString(
subagents.resolve("specialist.md"),
"""
---
description: A custom specialist subagent
---
You only reply OK.
""");

Model model = stubModel("done");
HarnessAgent.Builder builder =
HarnessAgent.builder()
.name("main")
.model(model)
.workspace(workspace)
.abstractFilesystem(new LocalFilesystem(workspace))
.disableGeneralPurposeSubagent();

List<String> entryNames =
builder.buildSubagentEntries(workspace).stream()
.map(SubagentEntry::name)
.collect(Collectors.toList());
assertFalse(entryNames.contains("general-purpose"));
assertTrue(entryNames.contains("specialist"));

HarnessAgent agent = builder.build();
agent.call(userText("go"), RuntimeContext.builder().sessionId("s2").build()).block();

@SuppressWarnings("unchecked")
ArgumentCaptor<List<Msg>> captor = ArgumentCaptor.forClass(List.class);
verify(model, atLeast(1)).stream(captor.capture(), any(), any());
String combined =
captor.getAllValues().stream()
.map(HarnessAgentTest::joinAllText)
.filter(s -> s.contains("## Subagents"))
.findFirst()
.orElse("");
assertTrue(combined.contains("`specialist`"));
assertFalse(combined.contains("general-purpose"));
}

@Test
void subagentsDir_loadsMarkdownDeclarations() throws Exception {
Files.createDirectories(workspace);
Expand Down
Loading