diff --git a/src/components/ChatInterface.tsx b/src/components/ChatInterface.tsx index e1bf3eb..caf19ec 100644 --- a/src/components/ChatInterface.tsx +++ b/src/components/ChatInterface.tsx @@ -16,7 +16,7 @@ export function ChatInterface() { getAgentLoopState, } = useConversation(); - const { currentProvider } = useInference(); + const { provider: currentProvider, isAuthenticated } = useInference(); const [isLoading, setIsLoading] = useState(false); const messagesEndRef = useRef(null); diff --git a/src/hooks/useAgentLoop.ts b/src/hooks/useAgentLoop.ts index 53eac38..78e9ab6 100644 --- a/src/hooks/useAgentLoop.ts +++ b/src/hooks/useAgentLoop.ts @@ -126,7 +126,7 @@ const DEFAULT_CONFIG: AgentLoopConfig = { export function useAgentLoop(config: Partial = {}): UseAgentLoopReturn { const finalConfig = { ...DEFAULT_CONFIG, ...config }; - const { currentProvider } = useInference(); + const { provider: currentProvider, isAuthenticated } = useInference(); const { getAllTools, callTool: callMCPTool, connections } = useMCP(); // Track running loops @@ -255,7 +255,7 @@ export function useAgentLoop(config: Partial = {}): UseAgentLoo conversation: Conversation, onUpdate: (conversation: Conversation) => void ) => { - if (!currentProvider?.isAuthenticated) { + if (!isAuthenticated || !currentProvider) { throw new Error('No authenticated inference provider available'); } @@ -397,7 +397,7 @@ export function useAgentLoop(config: Partial = {}): UseAgentLoo } finally { loopStates.current.delete(conversationId); } - }, [currentProvider, finalConfig, toInferenceMessages, fromInferenceResponse, getAllTools, executeTool]); + }, [isAuthenticated, currentProvider, finalConfig, toInferenceMessages, fromInferenceResponse, getAllTools, executeTool]); const stopLoop = useCallback((conversationId: string) => { const loopState = loopStates.current.get(conversationId);