fix(mothership): add promptForToolApproval to prevent tool hang in mothership chat (#3616)

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

Co-authored-by: Theodore Li <theo@sim.ai>
This commit is contained in:
Theodore Li
2026-03-16 17:44:29 -07:00
committed by GitHub
parent 36e502a068
commit c090c821be
4 changed files with 12 additions and 2 deletions

View File

@@ -302,6 +302,7 @@ export async function POST(req: NextRequest) {
goRoute: '/api/copilot',
autoExecuteTools: true,
interactive: true,
promptForToolApproval: true,
},
})
@@ -315,6 +316,7 @@ export async function POST(req: NextRequest) {
goRoute: '/api/copilot',
autoExecuteTools: true,
interactive: true,
promptForToolApproval: true,
})
const responseData = {

View File

@@ -262,6 +262,7 @@ export async function POST(req: NextRequest) {
goRoute: '/api/mothership',
autoExecuteTools: true,
interactive: true,
promptForToolApproval: false,
onComplete: async (result: OrchestratorResult) => {
if (!actualChatId) return

View File

@@ -320,7 +320,7 @@ export const sseHandlers: Record<string, SSEHandler> = {
return
}
if (requiresConfirmation) {
if (requiresConfirmation && options.promptForToolApproval) {
const decision = await waitForToolDecision(
toolCallId,
options.timeout || STREAM_TIMEOUT_MS,
@@ -569,7 +569,7 @@ export const subAgentHandlers: Record<string, SSEHandler> = {
return
}
if (requiresConfirmation) {
if (requiresConfirmation && options.promptForToolApproval) {
const decision = await waitForToolDecision(
toolCallId,
options.timeout || STREAM_TIMEOUT_MS,

View File

@@ -139,6 +139,13 @@ export interface OrchestratorOptions {
onError?: (error: Error) => void | Promise<void>
abortSignal?: AbortSignal
interactive?: boolean
/**
* When true, tools with `requiresConfirmation` will block until the client
* explicitly approves or rejects. When false (e.g. Mothership chat), those
* tools are auto-executed without waiting for user approval.
* Defaults to false.
*/
promptForToolApproval?: boolean
}
export interface OrchestratorResult {