@tiens.nguyen/gonext-local-worker 1.0.138 → 1.0.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1526,14 +1526,15 @@ async function runAgentChatJob(job) {
1526
1526
  emailFrom: payload?.emailFrom ?? "",
1527
1527
  emailAllowList: payload?.emailAllowList ?? "",
1528
1528
  });
1529
- // 10 min max for an agent run: 5 ReAct steps on a 14B with a cold prompt cache —
1530
- // or a remote Ollama box cold-loading a big model — can exceed the old caps. Must
1531
- // stay BELOW the web client's hard WS deadline (660s) so our clean timeout error
1532
- // reaches the user instead of a generic WS timeout. On expiry the python child is
1533
- // SIGKILLed, which also shows up as a BrokenPipeError in the model server log
1534
- // (expected). Liveness during long model calls comes from the python heartbeat
1535
- // (a keepalive step chunk every 45s), not from this cap.
1536
- const timeoutMs = 600_000;
1529
+ // 30 min max for an agent run: multi-step ReAct on a 14B/31B with a cold prompt
1530
+ // cache — or a remote Ollama box on slow GPU cold-loading a big model — can run
1531
+ // for many minutes per step. Must stay BELOW the web client's hard WS deadline
1532
+ // (1_860_000 ms) so our clean timeout error reaches the user instead of a generic
1533
+ // WS timeout. On expiry the python child is SIGKILLed, which also shows up as a
1534
+ // BrokenPipeError in the model server log (expected). Liveness during long model
1535
+ // calls comes from the python heartbeat (a keepalive step chunk every 45s), not
1536
+ // from this cap.
1537
+ const timeoutMs = 1_800_000;
1537
1538
 
1538
1539
  let inThink = false;
1539
1540
  let finalText = "";
@@ -398,6 +398,24 @@ def _list_model_ids(base_url, api_key=""):
398
398
  if isinstance(d, dict) and isinstance(d.get("id"), str) and d["id"].strip()]
399
399
 
400
400
 
401
+ def _is_ollama_server(base_url):
402
+ """True if the OpenAI-compatible base URL is an Ollama server.
403
+
404
+ Ollama's root path answers GET / with the plain-text banner "Ollama is
405
+ running". Used to gate Ollama-only request params (reasoning_effort) that an
406
+ MLX server might reject.
407
+ """
408
+ root = re.sub(r"/v1/?$", "", (base_url or "").rstrip("/"))
409
+ if not root:
410
+ return False
411
+ req = urllib.request.Request(root, headers={"User-Agent": "gonext-agent/1.0"})
412
+ try:
413
+ with urllib.request.urlopen(req, timeout=6, context=_ssl_context()) as resp:
414
+ return b"ollama" in resp.read(200).lower()
415
+ except Exception: # noqa: BLE001
416
+ return False
417
+
418
+
401
419
  def _detect_model_id(base_url, api_key=""):
402
420
  """Ask an OpenAI-compatible server which model it serves (first reported id).
403
421
 
@@ -1948,16 +1966,27 @@ def run_agent_chat(cfg):
1948
1966
  return ChatMessage(role=MessageRole.ASSISTANT, content=text)
1949
1967
 
1950
1968
  try:
1969
+ # Ollama's OpenAI-compat endpoint ignores Qwen3's /no_think soft-switch (its
1970
+ # template forces thinking mode; "think": false is also ignored there) but DOES
1971
+ # honor reasoning_effort="none". Thinking burned ~430 of 487 output tokens in
1972
+ # the live test — minutes per step on a slow GPU — so disable it explicitly.
1973
+ # Sniffed per-server because MLX might reject the unknown param.
1974
+ extra_model_kwargs = {}
1975
+ if _is_ollama_server(coding_base_url):
1976
+ _log("coding server is Ollama → sending reasoning_effort='none' to disable thinking")
1977
+ extra_model_kwargs["reasoning_effort"] = "none"
1951
1978
  model = _LoggingModel(
1952
1979
  model_id=coding_model_id,
1953
1980
  api_base=coding_base_url,
1954
1981
  api_key=agent_api_key,
1955
- # Cap each HTTP attempt at 240s so one hung request (remote server
1956
- # cold-loading a big model) fails into OUR retry loop instead of eating
1957
- # the whole worker budget; by the retry the model is usually loaded.
1982
+ # Cap each HTTP attempt at 600s so a genuinely slow single call (a
1983
+ # remote M6000/Vulkan box doing a cold ~4-5min prompt-eval) can finish
1984
+ # on the first try, while a truly hung request still fails into OUR
1985
+ # retry loop rather than eating the whole 30min worker budget.
1958
1986
  # max_retries=0: the openai client's own silent retries would otherwise
1959
1987
  # stack multiplicatively with ours (3 × 3 attempts).
1960
- client_kwargs={"timeout": 240.0, "max_retries": 0},
1988
+ client_kwargs={"timeout": 600.0, "max_retries": 0},
1989
+ **extra_model_kwargs,
1961
1990
  )
1962
1991
  agent_tools = [http_request, web_search, fetch_url, calculate,
1963
1992
  get_current_datetime, create_pdf]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.138",
3
+ "version": "1.0.140",
4
4
  "description": "Polls GoNext cloud API for async local LLM jobs and runs them against Ollama/OpenAI-compatible servers on this Mac",
5
5
  "type": "module",
6
6
  "license": "MIT",