Skip to content

Commit efef91e

Browse files
authored
improvement(copilot): fast mode, subagent tool responses and allow preferences (#2955)
* Improvements * Fix actions mapping * Remove console logs
1 parent 64efeaa commit efef91e

File tree

3 files changed

+52
-9
lines changed
  • apps/sim

3 files changed

+52
-9
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,10 +1425,7 @@ function RunSkipButtons({
14251425
setIsProcessing(true)
14261426
setButtonsHidden(true)
14271427
try {
1428-
// Add to auto-allowed list - this also executes all pending integration tools of this type
14291428
await addAutoAllowedTool(toolCall.name)
1430-
// For client tools with interrupts (not integration tools), we still need to call handleRun
1431-
// since executeIntegrationTool only works for server-side tools
14321429
if (!isIntegrationTool(toolCall.name)) {
14331430
await handleRun(toolCall, setToolCallState, onStateChange, editedParams)
14341431
}
@@ -1526,7 +1523,11 @@ export function ToolCall({
15261523
toolCall.name === 'user_memory' ||
15271524
toolCall.name === 'edit_respond' ||
15281525
toolCall.name === 'debug_respond' ||
1529-
toolCall.name === 'plan_respond'
1526+
toolCall.name === 'plan_respond' ||
1527+
toolCall.name === 'research_respond' ||
1528+
toolCall.name === 'info_respond' ||
1529+
toolCall.name === 'deploy_respond' ||
1530+
toolCall.name === 'superagent_respond'
15301531
)
15311532
return null
15321533

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/constants.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,20 @@ export interface SlashCommand {
209209
export const TOP_LEVEL_COMMANDS: readonly SlashCommand[] = [
210210
{ id: 'fast', label: 'Fast' },
211211
{ id: 'research', label: 'Research' },
212-
{ id: 'superagent', label: 'Actions' },
212+
{ id: 'actions', label: 'Actions' },
213213
] as const
214214

215+
/**
216+
* Maps UI command IDs to API command IDs.
217+
* Some commands have different IDs for display vs API (e.g., "actions" -> "superagent")
218+
*/
219+
export function getApiCommandId(uiCommandId: string): string {
220+
const commandMapping: Record<string, string> = {
221+
actions: 'superagent',
222+
}
223+
return commandMapping[uiCommandId] || uiCommandId
224+
}
225+
215226
export const WEB_COMMANDS: readonly SlashCommand[] = [
216227
{ id: 'search', label: 'Search' },
217228
{ id: 'read', label: 'Read' },

apps/sim/stores/panel/copilot/store.ts

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,24 @@ const subAgentSSEHandlers: Record<string, SSEHandler> = {
21162116
})
21172117
})
21182118
}
2119+
} else {
2120+
// Check if this is an integration tool (server-side) that should be auto-executed
2121+
const isIntegrationTool = !CLASS_TOOL_METADATA[name]
2122+
if (isIntegrationTool && isSubAgentAutoAllowed) {
2123+
logger.info('[SubAgent] Auto-executing integration tool (auto-allowed)', {
2124+
id,
2125+
name,
2126+
})
2127+
// Execute integration tool via the store method
2128+
const { executeIntegrationTool } = get()
2129+
executeIntegrationTool(id).catch((err) => {
2130+
logger.error('[SubAgent] Integration tool auto-execution failed', {
2131+
id,
2132+
name,
2133+
error: err?.message || err,
2134+
})
2135+
})
2136+
}
21192137
}
21202138
}
21212139
} catch (e: any) {
@@ -2797,9 +2815,14 @@ export const useCopilotStore = create<CopilotStore>()(
27972815
mode === 'ask' ? 'ask' : mode === 'plan' ? 'plan' : 'agent'
27982816

27992817
// Extract slash commands from contexts (lowercase) and filter them out from contexts
2818+
// Map UI command IDs to API command IDs (e.g., "actions" -> "superagent")
2819+
const uiToApiCommandMap: Record<string, string> = { actions: 'superagent' }
28002820
const commands = contexts
28012821
?.filter((c) => c.kind === 'slash_command' && 'command' in c)
2802-
.map((c) => (c as any).command.toLowerCase()) as string[] | undefined
2822+
.map((c) => {
2823+
const uiCommand = (c as any).command.toLowerCase()
2824+
return uiToApiCommandMap[uiCommand] || uiCommand
2825+
}) as string[] | undefined
28032826
const filteredContexts = contexts?.filter((c) => c.kind !== 'slash_command')
28042827

28052828
const result = await sendStreamingMessage({
@@ -3923,11 +3946,16 @@ export const useCopilotStore = create<CopilotStore>()(
39233946

39243947
loadAutoAllowedTools: async () => {
39253948
try {
3949+
logger.info('[AutoAllowedTools] Loading from API...')
39263950
const res = await fetch('/api/copilot/auto-allowed-tools')
3951+
logger.info('[AutoAllowedTools] Load response', { status: res.status, ok: res.ok })
39273952
if (res.ok) {
39283953
const data = await res.json()
3929-
set({ autoAllowedTools: data.autoAllowedTools || [] })
3930-
logger.info('[AutoAllowedTools] Loaded', { tools: data.autoAllowedTools })
3954+
const tools = data.autoAllowedTools || []
3955+
set({ autoAllowedTools: tools })
3956+
logger.info('[AutoAllowedTools] Loaded successfully', { count: tools.length, tools })
3957+
} else {
3958+
logger.warn('[AutoAllowedTools] Load failed with status', { status: res.status })
39313959
}
39323960
} catch (err) {
39333961
logger.error('[AutoAllowedTools] Failed to load', { error: err })
@@ -3936,15 +3964,18 @@ export const useCopilotStore = create<CopilotStore>()(
39363964

39373965
addAutoAllowedTool: async (toolId: string) => {
39383966
try {
3967+
logger.info('[AutoAllowedTools] Adding tool...', { toolId })
39393968
const res = await fetch('/api/copilot/auto-allowed-tools', {
39403969
method: 'POST',
39413970
headers: { 'Content-Type': 'application/json' },
39423971
body: JSON.stringify({ toolId }),
39433972
})
3973+
logger.info('[AutoAllowedTools] API response', { toolId, status: res.status, ok: res.ok })
39443974
if (res.ok) {
39453975
const data = await res.json()
3976+
logger.info('[AutoAllowedTools] API returned', { toolId, tools: data.autoAllowedTools })
39463977
set({ autoAllowedTools: data.autoAllowedTools || [] })
3947-
logger.info('[AutoAllowedTools] Added tool', { toolId })
3978+
logger.info('[AutoAllowedTools] Added tool to store', { toolId })
39483979

39493980
// Auto-execute all pending tools of the same type
39503981
const { toolCallsById, executeIntegrationTool } = get()

0 commit comments

Comments
 (0)