From b0d4563ae80ad5c82e7a1ab56c5e50f607db130e Mon Sep 17 00:00:00 2001 From: Liang Jiaqing Date: Thu, 2 Apr 2026 21:16:45 +0800 Subject: [PATCH] Refine llmcore debug and tool parsing --- llmcore.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llmcore.py b/llmcore.py index e99a3f5..c2e58d6 100644 --- a/llmcore.py +++ b/llmcore.py @@ -439,7 +439,7 @@ class BaseSession: try: while True: chunk = next(gen); content += chunk; yield chunk except StopIteration as e: content_blocks = e.value or [] - print(f"[DEBUG BaseSession.ask] content_blocks: {content_blocks}") + if len(content_blocks) > 1: print(f"[DEBUG BaseSession.ask] content_blocks: {content_blocks}") for block in (content_blocks or []): if block.get('type', '') == 'tool_use': tu = {'name': block.get('name', ''), 'arguments': block.get('input', {})} @@ -680,7 +680,7 @@ class ToolClient: json_strs.extend([s for s in tool_all if s.startswith('{') and s.endswith('}')]) remaining_text = re.sub(tool_pattern, "", remaining_text, flags=re.DOTALL) elif '' in remaining_text: - weaktoolstr = remaining_text.split('')[-1].strip() + weaktoolstr = remaining_text.split('')[-1].strip().strip('><') json_str = weaktoolstr if weaktoolstr.endswith('}') else '' if json_str == '' and '```' in weaktoolstr and weaktoolstr.split('```')[0].strip().endswith('}'): json_str = weaktoolstr.split('```')[0].strip()