Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 0 additions & 2 deletions src/constants/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export const ALL_AGENT_DISALLOWED_TOOLS = new Set([
TASK_OUTPUT_TOOL_NAME,
EXIT_PLAN_MODE_V2_TOOL_NAME,
ENTER_PLAN_MODE_TOOL_NAME,
// Allow Agent tool for agents when user is ant (enables nested agents)
...(process.env.USER_TYPE === 'ant' ? [] : [AGENT_TOOL_NAME]),
ASK_USER_QUESTION_TOOL_NAME,
TASK_STOP_TOOL_NAME,
// Prevent recursive workflow execution inside subagents.
Expand Down
29 changes: 2 additions & 27 deletions src/services/tips/tipRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ const externalTips: Tip[] = [
`Use Plan Mode to prepare for a complex request before making changes. Press ${getShortcutDisplay('chat:cycleMode', 'Chat', 'shift+tab')} twice to enable.`,
cooldownSessions: 5,
isRelevant: async () => {
if (process.env.USER_TYPE === 'ant') return false
const config = getGlobalConfig()
// Show to users who haven't used plan mode recently (7+ days)
const daysSinceLastUse = config.lastPlanModeUse
Expand Down Expand Up @@ -401,9 +400,7 @@ const externalTips: Tip[] = [
{
id: 'shift-tab',
content: async () =>
process.env.USER_TYPE === 'ant'
? `Hit ${getShortcutDisplay('chat:cycleMode', 'Chat', 'shift+tab')} to cycle between default mode and auto mode`
: `Hit ${getShortcutDisplay('chat:cycleMode', 'Chat', 'shift+tab')} to cycle between default mode, auto-accept edit mode, and plan mode`,
`Hit ${getShortcutDisplay('chat:cycleMode', 'Chat', 'shift+tab')} to cycle between default mode, auto-accept edit mode, and plan mode`,
cooldownSessions: 10,
isRelevant: async () => true,
},
Expand Down Expand Up @@ -476,7 +473,6 @@ const externalTips: Tip[] = [
`Your default model setting is Opus Plan Mode. Press ${getShortcutDisplay('chat:cycleMode', 'Chat', 'shift+tab')} twice to activate Plan Mode and plan with Claude Opus.`,
cooldownSessions: 2,
async isRelevant() {
if (process.env.USER_TYPE === 'ant') return false
const config = getGlobalConfig()
const modelSetting = getUserSpecifiedModelSetting()
const hasOpusPlanMode = modelSetting === 'opusplan'
Expand Down Expand Up @@ -624,33 +620,12 @@ const externalTips: Tip[] = [
content: async () => 'Use /feedback to help us improve!',
cooldownSessions: 15,
async isRelevant() {
if (process.env.USER_TYPE === 'ant') {
return false
}
const config = getGlobalConfig()
return config.numStartups > 5
},
},
]
const internalOnlyTips: Tip[] =
process.env.USER_TYPE === 'ant'
? [
{
id: 'important-claudemd',
content: async () =>
'[internal] Use "IMPORTANT:" prefix for must-follow CLAUDE.md rules',
cooldownSessions: 30,
isRelevant: async () => true,
},
{
id: 'skillify',
content: async () =>
'[internal] Use /skillify to turn repeatable recurring workflows into reusable project skills',
cooldownSessions: 15,
isRelevant: async () => true,
},
]
: []
const internalOnlyTips: Tip[] = []

function getCustomTips(): Tip[] {
const settings = getInitialSettings()
Expand Down
5 changes: 2 additions & 3 deletions src/tools/AgentTool/built-in/exploreAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ export const EXPLORE_AGENT: BuiltInAgentDefinition = {
],
source: 'built-in',
baseDir: 'built-in',
// Ants get inherit to use the main agent's model; external users get haiku for speed
// Note: For ants, getAgentModel() checks tengu_explore_agent GrowthBook flag at runtime
model: process.env.USER_TYPE === 'ant' ? 'inherit' : 'haiku',
// Use haiku for speed — explore is a fast read-only search agent
model: 'haiku',
// Explore is a fast read-only search agent — it doesn't need commit/PR/lint
// rules from CLAUDE.md. The main agent has full context and interprets results.
omitClaudeMd: true,
Expand Down
44 changes: 21 additions & 23 deletions src/tools/BashTool/shouldUseSandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,32 @@ type SandboxInput = {
// It is not a security bug to be able to bypass excludedCommands — the sandbox permission
// system (which prompts users) is the actual security control.
function containsExcludedCommand(command: string): boolean {
// Check dynamic config for disabled commands and substrings (only for ants)
if (process.env.USER_TYPE === 'ant') {
const disabledCommands = getFeatureValue_CACHED_MAY_BE_STALE<{
commands: string[]
substrings: string[]
}>('tengu_sandbox_disabled_commands', { commands: [], substrings: [] })
// Check dynamic config for disabled commands and substrings
const disabledCommands = getFeatureValue_CACHED_MAY_BE_STALE<{
commands: string[]
substrings: string[]
}>('tengu_sandbox_disabled_commands', { commands: [], substrings: [] })

Comment thread
Flo5k5 marked this conversation as resolved.
Resolved
// Check if command contains any disabled substrings
for (const substring of disabledCommands.substrings) {
if (command.includes(substring)) {
return true
}
// Check if command contains any disabled substrings
for (const substring of disabledCommands.substrings) {
if (command.includes(substring)) {
return true
Comment thread
Flo5k5 marked this conversation as resolved.
Resolved
}
}

// Check if command starts with any disabled commands
try {
const commandParts = splitCommand_DEPRECATED(command)
for (const part of commandParts) {
const baseCommand = part.trim().split(' ')[0]
if (baseCommand && disabledCommands.commands.includes(baseCommand)) {
return true
}
// Check if command starts with any disabled commands
try {
const commandParts = splitCommand_DEPRECATED(command)
for (const part of commandParts) {
const baseCommand = part.trim().split(' ')[0]
if (baseCommand && disabledCommands.commands.includes(baseCommand)) {
return true
}
} catch {
// If we can't parse the command (e.g., malformed bash syntax),
// treat it as not excluded to allow other validation checks to handle it
// This prevents crashes when rendering tool use messages
}
} catch {
// If we can't parse the command (e.g., malformed bash syntax),
// treat it as not excluded to allow other validation checks to handle it
// This prevents crashes when rendering tool use messages
}

// Check user-configured excluded commands from settings
Expand Down
69 changes: 1 addition & 68 deletions src/tools/EnterPlanModeTool/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,73 +98,6 @@ User: "What files handle routing?"
`
}

function getEnterPlanModeToolPromptAnt(): string {
// When interview phase is enabled, omit the "What Happens" section —
// detailed workflow instructions arrive via the plan_mode attachment (messages.ts).
const whatHappens = isPlanModeInterviewPhaseEnabled()
? ''
: WHAT_HAPPENS_SECTION

return `Use this tool when a task has genuine ambiguity about the right approach and getting user input before coding would prevent significant rework. This tool transitions you into plan mode where you can explore the codebase and design an implementation approach for user approval.

## When to Use This Tool

Plan mode is valuable when the implementation approach is genuinely unclear. Use it when:

1. **Significant Architectural Ambiguity**: Multiple reasonable approaches exist and the choice meaningfully affects the codebase
- Example: "Add caching to the API" - Redis vs in-memory vs file-based
- Example: "Add real-time updates" - WebSockets vs SSE vs polling

2. **Unclear Requirements**: You need to explore and clarify before you can make progress
- Example: "Make the app faster" - need to profile and identify bottlenecks
- Example: "Refactor this module" - need to understand what the target architecture should be

3. **High-Impact Restructuring**: The task will significantly restructure existing code and getting buy-in first reduces risk
- Example: "Redesign the authentication system"
- Example: "Migrate from one state management approach to another"

## When NOT to Use This Tool

Skip plan mode when you can reasonably infer the right approach:
- The task is straightforward even if it touches multiple files
- The user's request is specific enough that the implementation path is clear
- You're adding a feature with an obvious implementation pattern (e.g., adding a button, a new endpoint following existing conventions)
- Bug fixes where the fix is clear once you understand the bug
- Research/exploration tasks (use the Agent tool instead)
- The user says something like "can we work on X" or "let's do X" — just get started

When in doubt, prefer starting work and using ${ASK_USER_QUESTION_TOOL_NAME} for specific questions over entering a full planning phase.

${whatHappens}## Examples

### GOOD - Use EnterPlanMode:
User: "Add user authentication to the app"
- Genuinely ambiguous: session vs JWT, where to store tokens, middleware structure

User: "Redesign the data pipeline"
- Major restructuring where the wrong approach wastes significant effort

### BAD - Don't use EnterPlanMode:
User: "Add a delete button to the user profile"
- Implementation path is clear; just do it

User: "Can we work on the search feature?"
- User wants to get started, not plan

User: "Update the error handling in the API"
- Start working; ask specific questions if needed

User: "Fix the typo in the README"
- Straightforward, no planning needed

## Important Notes

- This tool REQUIRES user approval - they must consent to entering plan mode
`
}

export function getEnterPlanModeToolPrompt(): string {
return process.env.USER_TYPE === 'ant'
? getEnterPlanModeToolPromptAnt()
: getEnterPlanModeToolPromptExternal()
return getEnterPlanModeToolPromptExternal()
}
8 changes: 4 additions & 4 deletions src/utils/effort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function parseEffortValue(value: unknown): EffortValue | undefined {

/**
* Numeric values are model-default only and not persisted.
* 'max' is session-scoped for external users (ants can persist it).
* 'max' can now be persisted by all users.
* Write sites call this before saving to settings so the Zod schema
* (which only accepts string levels) never rejects a write.
*/
Expand All @@ -146,15 +146,15 @@ export function toPersistableEffort(
if (value === 'low' || value === 'medium' || value === 'high') {
return value
}
if (value === 'max' && process.env.USER_TYPE === 'ant') {
if (value === 'max') {
return value
Comment thread
Flo5k5 marked this conversation as resolved.
Resolved
}
return undefined
}

export function getInitialEffortSetting(): EffortLevel | undefined {
// toPersistableEffort filters 'max' for non-ants on read, so a manually
// edited settings.json doesn't leak session-scoped max into a fresh session.
// toPersistableEffort validates 'max' on read, so a manually
// edited settings.json with an invalid level doesn't leak into a fresh session.
return toPersistableEffort(getInitialSettings().effortLevel)
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/fullscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function isFullscreenEnvEnabled(): boolean {
// `/config` without having to set an env var.
const configValue = getGlobalConfig().flickerFreeMode
if (configValue !== undefined) return configValue
return process.env.USER_TYPE === 'ant'
return false
Comment thread
Flo5k5 marked this conversation as resolved.
Resolved
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/utils/planModeV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ export function getPlanModeV2ExploreAgentCount(): number {
/**
* Check if plan mode interview phase is enabled.
*
* Config: ant=always_on, external=tengu_plan_mode_interview_phase gate, envVar=true
* Config: tengu_plan_mode_interview_phase gate, envVar=true
*/
export function isPlanModeInterviewPhaseEnabled(): boolean {
// Always on for ants
if (process.env.USER_TYPE === 'ant') return true

const env = process.env.CLAUDE_CODE_PLAN_MODE_INTERVIEW_PHASE
if (isEnvTruthy(env)) return true
if (isEnvDefinedFalsy(env)) return false
Expand Down
Loading