@tiens.nguyen/gonext-local-worker 1.0.74 → 1.0.75

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.
@@ -128,10 +128,12 @@ def _route(task_text: str, base_url: str, api_key: str, model_id: str) -> bool:
128
128
  model=model_id,
129
129
  messages=[
130
130
  {"role": "system", "content": (
131
- "You are a task classifier. Reply with YES or NO only, no punctuation."
131
+ "You are a task classifier. Reply YES or NO only, no punctuation. "
132
+ "Answer NO if the task can be solved with Python stdlib (datetime, math, etc.) "
133
+ "or is just conversation. Answer YES only if it requires calling an EXTERNAL URL or web API."
132
134
  )},
133
135
  {"role": "user", "content": (
134
- f"Does this task require making an HTTP request to a URL or API?\n\n"
136
+ f"Does this task specifically require making an HTTP request to an external URL or web API?\n\n"
135
137
  f"Task: {task_text}\n\nYES or NO:"
136
138
  )},
137
139
  ],
@@ -246,10 +248,17 @@ def run_agent_chat(cfg):
246
248
  "You have ONE built-in function: `http_request(method, url, headers='', body='')`. "
247
249
  "It returns a STRING with the HTTP status and body. "
248
250
  "Call it, then immediately call `final_answer(response)` inside the same code block.\n"
249
- "Do NOT put final_answer outside the code block.\n\n"
251
+ "IMPORTANT RULES:\n"
252
+ "- Python's `datetime` module is available — use it for date/time tasks, no HTTP needed.\n"
253
+ "- If http_request returns an error starting with 'Error:', the URL failed. "
254
+ "Do NOT retry the same URL. Try a DIFFERENT URL or API, or use Python stdlib.\n"
255
+ "- Do NOT put final_answer outside the code block.\n\n"
250
256
  )
251
257
  task_with_hint = tool_hint + "Task: " + task_text
252
258
 
259
+ # Track URLs that have already failed so we don't retry dead endpoints across steps.
260
+ _failed_urls: set = set()
261
+
253
262
  @tool
254
263
  def http_request(method: str, url: str, headers: str = "", body: str = "") -> str:
255
264
  """Perform an HTTP request and return the status code and body preview.
@@ -266,11 +275,25 @@ def run_agent_chat(cfg):
266
275
  parsed_headers = json.loads(headers)
267
276
  except Exception: # noqa: BLE001
268
277
  pass
269
- # Retry once on timeout — gorok tunnels can be flaky on the first attempt.
278
+ url_key = f"{method.upper()}:{url}"
279
+ if url_key in _failed_urls:
280
+ msg = f"Error: {url} already failed — try a different URL or use Python stdlib."
281
+ _emit({"type": "step", "text": f"HTTP {method.upper()} {url} → (skipped, already failed)"})
282
+ _log(f"http_request skipped (already failed): {url_key}")
283
+ return msg
270
284
  result = _http_request_impl(method, url, parsed_headers, body or None)
271
285
  if result.startswith("Error:"):
286
+ # Retry once for flaky connections (e.g. gorok tunnels).
272
287
  _log(f"http_request retry {method.upper()} {url}")
273
288
  result = _http_request_impl(method, url, parsed_headers, body or None)
289
+ if result.startswith("Error:"):
290
+ # Both attempts failed — mark URL as dead so model tries something else.
291
+ _failed_urls.add(url_key)
292
+ result = (
293
+ f"{result}\n"
294
+ "Note: This URL failed twice. Do NOT retry it. "
295
+ "Try a DIFFERENT URL or use Python's datetime/math/etc. module instead."
296
+ )
274
297
  status_line = result.split("\n")[0][:150] if result else "no response"
275
298
  _emit({"type": "step", "text": f"HTTP {method.upper()} {url} → {status_line}"})
276
299
  _log(f"http_request {method.upper()} {url} → {result[:80]}")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.74",
3
+ "version": "1.0.75",
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",