myagent-ai 1.47.21 → 1.47.22
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/agents/main_agent.py +2 -35
- package/package.json +1 -1
- package/web/ui/chat/chat_main.js +0 -8
- package/web/ui/chat/flow_engine.js +2 -27
package/agents/main_agent.py
CHANGED
|
@@ -499,27 +499,6 @@ class MainAgent(BaseAgent):
|
|
|
499
499
|
except Exception as e:
|
|
500
500
|
logger.debug(f"V2 SSE 事件发送失败 ({event_type}): {e}")
|
|
501
501
|
|
|
502
|
-
def _try_extract_partial_response(self, llm_raw: str) -> str:
|
|
503
|
-
"""[v1.47.21] 从不完整的 LLM 输出中提取纯文本回复。
|
|
504
|
-
|
|
505
|
-
完全依赖原生 tool_calling,不再解析 XML 格式。
|
|
506
|
-
仅做简单的 XML 标签清理(兜底,防止模型意外输出 XML)。
|
|
507
|
-
"""
|
|
508
|
-
if not llm_raw:
|
|
509
|
-
return ""
|
|
510
|
-
|
|
511
|
-
import re
|
|
512
|
-
# 去除所有 XML 标签
|
|
513
|
-
cleaned = re.sub(r"<[^>]+>", "", llm_raw).strip()
|
|
514
|
-
cleaned = re.sub(r"^(reasoning|assistant)\s*", "", cleaned, flags=re.IGNORECASE).strip()
|
|
515
|
-
# 跳过工具执行状态文本
|
|
516
|
-
if cleaned and len(cleaned) > 5 and not re.match(
|
|
517
|
-
r"^(执行工具|调用工具|Running tool|Calling tool)", cleaned, re.IGNORECASE
|
|
518
|
-
):
|
|
519
|
-
return cleaned
|
|
520
|
-
|
|
521
|
-
return ""
|
|
522
|
-
|
|
523
502
|
async def _merge_duplicate_memory(
|
|
524
503
|
self,
|
|
525
504
|
old_memory,
|
|
@@ -1180,20 +1159,8 @@ class MainAgent(BaseAgent):
|
|
|
1180
1159
|
continue
|
|
1181
1160
|
|
|
1182
1161
|
else:
|
|
1183
|
-
#
|
|
1184
|
-
|
|
1185
|
-
raw_content = (response.content or "").strip()
|
|
1186
|
-
|
|
1187
|
-
# 如果模型意外输出了 XML 标签,清理掉
|
|
1188
|
-
import re as _re_clean
|
|
1189
|
-
if raw_content.startswith("<") and "</" in raw_content:
|
|
1190
|
-
# 清除 XML 标签,提取纯文本
|
|
1191
|
-
cleaned = _re_clean.sub(r'<[^>]+>', '', raw_content).strip()
|
|
1192
|
-
if cleaned:
|
|
1193
|
-
raw_content = cleaned
|
|
1194
|
-
logger.info(f"[{task_id}] 清理了 LLM 输出中的 XML 标签")
|
|
1195
|
-
|
|
1196
|
-
reply_text = raw_content
|
|
1162
|
+
# 没有原生工具调用 → 纯文本回复,完全依赖 tool_calling
|
|
1163
|
+
reply_text = (response.content or "").strip()
|
|
1197
1164
|
logger.info(f"[{task_id}] 无工具调用,任务完成 (reply长度={len(reply_text)})")
|
|
1198
1165
|
|
|
1199
1166
|
if not reply_text:
|
package/package.json
CHANGED
package/web/ui/chat/chat_main.js
CHANGED
|
@@ -2999,11 +2999,7 @@ async function selectSession(id) {
|
|
|
2999
2999
|
return m && (m.role === 'user' || m.role === 'assistant' || m.role === 'tool');
|
|
3000
3000
|
}).map(function(m) {
|
|
3001
3001
|
var content = (m.content != null) ? String(m.content) : '';
|
|
3002
|
-
// [v1.47.21] 清理意外输出的 XML 标签(完全依赖 tool_calling)
|
|
3003
3002
|
var mkey = (m.key || '').toLowerCase();
|
|
3004
|
-
if (m.role === 'assistant' && content && content.trim().startsWith('<')) {
|
|
3005
|
-
content = content.replace(/<[^>]+>/g, ' ').replace(/\s{2,}/g, ' ').trim();
|
|
3006
|
-
}
|
|
3007
3003
|
var mapped = {
|
|
3008
3004
|
role: m.role || 'assistant',
|
|
3009
3005
|
content: content,
|
|
@@ -3108,10 +3104,6 @@ async function loadMoreMessages() {
|
|
|
3108
3104
|
}).map(function(m) {
|
|
3109
3105
|
var content = (m.content != null) ? String(m.content) : '';
|
|
3110
3106
|
var mkey = (m.key || '').toLowerCase();
|
|
3111
|
-
// [v1.47.21] 清理意外输出的 XML 标签
|
|
3112
|
-
if (m.role === 'assistant' && content && content.trim().startsWith('<')) {
|
|
3113
|
-
content = content.replace(/<[^>]+>/g, ' ').replace(/\s{2,}/g, ' ').trim();
|
|
3114
|
-
}
|
|
3115
3107
|
var mapped = {
|
|
3116
3108
|
role: m.role || 'assistant',
|
|
3117
3109
|
content: content,
|
|
@@ -398,10 +398,6 @@ async function pollChatHistory() {
|
|
|
398
398
|
}).map(function(m) {
|
|
399
399
|
var content = (m.content != null) ? String(m.content) : '';
|
|
400
400
|
var mkey = (m.key || '').toLowerCase();
|
|
401
|
-
// [v1.47.21] 清理意外输出的 XML 标签(完全依赖 tool_calling,不再解析 XML)
|
|
402
|
-
if (m.role === 'assistant' && content && content.trim().startsWith('<')) {
|
|
403
|
-
content = content.replace(/<[^>]+>/g, ' ').replace(/\s{2,}/g, ' ').trim();
|
|
404
|
-
}
|
|
405
401
|
var mapped = {
|
|
406
402
|
role: m.role || 'assistant',
|
|
407
403
|
content: content,
|
|
@@ -416,7 +412,7 @@ async function pollChatHistory() {
|
|
|
416
412
|
if (m._media && m._media.length > 0) mapped._media = m._media;
|
|
417
413
|
return mapped;
|
|
418
414
|
});
|
|
419
|
-
|
|
415
|
+
|
|
420
416
|
// 检测是否有新消息
|
|
421
417
|
var newCount = loaded.length;
|
|
422
418
|
if (newCount === _lastKnownMessageCount && !state.isGenerating) return; // 无变化且非生成中,跳过
|
|
@@ -472,10 +468,6 @@ async function forceRefreshHistory() {
|
|
|
472
468
|
}).map(function(m) {
|
|
473
469
|
var content = (m.content != null) ? String(m.content) : '';
|
|
474
470
|
var mkey = (m.key || '').toLowerCase();
|
|
475
|
-
// [v1.47.21] 清理意外输出的 XML 标签
|
|
476
|
-
if (m.role === 'assistant' && content && content.trim().startsWith('<')) {
|
|
477
|
-
content = content.replace(/<[^>]+>/g, ' ').replace(/\s{2,}/g, ' ').trim();
|
|
478
|
-
}
|
|
479
471
|
var mapped = {
|
|
480
472
|
role: m.role || 'assistant',
|
|
481
473
|
content: content,
|
|
@@ -1114,16 +1106,6 @@ function _showFinishNotification(text) {
|
|
|
1114
1106
|
setTimeout(function() { if (overlay.parentNode) overlay.remove(); }, 5000);
|
|
1115
1107
|
}
|
|
1116
1108
|
|
|
1117
|
-
/**
|
|
1118
|
-
* [v1.47.21] Strip XML tags from text — simple regex cleanup for accidental XML output.
|
|
1119
|
-
* No longer parses <output>/<reply>/<toolstocal> — fully relies on native tool_calling.
|
|
1120
|
-
*/
|
|
1121
|
-
function _stripXmlTags(xml) {
|
|
1122
|
-
if (!xml) return '';
|
|
1123
|
-
return xml.replace(/<[^>]+>/g, ' ').replace(/</g, '<').replace(/>/g, '>')
|
|
1124
|
-
.replace(/&/g, '&').replace(/\s{2,}/g, ' ').trim();
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
1109
|
// ══════════════════════════════════════════════════════
|
|
1128
1110
|
// ── V2 Content Assembler (V2 内容组装) ──
|
|
1129
1111
|
// ══════════════════════════════════════════════════════
|
|
@@ -1148,14 +1130,7 @@ function _assembleV2Content(msg, msgParts) {
|
|
|
1148
1130
|
if (msg._askUser && msg._askUser.trim()) {
|
|
1149
1131
|
return msg._askUser.trim();
|
|
1150
1132
|
}
|
|
1151
|
-
// Priority 4:
|
|
1152
|
-
if (msg._v2RawXml && msg._v2RawXml.trim()) {
|
|
1153
|
-
var strippedText = _stripXmlTags(msg._v2RawXml);
|
|
1154
|
-
if (strippedText && strippedText.trim()) {
|
|
1155
|
-
return strippedText.trim();
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
// Priority 5: raw content from message (server-stored response)
|
|
1133
|
+
// Priority 4: raw content from message (server-stored response)
|
|
1159
1134
|
if (msg.content && msg.content.trim() && msg.content !== '(无回复)') {
|
|
1160
1135
|
return msg.content.trim();
|
|
1161
1136
|
}
|