@tiens.nguyen/gonext-local-worker 1.0.164 → 1.0.167
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 +33 -4
- package/package.json +1 -1
package/gonext_agent_chat.py
CHANGED
|
@@ -2608,11 +2608,40 @@ def run_agent_chat(cfg):
|
|
|
2608
2608
|
# Normalize code-block delimiters so smolagents' <code>…</code> parser
|
|
2609
2609
|
# matches even when the model wrote "<code >" / a markdown fence. Without
|
|
2610
2610
|
# this, tag-whitespace variants fail EVERY step → "Reached max steps".
|
|
2611
|
+
# GATED on real tool-call intent: a finished PROSE answer often contains
|
|
2612
|
+
# markdown fences (e.g. a ```java snippet) — blindly converting those to
|
|
2613
|
+
# <code> made smolagents EXECUTE the snippet as python → SyntaxError,
|
|
2614
|
+
# a wasted step, and a worse fallback answer (seen live). If there is no
|
|
2615
|
+
# executable intent at all and the prose reads like a final answer, wrap
|
|
2616
|
+
# it in final_answer() so the run finishes cleanly with the model's text.
|
|
2611
2617
|
if isinstance(content, str) and content:
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2618
|
+
has_code_tag = re.search(r"<code[\s>]", content, re.I) is not None
|
|
2619
|
+
fence_bodies = re.findall(r"```[a-zA-Z0-9_+-]*\n?([\s\S]*?)```", content)
|
|
2620
|
+
_tool_call_re = (
|
|
2621
|
+
r"\b(final_answer|download_file|unzip_file|list_dir|read_text_file|"
|
|
2622
|
+
r"rag_index|rag_add|rag_search|web_search|fetch_url|http_request|"
|
|
2623
|
+
r"calculate|get_current_datetime|create_pdf|extract_text_from_pdf|"
|
|
2624
|
+
r"send_email)\s*\("
|
|
2625
|
+
)
|
|
2626
|
+
fence_is_toolcall = any(re.search(_tool_call_re, b) for b in fence_bodies)
|
|
2627
|
+
if has_code_tag or fence_is_toolcall:
|
|
2628
|
+
normalized = _normalize_code_tags(content)
|
|
2629
|
+
if normalized != content:
|
|
2630
|
+
_log("normalized code-block tags (<code >/fence → <code>)")
|
|
2631
|
+
msg.content = normalized
|
|
2632
|
+
else:
|
|
2633
|
+
stripped = content.strip()
|
|
2634
|
+
looks_final = len(stripped) >= 400 or re.search(
|
|
2635
|
+
r"(^|\n)#{1,4}\s|\n\d+\.\s|\n[-*]\s|\|.+\|", stripped
|
|
2636
|
+
) is not None
|
|
2637
|
+
if stripped and looks_final:
|
|
2638
|
+
_log(
|
|
2639
|
+
f"prose-only turn ({len(stripped)} chars, no tool call) "
|
|
2640
|
+
"→ auto-wrapping as final_answer"
|
|
2641
|
+
)
|
|
2642
|
+
msg.content = (
|
|
2643
|
+
stripped + "\n<code>\nfinal_answer(" + repr(stripped) + ")\n</code>"
|
|
2644
|
+
)
|
|
2616
2645
|
except Exception as e: # noqa: BLE001
|
|
2617
2646
|
_log(f"content-normalize error: {e}")
|
|
2618
2647
|
return msg
|
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.167",
|
|
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",
|