/ tools / AgentTool / builtInAgents.ts
builtInAgents.ts
 1  import { feature } from 'bun:bundle'
 2  import { getIsNonInteractiveSession } from '../../bootstrap/state.js'
 3  import { getFeatureValue_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js'
 4  import { isEnvTruthy } from '../../utils/envUtils.js'
 5  import { CLAUDE_CODE_GUIDE_AGENT } from './built-in/claudeCodeGuideAgent.js'
 6  import { EXPLORE_AGENT } from './built-in/exploreAgent.js'
 7  import { GENERAL_PURPOSE_AGENT } from './built-in/generalPurposeAgent.js'
 8  import { PLAN_AGENT } from './built-in/planAgent.js'
 9  import { STATUSLINE_SETUP_AGENT } from './built-in/statuslineSetup.js'
10  import { VERIFICATION_AGENT } from './built-in/verificationAgent.js'
11  import type { AgentDefinition } from './loadAgentsDir.js'
12  
13  export function areExplorePlanAgentsEnabled(): boolean {
14    if (feature('BUILTIN_EXPLORE_PLAN_AGENTS')) {
15      // 3P default: true — Bedrock/Vertex keep agents enabled (matches pre-experiment
16      // external behavior). A/B test treatment sets false to measure impact of removal.
17      return getFeatureValue_CACHED_MAY_BE_STALE('tengu_amber_stoat', true)
18    }
19    return false
20  }
21  
22  export function getBuiltInAgents(): AgentDefinition[] {
23    // Allow disabling all built-in agents via env var (useful for SDK users who want a blank slate)
24    // Only applies in noninteractive mode (SDK/API usage)
25    if (
26      isEnvTruthy(process.env.CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS) &&
27      getIsNonInteractiveSession()
28    ) {
29      return []
30    }
31  
32    // Use lazy require inside the function body to avoid circular dependency
33    // issues at module init time. The coordinatorMode module depends on tools
34    // which depend on AgentTool which imports this file.
35    if (feature('COORDINATOR_MODE')) {
36      if (isEnvTruthy(process.env.CLAUDE_CODE_COORDINATOR_MODE)) {
37        /* eslint-disable @typescript-eslint/no-require-imports */
38        const { getCoordinatorAgents } =
39          require('../../coordinator/workerAgent.js') as typeof import('../../coordinator/workerAgent.js')
40        /* eslint-enable @typescript-eslint/no-require-imports */
41        return getCoordinatorAgents()
42      }
43    }
44  
45    const agents: AgentDefinition[] = [
46      GENERAL_PURPOSE_AGENT,
47      STATUSLINE_SETUP_AGENT,
48    ]
49  
50    if (areExplorePlanAgentsEnabled()) {
51      agents.push(EXPLORE_AGENT, PLAN_AGENT)
52    }
53  
54    // Include Code Guide agent for non-SDK entrypoints
55    const isNonSdkEntrypoint =
56      process.env.CLAUDE_CODE_ENTRYPOINT !== 'sdk-ts' &&
57      process.env.CLAUDE_CODE_ENTRYPOINT !== 'sdk-py' &&
58      process.env.CLAUDE_CODE_ENTRYPOINT !== 'sdk-cli'
59  
60    if (isNonSdkEntrypoint) {
61      agents.push(CLAUDE_CODE_GUIDE_AGENT)
62    }
63  
64    if (
65      feature('VERIFICATION_AGENT') &&
66      getFeatureValue_CACHED_MAY_BE_STALE('tengu_hive_evidence', false)
67    ) {
68      agents.push(VERIFICATION_AGENT)
69    }
70  
71    return agents
72  }