mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-22 21:38:05 -05:00
Autoload
This commit is contained in:
@@ -105,10 +105,10 @@ export function useCopilotInitialization(props: UseCopilotInitializationProps) {
|
||||
isSendingMessage,
|
||||
])
|
||||
|
||||
/** Load auto-allowed tools once on mount */
|
||||
/** Load auto-allowed tools once on mount - runs immediately, independent of workflow */
|
||||
const hasLoadedAutoAllowedToolsRef = useRef(false)
|
||||
useEffect(() => {
|
||||
if (hasMountedRef.current && !hasLoadedAutoAllowedToolsRef.current) {
|
||||
if (!hasLoadedAutoAllowedToolsRef.current) {
|
||||
hasLoadedAutoAllowedToolsRef.current = true
|
||||
loadAutoAllowedTools().catch((err) => {
|
||||
logger.warn('[Copilot] Failed to load auto-allowed tools', err)
|
||||
|
||||
@@ -1481,7 +1481,10 @@ const sseHandlers: Record<string, SSEHandler> = {
|
||||
// Check if tool is auto-allowed - if so, execute even if it has an interrupt
|
||||
const { autoAllowedTools: classAutoAllowed } = get()
|
||||
const isClassAutoAllowed = name ? classAutoAllowed.includes(name) : false
|
||||
if ((!hasInterrupt || isClassAutoAllowed) && (typeof inst?.execute === 'function' || typeof inst?.handleAccept === 'function')) {
|
||||
if (
|
||||
(!hasInterrupt || isClassAutoAllowed) &&
|
||||
(typeof inst?.execute === 'function' || typeof inst?.handleAccept === 'function')
|
||||
) {
|
||||
if (isClassAutoAllowed && hasInterrupt) {
|
||||
logger.info('[toolCallsById] Auto-executing class tool with interrupt (auto-allowed)', {
|
||||
id,
|
||||
@@ -2719,6 +2722,9 @@ export const useCopilotStore = create<CopilotStore>()(
|
||||
// Load sensitive credential IDs for masking before streaming starts
|
||||
await get().loadSensitiveCredentialIds()
|
||||
|
||||
// Ensure auto-allowed tools are loaded before tool calls arrive
|
||||
await get().loadAutoAllowedTools()
|
||||
|
||||
let newMessages: CopilotMessage[]
|
||||
if (revertState) {
|
||||
const currentMessages = get().messages
|
||||
@@ -3782,10 +3788,7 @@ export const useCopilotStore = create<CopilotStore>()(
|
||||
const { id, name, params } = toolCall
|
||||
|
||||
// Guard against double execution - skip if already executing or in terminal state
|
||||
if (
|
||||
toolCall.state === ClientToolCallState.executing ||
|
||||
isTerminalState(toolCall.state)
|
||||
) {
|
||||
if (toolCall.state === ClientToolCallState.executing || isTerminalState(toolCall.state)) {
|
||||
logger.info('[executeIntegrationTool] Skipping - already executing or terminal', {
|
||||
id,
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user