@tiens.nguyen/gonext-local-worker 1.0.55 → 1.0.57

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.
@@ -1237,7 +1237,7 @@ async function runAgentChatJob(job) {
1237
1237
  agentApiKey: payload?.agentApiKey ?? "",
1238
1238
  agentModelId: payload?.agentModelId ?? "",
1239
1239
  tools: payload?.tools ?? ["http_request"],
1240
- maxSteps: payload?.maxSteps ?? 10,
1240
+ maxSteps: payload?.maxSteps ?? 5,
1241
1241
  });
1242
1242
  const timeoutMs = 300_000; // 5 min max for an agent run
1243
1243
 
@@ -98,9 +98,11 @@ def _summarise_step(step_log):
98
98
 
99
99
  if observations:
100
100
  obs = str(observations).strip()
101
- # Keep only first line of response body for brevity
102
- first_obs_line = obs.split("\n")[0][:200]
103
- parts.append(f" {first_obs_line}")
101
+ # smolagents prefixes output with "Execution logs:" skip that header line
102
+ # and show the first line of actual content.
103
+ lines = [l for l in obs.splitlines() if l.strip() and l.strip() != "Execution logs:"]
104
+ if lines:
105
+ parts.append(f"→ {lines[0][:200]}")
104
106
 
105
107
  if error:
106
108
  err = str(error)
@@ -124,7 +126,7 @@ def run_agent_chat(cfg):
124
126
  agent_base_url = cfg.get("agentBaseURL") or ""
125
127
  agent_api_key = cfg.get("agentApiKey") or "local"
126
128
  agent_model_id = cfg.get("agentModelId") or ""
127
- max_steps = int(cfg.get("maxSteps") or 10)
129
+ max_steps = int(cfg.get("maxSteps") or 5)
128
130
 
129
131
  _log(f"start model={agent_model_id!r} base={agent_base_url!r} maxSteps={max_steps}")
130
132
 
@@ -146,12 +148,15 @@ def run_agent_chat(cfg):
146
148
  if context_lines:
147
149
  task_text = "\n".join(context_lines) + "\n\nNow answer: " + task_text
148
150
 
149
- # Prepend explicit tool instructions so small models don't try to import
150
- # requests/urllib themselves the http_request function is already available.
151
+ # Prepend explicit tool instructions so small models use http_request correctly
152
+ # and always terminate with final_answer() rather than looping forever.
151
153
  tool_hint = (
152
154
  "You have ONE built-in function: `http_request(method, url, headers='', body='')`. "
153
- "Call it directly — do NOT write `import requests`, `import urllib`, or any import. "
154
- "Example: result = http_request(method='GET', url='https://example.com')\n\n"
155
+ "Do NOT import requests, urllib, or any library — call http_request() directly.\n"
156
+ "When you have the answer, ALWAYS end with `final_answer(your_answer)` — this stops the agent.\n"
157
+ "Example:\n"
158
+ "result = http_request(method='GET', url='https://example.com')\n"
159
+ "final_answer(result)\n\n"
155
160
  )
156
161
  task_with_hint = tool_hint + "Task: " + task_text
157
162
  _log(f"task={task_text[:120]!r}")
@@ -173,6 +178,10 @@ def run_agent_chat(cfg):
173
178
  except Exception: # noqa: BLE001
174
179
  pass
175
180
  result = _http_request_impl(method, url, parsed_headers, body or None)
181
+ # Emit immediately so the thinking area shows the result even when the
182
+ # generated code doesn't print() — _REAL_STDOUT bypasses redirect_stdout.
183
+ status_line = result.split("\n")[0][:150] if result else "no response"
184
+ _emit({"type": "step", "text": f"HTTP {method.upper()} {url} → {status_line}"})
176
185
  _log(f"http_request {method.upper()} {url} → {result[:80]}")
177
186
  return result
178
187
 
@@ -181,6 +190,11 @@ def run_agent_chat(cfg):
181
190
  text = _summarise_step(step_log)
182
191
  except Exception as e: # noqa: BLE001
183
192
  text = f"Step: {e}"
193
+ # Skip emitting if there's nothing beyond the tool name — the tool already
194
+ # emitted its own step event with the actual response above.
195
+ if not text or text.rstrip().endswith("| →"):
196
+ _log(f"step (empty obs, skipped): {text[:80]}")
197
+ return
184
198
  _log(f"step: {text[:200]}")
185
199
  _emit({"type": "step", "text": text})
186
200
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
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",