fix: Lookup errors for contextvars used in ToolManager

This commit is contained in:
Yeuoly 2024-12-02 21:25:47 +08:00
parent ad899844a1
commit 77a62f33b3
No known key found for this signature in database
GPG Key ID: A66E7E320FB19F61

View File

@ -100,6 +100,13 @@ class ToolManager:
"""
get the plugin provider
"""
# check if context is set
try:
contexts.plugin_tool_providers.get()
except LookupError:
contexts.plugin_tool_providers.set({})
contexts.plugin_tool_providers_lock.set(Lock())
with contexts.plugin_tool_providers_lock.get():
plugin_tool_providers = contexts.plugin_tool_providers.get()
if provider in plugin_tool_providers: