@tiens.nguyen/gonext-local-worker 1.0.123 → 1.0.124

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.
@@ -904,20 +904,33 @@ def run_agent_chat(cfg):
904
904
  raw_coding_base = (cfg.get("codingBaseURL") or "").strip()
905
905
  raw_coding_model = (cfg.get("codingModelId") or "").strip()
906
906
  if raw_coding_base:
907
- # A dedicated coding server is configured. If no model name was given,
908
- # ask the server which model it serves (mlx_lm.server otherwise tries to
909
- # download a mismatched name from HF and 404s).
910
- detected = raw_coding_model or _detect_model_id(raw_coding_base, agent_api_key)
911
- if detected:
912
- coding_base_url = raw_coding_base
913
- coding_model_id = detected
914
- else:
907
+ same_server = raw_coding_base.rstrip("/") == (agent_base_url or "").rstrip("/")
908
+ if same_server and not raw_coding_model:
909
+ # The coding URL points at the SAME server as the chat model. Do NOT
910
+ # auto-detect: /v1/models can list several cached models and return a
911
+ # SMALLER one first (e.g. a 3B), silently downgrading the agent's reasoning.
912
+ # Reuse the chat model id directly — it's the model actually loaded here.
915
913
  _log(
916
- f"coding model id unresolved for {raw_coding_base!r}; "
917
- "falling back to chat model"
914
+ f"coding base == chat base ({raw_coding_base}); "
915
+ f"reusing chat model {agent_model_id!r} (skipping auto-detect)"
918
916
  )
919
917
  coding_base_url = agent_base_url
920
918
  coding_model_id = agent_model_id
919
+ else:
920
+ # A DIFFERENT dedicated coding server. If no model name was given, ask the
921
+ # server which model it serves (mlx_lm.server otherwise tries to download a
922
+ # mismatched name from HF and 404s).
923
+ detected = raw_coding_model or _detect_model_id(raw_coding_base, agent_api_key)
924
+ if detected:
925
+ coding_base_url = raw_coding_base
926
+ coding_model_id = detected
927
+ else:
928
+ _log(
929
+ f"coding model id unresolved for {raw_coding_base!r}; "
930
+ "falling back to chat model"
931
+ )
932
+ coding_base_url = agent_base_url
933
+ coding_model_id = agent_model_id
921
934
  else:
922
935
  coding_base_url = agent_base_url
923
936
  coding_model_id = agent_model_id
@@ -1187,15 +1200,13 @@ def run_agent_chat(cfg):
1187
1200
  "\n"
1188
1201
  "http_request RETURN FORMAT: 'HTTP 200\\n{body}' — first line is 'HTTP <code>', body follows.\n"
1189
1202
  "\n"
1190
- "BASIC AUTH — ALWAYS use username= and password=, NEVER construct headers manually:\n"
1191
- " response = http_request('GET', 'https://api.example.com/data',\n"
1192
- " username='alice@example.com', password='secret123')\n"
1193
- " final_answer(response)\n"
1194
- "The function handles base64 encoding automatically. NEVER write 'Basic ' + anything.\n"
1195
- "\n"
1196
- "BEARER TOKEN use headers:\n"
1197
- " response = http_request('GET', url, headers='{\"Authorization\": \"Bearer TOKEN\"}')\n"
1198
- " final_answer(response)\n"
1203
+ "AUTH — ONLY when the TASK itself provides credentials or a token. If it does "
1204
+ "NOT, call http_request with NO username/password/headers. NEVER invent or copy "
1205
+ "the placeholder values below.\n"
1206
+ " BASIC AUTH — pass username= and password= (auto base64; never build a 'Basic ' header):\n"
1207
+ " http_request('GET', url, username=<username from the task>, password=<password from the task>)\n"
1208
+ " BEARER TOKEN — pass it in headers:\n"
1209
+ " http_request('GET', url, headers='{\"Authorization\": \"Bearer <token from the task>\"}')\n"
1199
1210
  "\n"
1200
1211
  "CHOOSING A TOOL (match the TASK, not these examples):\n"
1201
1212
  "- ONLY a date/time question (e.g. 'what is the date today') -> get_current_datetime().\n"
@@ -1203,6 +1214,8 @@ def run_agent_chat(cfg):
1203
1214
  "knowledge -> web_search(query).\n"
1204
1215
  "- 'read this page' / 'open this link' / 'what does <URL> say' -> fetch_url(url).\n"
1205
1216
  "- any arithmetic, percentage, or 'how much is' math -> calculate(expression).\n"
1217
+ "- a live/current NUMBER with no URL given (price, exchange rate, weather, score, "
1218
+ "stock/crypto) -> web_search(query). Do NOT guess an API URL for these.\n"
1206
1219
  "- 'create/make/generate/export a PDF' of some text/data -> create_pdf(text, title).\n"
1207
1220
  + _pdf_read_choose_line + _email_choose_line +
1208
1221
  "- A specific known API/URL was given -> http_request().\n"
@@ -1212,8 +1225,11 @@ def run_agent_chat(cfg):
1212
1225
  "If nothing works, call final_answer explaining what you need — do NOT make up an answer.\n"
1213
1226
  "- Only report what a tool ACTUALLY returned. Never fabricate a response, body, or status code.\n"
1214
1227
  "- Pass an http_request response DIRECTLY to final_answer — do NOT split, parse, or index it.\n"
1215
- "- If a response starts with 'HTTP 2' it SUCCEEDED call final_answer immediately.\n"
1216
- "- If a tool returns 'Error:' or HTTP 4xx/5xx, try a DIFFERENT approach, not the same URL.\n"
1228
+ "- When a call's result is UNCERTAIN (any network call), do NOT call final_answer "
1229
+ "in the SAME block. Call the tool alone, READ the Observation, THEN answer next step.\n"
1230
+ "- If a response starts with 'HTTP 2' it SUCCEEDED — answer with it next step.\n"
1231
+ "- NEVER pass an 'Error:' / HTTP 4xx / 5xx result to final_answer. On an error, try a "
1232
+ "DIFFERENT approach next step (e.g. web_search); only give up after a few tries.\n"
1217
1233
  "- Do NOT put final_answer outside the code block.\n\n"
1218
1234
  )
1219
1235
  # Lead with the TASK so the weak model anchors on what's actually being asked —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.123",
3
+ "version": "1.0.124",
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",