Skip to content

Commit 7e40d06

Browse files
author
Theodore Li
committed
fix: add promptForToolApproval to prevent tool hang in mothership chat
Tools with requiresConfirmation (e.g. user_table) blocked indefinitely in mothership because the frontend has no approval UI. Added a new promptForToolApproval orchestrator option so mothership auto-executes these tools while copilot continues to prompt for user approval. Made-with: Cursor
1 parent 738d51a commit 7e40d06

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

apps/sim/app/api/copilot/chat/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ export async function POST(req: NextRequest) {
302302
goRoute: '/api/copilot',
303303
autoExecuteTools: true,
304304
interactive: true,
305+
promptForToolApproval: true,
305306
},
306307
})
307308

@@ -315,6 +316,7 @@ export async function POST(req: NextRequest) {
315316
goRoute: '/api/copilot',
316317
autoExecuteTools: true,
317318
interactive: true,
319+
promptForToolApproval: true,
318320
})
319321

320322
const responseData = {

apps/sim/app/api/mothership/chat/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ export async function POST(req: NextRequest) {
261261
chatId: actualChatId,
262262
goRoute: '/api/mothership',
263263
autoExecuteTools: true,
264-
interactive: false,
264+
interactive: true,
265+
promptForToolApproval: false,
265266
onComplete: async (result: OrchestratorResult) => {
266267
if (!actualChatId) return
267268

apps/sim/lib/copilot/orchestrator/sse/handlers/handlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ export const sseHandlers: Record<string, SSEHandler> = {
320320
return
321321
}
322322

323-
if (requiresConfirmation) {
323+
if (requiresConfirmation && options.promptForToolApproval) {
324324
const decision = await waitForToolDecision(
325325
toolCallId,
326326
options.timeout || STREAM_TIMEOUT_MS,
@@ -569,7 +569,7 @@ export const subAgentHandlers: Record<string, SSEHandler> = {
569569
return
570570
}
571571

572-
if (requiresConfirmation) {
572+
if (requiresConfirmation && options.promptForToolApproval) {
573573
const decision = await waitForToolDecision(
574574
toolCallId,
575575
options.timeout || STREAM_TIMEOUT_MS,

apps/sim/lib/copilot/orchestrator/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ export interface OrchestratorOptions {
139139
onError?: (error: Error) => void | Promise<void>
140140
abortSignal?: AbortSignal
141141
interactive?: boolean
142+
/**
143+
* When true, tools with `requiresConfirmation` will block until the client
144+
* explicitly approves or rejects. When false (e.g. Mothership chat), those
145+
* tools are auto-executed without waiting for user approval.
146+
* Defaults to false.
147+
*/
148+
promptForToolApproval?: boolean
142149
}
143150

144151
export interface OrchestratorResult {

0 commit comments

Comments
 (0)