Skip to content

Personal AI, On Personal Devices

Python

fix: add pure-Python fallback for think tool when Rust extension unavailable

Jon Saad-Falconb72afe9b00ca
diff --git a/src/openjarvis/tools/think.py b/src/openjarvis/tools/think.py
index 225c888e..3c353ab0 100644
--- a/src/openjarvis/tools/think.py
+++ b/src/openjarvis/tools/think.py
@@ -40,9 +40,13 @@ class ThinkTool(BaseTool):
def execute(self, **params: Any) -> ToolResult:
thought = params.get("thought", "")
- from openjarvis._rust_bridge import get_rust_module
- _rust = get_rust_module()
- content = _rust.ThinkTool().execute(thought)
+ try:
+ from openjarvis._rust_bridge import get_rust_module
+ _rust = get_rust_module()
+ content = _rust.ThinkTool().execute(thought)
+ except (ImportError, ModuleNotFoundError):
+ # Pure-Python fallback when Rust extension isn't built
+ content = thought
return ToolResult(
tool_name="think",
content=content,