@tiens.nguyen/gonext-local-worker 1.0.58 → 1.0.60
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.
- package/gonext_agent_chat.py +26 -4
- package/package.json +1 -1
package/gonext_agent_chat.py
CHANGED
|
@@ -39,7 +39,7 @@ def _ssl_context():
|
|
|
39
39
|
return ssl.create_default_context()
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
def _http_request_impl(method, url, headers=None, body=None, timeout=
|
|
42
|
+
def _http_request_impl(method, url, headers=None, body=None, timeout=25):
|
|
43
43
|
req = urllib.request.Request(url, method=method.upper())
|
|
44
44
|
if headers:
|
|
45
45
|
for k, v in headers.items():
|
|
@@ -131,6 +131,10 @@ def run_agent_chat(cfg):
|
|
|
131
131
|
_log(f"start model={agent_model_id!r} base={agent_base_url!r} maxSteps={max_steps}")
|
|
132
132
|
|
|
133
133
|
# Build task from the last user message; prepend prior assistant turns as context.
|
|
134
|
+
# Strip <think>...</think> blocks from assistant messages — those are internal
|
|
135
|
+
# reasoning steps and must not be fed back to the agent as conversation context.
|
|
136
|
+
_THINK_RE = re.compile(r"<think>.*?</think>", re.DOTALL | re.IGNORECASE)
|
|
137
|
+
|
|
134
138
|
task_text = ""
|
|
135
139
|
context_lines = []
|
|
136
140
|
for m in messages:
|
|
@@ -139,7 +143,9 @@ def run_agent_chat(cfg):
|
|
|
139
143
|
if role == "user":
|
|
140
144
|
task_text = content
|
|
141
145
|
elif role == "assistant":
|
|
142
|
-
|
|
146
|
+
clean = _THINK_RE.sub("", content).strip()
|
|
147
|
+
if clean:
|
|
148
|
+
context_lines.append(f"Assistant previously said: {clean[:500]}")
|
|
143
149
|
|
|
144
150
|
if not task_text:
|
|
145
151
|
_emit({"type": "final", "text": "[No user message found in history]"})
|
|
@@ -186,6 +192,22 @@ def run_agent_chat(cfg):
|
|
|
186
192
|
return result
|
|
187
193
|
|
|
188
194
|
def step_callback(step_log):
|
|
195
|
+
step_num = getattr(step_log, "step_number", "?")
|
|
196
|
+
|
|
197
|
+
# Log what was sent to the model (last message in the conversation).
|
|
198
|
+
model_input = getattr(step_log, "model_input_messages", None)
|
|
199
|
+
if model_input:
|
|
200
|
+
last = model_input[-1]
|
|
201
|
+
raw = getattr(last, "content", "")
|
|
202
|
+
if isinstance(raw, list):
|
|
203
|
+
raw = " ".join(p.get("text", "") for p in raw if isinstance(p, dict))
|
|
204
|
+
_log(f"step {step_num} → model input (tail): {str(raw)[:400]}")
|
|
205
|
+
|
|
206
|
+
# Log what the model generated (the Python code block).
|
|
207
|
+
model_output = getattr(step_log, "model_output", None)
|
|
208
|
+
if model_output:
|
|
209
|
+
_log(f"step {step_num} ← model output: {str(model_output)[:400]}")
|
|
210
|
+
|
|
189
211
|
try:
|
|
190
212
|
text = _summarise_step(step_log)
|
|
191
213
|
except Exception as e: # noqa: BLE001
|
|
@@ -193,9 +215,9 @@ def run_agent_chat(cfg):
|
|
|
193
215
|
# Skip emitting if there's nothing beyond the tool name — the tool already
|
|
194
216
|
# emitted its own step event with the actual response above.
|
|
195
217
|
if not text or text.rstrip().endswith("| →"):
|
|
196
|
-
_log(f"step (empty obs, skipped)
|
|
218
|
+
_log(f"step {step_num} (empty obs, skipped)")
|
|
197
219
|
return
|
|
198
|
-
_log(f"step: {text[:200]}")
|
|
220
|
+
_log(f"step {step_num}: {text[:200]}")
|
|
199
221
|
_emit({"type": "step", "text": text})
|
|
200
222
|
|
|
201
223
|
try:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiens.nguyen/gonext-local-worker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
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",
|