@tiens.nguyen/gonext-local-worker 1.0.59 → 1.0.61

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.
@@ -32,18 +32,20 @@ _REAL_STDOUT = sys.stdout
32
32
 
33
33
  def _ssl_context():
34
34
  import ssl
35
- try:
36
- import certifi
37
- return ssl.create_default_context(cafile=certifi.where())
38
- except ImportError:
39
- return ssl.create_default_context()
35
+ # Disable cert verification — this agent runs locally against dev tunnels
36
+ # (gorok, ngrok) whose certs may not chain correctly in Python's SSL store.
37
+ ctx = ssl.create_default_context()
38
+ ctx.check_hostname = False
39
+ ctx.verify_mode = ssl.CERT_NONE
40
+ return ctx
40
41
 
41
42
 
42
43
  def _http_request_impl(method, url, headers=None, body=None, timeout=25):
43
- req = urllib.request.Request(url, method=method.upper())
44
+ # Merge caller headers on top of sensible defaults.
45
+ merged = {"User-Agent": "gonext-agent/1.0", "Accept": "*/*"}
44
46
  if headers:
45
- for k, v in headers.items():
46
- req.add_header(k, v)
47
+ merged.update(headers)
48
+ req = urllib.request.Request(url, method=method.upper(), headers=merged)
47
49
  data = body.encode() if isinstance(body, str) and body else (body or None)
48
50
  try:
49
51
  ctx = _ssl_context()
@@ -131,6 +133,10 @@ def run_agent_chat(cfg):
131
133
  _log(f"start model={agent_model_id!r} base={agent_base_url!r} maxSteps={max_steps}")
132
134
 
133
135
  # Build task from the last user message; prepend prior assistant turns as context.
136
+ # Strip <think>...</think> blocks from assistant messages — those are internal
137
+ # reasoning steps and must not be fed back to the agent as conversation context.
138
+ _THINK_RE = re.compile(r"<think>.*?</think>", re.DOTALL | re.IGNORECASE)
139
+
134
140
  task_text = ""
135
141
  context_lines = []
136
142
  for m in messages:
@@ -139,7 +145,9 @@ def run_agent_chat(cfg):
139
145
  if role == "user":
140
146
  task_text = content
141
147
  elif role == "assistant":
142
- context_lines.append(f"Assistant previously said: {content[:500]}")
148
+ clean = _THINK_RE.sub("", content).strip()
149
+ if clean:
150
+ context_lines.append(f"Assistant previously said: {clean[:500]}")
143
151
 
144
152
  if not task_text:
145
153
  _emit({"type": "final", "text": "[No user message found in history]"})
@@ -186,6 +194,22 @@ def run_agent_chat(cfg):
186
194
  return result
187
195
 
188
196
  def step_callback(step_log):
197
+ step_num = getattr(step_log, "step_number", "?")
198
+
199
+ # Log what was sent to the model (last message in the conversation).
200
+ model_input = getattr(step_log, "model_input_messages", None)
201
+ if model_input:
202
+ last = model_input[-1]
203
+ raw = getattr(last, "content", "")
204
+ if isinstance(raw, list):
205
+ raw = " ".join(p.get("text", "") for p in raw if isinstance(p, dict))
206
+ _log(f"step {step_num} → model input (tail): {str(raw)[:400]}")
207
+
208
+ # Log what the model generated (the Python code block).
209
+ model_output = getattr(step_log, "model_output", None)
210
+ if model_output:
211
+ _log(f"step {step_num} ← model output: {str(model_output)[:400]}")
212
+
189
213
  try:
190
214
  text = _summarise_step(step_log)
191
215
  except Exception as e: # noqa: BLE001
@@ -193,9 +217,9 @@ def run_agent_chat(cfg):
193
217
  # Skip emitting if there's nothing beyond the tool name — the tool already
194
218
  # emitted its own step event with the actual response above.
195
219
  if not text or text.rstrip().endswith("| →"):
196
- _log(f"step (empty obs, skipped): {text[:80]}")
220
+ _log(f"step {step_num} (empty obs, skipped)")
197
221
  return
198
- _log(f"step: {text[:200]}")
222
+ _log(f"step {step_num}: {text[:200]}")
199
223
  _emit({"type": "step", "text": text})
200
224
 
201
225
  try:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.59",
3
+ "version": "1.0.61",
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",