mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
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:
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user