Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

use llm.ainvoke non-blocking async call

Nick Sweetingfd4d7ea07a5b
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 443542ea6..032988824 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -1067,7 +1067,7 @@ class Agent(Generic[Context]):
if self.tool_calling_method == 'raw':
self._log_llm_call_info(input_messages, self.tool_calling_method)
try:
- output = self.llm.invoke(input_messages)
+ output = await self.llm.ainvoke(input_messages)
response = {'raw': output, 'parsed': None}
except Exception as e:
self.logger.error(f'Failed to invoke model: {str(e)}')