Personal AI, On Personal Devices
Python
fix: disable Ollama thinking by default, fix token tracking
Jon Saad-Falcon8590bc514067
diff --git a/src/openjarvis/agents/executor.py b/src/openjarvis/agents/executor.pyindex f222befb..4ad52e2a 100644--- a/src/openjarvis/agents/executor.py+++ b/src/openjarvis/agents/executor.py@@ -240,15 +240,10 @@ class AgentExecutor:pass # Fall back to configured model# Construct agent instance (BaseAgent requires engine, model as positional args)- # Append /no_think to suppress Qwen3.5 extended thinking that- # can consume all tokens and produce empty visible output.- sys_prompt = config.get("system_prompt", "") or ""- if sys_prompt and "/no_think" not in sys_prompt:- sys_prompt = sys_prompt.rstrip() + "\n/no_think"agent_instance = agent_cls(engine,model,- system_prompt=sys_prompt or None,+ system_prompt=config.get("system_prompt"),tools=[],)@@ -411,7 +406,11 @@ class AgentExecutor:# Accumulate budget metrics from AgentResult metadataif result:- tokens = result.metadata.get("tokens_used", 0)+ tokens = (+ result.metadata.get("total_tokens")+ or result.metadata.get("tokens_used")+ or 0+ )cost = result.metadata.get("cost", 0.0)budget_kwargs: dict[str, Any] = {"stall_retries": 0}if tokens > 0:diff --git a/src/openjarvis/engine/ollama.py b/src/openjarvis/engine/ollama.pyindex a757293e..c6fcf489 100644--- a/src/openjarvis/engine/ollama.py+++ b/src/openjarvis/engine/ollama.py@@ -75,6 +75,13 @@ class OllamaEngine(InferenceEngine):"num_ctx": kwargs.get("num_ctx", 8192),},}+ # Disable extended thinking by default (Qwen3.5 etc.).+ # When enabled, thinking tokens consume the entire budget and+ # the visible content comes back empty.+ if "think" not in kwargs:+ payload["think"] = False+ elif kwargs["think"] is not None:+ payload["think"] = kwargs["think"]# Pass tools if providedtools = kwargs.get("tools")if tools: