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
69 changes: 57 additions & 12 deletions apps/code/src/main/services/agent/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,56 @@ const onAgentLog: OnLogCallback = (level, scope, message, data) => {
}
};

const HAIKU_EXPLORE_AGENT_OVERRIDE = {
description:
'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.',
model: "haiku",
prompt: `You are a fast, read-only codebase exploration agent.

Your job is to find files, search code, read the most relevant sources, and report findings clearly.

Rules:
- Never create, modify, delete, move, or copy files.
- Never use shell redirection or any command that changes system state.
- Use Glob for broad file pattern matching.
- Use Grep for searching file contents.
- Use Read when you know the exact file path to inspect.
- Use Bash only for safe read-only commands like ls, git status, git log, git diff, find, cat, head, and tail.
- Adapt your search approach based on the thoroughness level specified by the caller.
- Return file paths as absolute paths in your final response.
- Avoid using emojis.
- Wherever possible, spawn multiple parallel tool calls for grepping and reading files.
- Search efficiently, then read only the most relevant files.
- Return findings directly in your final response — do not create files.`,
tools: [
"Bash",
"Glob",
"Grep",
"Read",
"WebFetch",
"WebSearch",
"NotebookRead",
"TodoWrite",
],
};

function buildClaudeCodeOptions(args: {
additionalDirectories?: string[];
effort?: EffortLevel;
plugins: { type: "local"; path: string }[];
}) {
return {
...(args.additionalDirectories?.length && {
additionalDirectories: args.additionalDirectories,
}),
...(args.effort && { effort: args.effort }),
plugins: args.plugins,
agents: {
Explore: HAIKU_EXPLORE_AGENT_OVERRIDE,
},
};
}

interface SessionConfig {
taskId: string;
taskRunId: string;
Expand Down Expand Up @@ -601,6 +651,11 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
},
...externalPlugins,
];
const claudeCodeOptions = buildClaudeCodeOptions({
additionalDirectories,
effort,
plugins,
});

let configOptions: SessionConfigOption[] | undefined;
let agentSessionId: string;
Expand Down Expand Up @@ -648,13 +703,7 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
...(permissionMode && { permissionMode }),
...(model != null && { model }),
claudeCode: {
options: {
...(additionalDirectories?.length && {
additionalDirectories,
}),
...(effort && { effort }),
plugins,
},
options: claudeCodeOptions,
},
},
});
Expand All @@ -680,11 +729,7 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
...(permissionMode && { permissionMode }),
...(model != null && { model }),
claudeCode: {
options: {
...(additionalDirectories?.length && { additionalDirectories }),
...(effort && { effort }),
plugins,
},
options: claudeCodeOptions,
},
},
});
Expand Down
Loading
Loading