Skip to content

Commit d0c9174

Browse files
committed
Add enableUserPrompt command line option to disable userPrompt tool for automated sessions
1 parent c82916c commit d0c9174

File tree

7 files changed

+54
-16
lines changed

7 files changed

+54
-16
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'mycoder': patch
3+
'mycoder-agent': patch
4+
---
5+
6+
Add `--enableUserPrompt` command line option that defaults to true but can be set to false to disable the userPrompt tool for fully automated sessions.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ mycoder "Implement a React component that displays a list of items"
3434
# Run with a prompt from a file
3535
mycoder -f prompt.txt
3636

37+
# Disable user prompts for fully automated sessions
38+
mycoder --enableUserPrompt false "Generate a basic Express.js server"
39+
3740
# Enable GitHub mode
3841
mycoder config set githubMode true
3942
```

packages/agent/src/core/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type ToolContext = {
1919
githubMode: boolean;
2020
customPrompt?: string;
2121
tokenCache?: boolean;
22+
enableUserPrompt?: boolean;
2223
};
2324

2425
export type Tool<TParams = Record<string, any>, TReturn = any> = {
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Tool } from '../core/types.js';
22

3+
// Import tools
34
import { browseMessageTool } from './browser/browseMessage.js';
45
import { browseStartTool } from './browser/browseStart.js';
56
import { subAgentTool } from './interaction/subAgent.js';
@@ -12,18 +13,33 @@ import { shellMessageTool } from './system/shellMessage.js';
1213
import { shellStartTool } from './system/shellStart.js';
1314
import { sleepTool } from './system/sleep.js';
1415

15-
export function getTools(): Tool[] {
16-
return [
17-
textEditorTool,
18-
subAgentTool,
19-
userPromptTool,
20-
sequenceCompleteTool,
21-
fetchTool,
22-
shellStartTool,
23-
shellMessageTool,
24-
browseStartTool,
25-
browseMessageTool,
26-
respawnTool,
27-
sleepTool,
28-
] as Tool[];
16+
// Import these separately to avoid circular dependencies
17+
18+
interface GetToolsOptions {
19+
enableUserPrompt?: boolean;
20+
}
21+
22+
export function getTools(options?: GetToolsOptions): Tool[] {
23+
const enableUserPrompt = options?.enableUserPrompt !== false; // Default to true if not specified
24+
25+
// Force cast to Tool type to avoid TypeScript issues
26+
const tools: Tool[] = [
27+
textEditorTool as unknown as Tool,
28+
subAgentTool as unknown as Tool,
29+
sequenceCompleteTool as unknown as Tool,
30+
fetchTool as unknown as Tool,
31+
shellStartTool as unknown as Tool,
32+
shellMessageTool as unknown as Tool,
33+
browseStartTool as unknown as Tool,
34+
browseMessageTool as unknown as Tool,
35+
respawnTool as unknown as Tool,
36+
sleepTool as unknown as Tool,
37+
];
38+
39+
// Only include userPrompt tool if enabled
40+
if (enableUserPrompt) {
41+
tools.push(userPromptTool as unknown as Tool);
42+
}
43+
44+
return tools;
2945
}

packages/agent/src/tools/interaction/subAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const subAgentTool: Tool<Parameters, ReturnType> = {
9090
.filter(Boolean)
9191
.join('\n');
9292

93-
const tools = getTools().filter((tool) => tool.name !== 'userPrompt');
93+
const tools = getTools({ enableUserPrompt: false });
9494

9595
// Update config if timeout is specified
9696
const config = {

packages/cli/src/commands/$default.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ export const command: CommandModule<SharedOptions, DefaultArgs> = {
162162
'Once the task is complete ask the user, via the userPrompt tool if the results are acceptable or if changes are needed or if there are additional follow on tasks.',
163163
].join('\n');
164164

165-
const tools = getTools();
165+
const tools = getTools({
166+
enableUserPrompt:
167+
argv.enableUserPrompt !== undefined ? argv.enableUserPrompt : true,
168+
});
166169

167170
// Error handling
168171
process.on('SIGINT', () => {
@@ -202,6 +205,8 @@ export const command: CommandModule<SharedOptions, DefaultArgs> = {
202205
customPrompt: config.customPrompt,
203206
tokenCache:
204207
argv.tokenCache !== undefined ? argv.tokenCache : config.tokenCache,
208+
enableUserPrompt:
209+
argv.enableUserPrompt !== undefined ? argv.enableUserPrompt : true,
205210
});
206211

207212
const output =

packages/cli/src/options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type SharedOptions = {
1313
readonly temperature?: number;
1414
readonly profile?: boolean;
1515
readonly tokenCache?: boolean;
16+
readonly enableUserPrompt?: boolean;
1617
};
1718

1819
export const sharedOptions = {
@@ -87,4 +88,10 @@ export const sharedOptions = {
8788
type: 'boolean',
8889
description: 'Enable token caching for LLM API calls',
8990
} as const,
91+
enableUserPrompt: {
92+
type: 'boolean',
93+
description:
94+
'Enable or disable the userPrompt tool (disable for fully automated sessions)',
95+
default: true,
96+
} as const,
9097
};

0 commit comments

Comments
 (0)