Skip to content

Commit cd72840

Browse files
committed
fix(code): fix subagent sessions
1 parent c532d71 commit cd72840

File tree

4 files changed

+76
-14
lines changed

4 files changed

+76
-14
lines changed

apps/code/src/main/services/agent/service.ts

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,56 @@ const onAgentLog: OnLogCallback = (level, scope, message, data) => {
177177
}
178178
};
179179

180+
const HAIKU_EXPLORE_AGENT_OVERRIDE = {
181+
description:
182+
'Fast agent for exploring and understanding codebases. Use this when you need to find files by pattern (eg. "src/components/**/*.tsx"), search for code or keywords (eg. "where is the auth middleware?"), or answer questions about how the codebase works (eg. "how does the session service handle reconnects?"). When calling this agent, specify a thoroughness level: "quick" for targeted lookups, "medium" for broader exploration, or "very thorough" for comprehensive analysis across multiple locations.',
183+
model: "haiku",
184+
prompt: `You are a fast, read-only codebase exploration agent.
185+
186+
Your job is to find files, search code, read the most relevant sources, and report findings clearly.
187+
188+
Rules:
189+
- Never create, modify, delete, move, or copy files.
190+
- Never use shell redirection or any command that changes system state.
191+
- Use Glob for broad file pattern matching.
192+
- Use Grep for searching file contents.
193+
- Use Read when you know the exact file path to inspect.
194+
- Use Bash only for safe read-only commands like ls, git status, git log, git diff, find, cat, head, and tail.
195+
- Adapt your search approach based on the thoroughness level specified by the caller.
196+
- Return file paths as absolute paths in your final response.
197+
- Avoid using emojis.
198+
- Wherever possible, spawn multiple parallel tool calls for grepping and reading files.
199+
- Search efficiently, then read only the most relevant files.
200+
- Return findings directly in your final response — do not create files.`,
201+
tools: [
202+
"Bash",
203+
"Glob",
204+
"Grep",
205+
"Read",
206+
"WebFetch",
207+
"WebSearch",
208+
"NotebookRead",
209+
"TodoWrite",
210+
],
211+
};
212+
213+
function buildClaudeCodeOptions(args: {
214+
additionalDirectories?: string[];
215+
effort?: EffortLevel;
216+
plugins: { type: "local"; path: string }[];
217+
}) {
218+
return {
219+
...(args.additionalDirectories?.length && {
220+
additionalDirectories: args.additionalDirectories,
221+
}),
222+
...(args.effort && { effort: args.effort }),
223+
plugins: args.plugins,
224+
agents: {
225+
Explore: HAIKU_EXPLORE_AGENT_OVERRIDE,
226+
},
227+
};
228+
}
229+
180230
interface SessionConfig {
181231
taskId: string;
182232
taskRunId: string;
@@ -601,6 +651,11 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
601651
},
602652
...externalPlugins,
603653
];
654+
const claudeCodeOptions = buildClaudeCodeOptions({
655+
additionalDirectories,
656+
effort,
657+
plugins,
658+
});
604659

605660
let configOptions: SessionConfigOption[] | undefined;
606661
let agentSessionId: string;
@@ -648,13 +703,7 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
648703
...(permissionMode && { permissionMode }),
649704
...(model != null && { model }),
650705
claudeCode: {
651-
options: {
652-
...(additionalDirectories?.length && {
653-
additionalDirectories,
654-
}),
655-
...(effort && { effort }),
656-
plugins,
657-
},
706+
options: claudeCodeOptions,
658707
},
659708
},
660709
});
@@ -680,11 +729,7 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
680729
...(permissionMode && { permissionMode }),
681730
...(model != null && { model }),
682731
claudeCode: {
683-
options: {
684-
...(additionalDirectories?.length && { additionalDirectories }),
685-
...(effort && { effort }),
686-
plugins,
687-
},
732+
options: claudeCodeOptions,
688733
},
689734
},
690735
});

0 commit comments

Comments
 (0)