From 4b4dc51336bba3569cc7da5f9f8de28aea7e88e8 Mon Sep 17 00:00:00 2001 From: Jiaqing Liang Date: Mon, 23 Mar 2026 11:46:10 +0800 Subject: [PATCH] fix: tool_use regex negative lookahead to prevent cross-tag matching; tgapp relative path resolve --- frontends/tgapp.py | 2 ++ llmcore.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontends/tgapp.py b/frontends/tgapp.py index 4198a9d..48ec5d4 100644 --- a/frontends/tgapp.py +++ b/frontends/tgapp.py @@ -1,5 +1,6 @@ import os, sys, re, threading, asyncio, queue as Q, socket, time sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +_TEMP_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'temp') from agentmain import GeneraticAgent try: from telegram import Update @@ -65,6 +66,7 @@ async def _stream(dq, msg): if done: files = re.findall(r'\[FILE:([^\]]+)\]', show[-1000:]) for fpath in files: + if not os.path.isabs(fpath): fpath = os.path.join(_TEMP_DIR, fpath) if os.path.exists(fpath): if fpath.lower().endswith(('.png','.jpg','.jpeg','.gif','.webp')): try: await msg.reply_photo(open(fpath,'rb')) diff --git a/llmcore.py b/llmcore.py index 03ee440..a22fbed 100644 --- a/llmcore.py +++ b/llmcore.py @@ -717,7 +717,7 @@ class ToolClient: remaining_text = re.sub(think_pattern, "", remaining_text, flags=re.DOTALL) tool_calls = []; json_strs = []; errors = [] - tool_pattern = r"(.{15,}?)" + tool_pattern = r"((?:(?!).){15,}?)" tool_all = re.findall(tool_pattern, remaining_text, re.DOTALL) if tool_all: