coze_lab 0.1.11 → 0.1.12
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/package.json
CHANGED
|
@@ -1385,14 +1385,16 @@ def main():
|
|
|
1385
1385
|
# Group messages into turns and send to CozeLoop — only if coze-context present.
|
|
1386
1386
|
turns = group_messages_into_turns(new_messages)
|
|
1387
1387
|
if turns:
|
|
1388
|
-
|
|
1389
|
-
|
|
1388
|
+
# coze-context 只出现在首条用户消息里(cozelab 注入的 agent 才有)。增量 hook 触发时,
|
|
1389
|
+
# 新消息往往全是工具调用/结果(不带 coze-context),故必须连同历史 turns 一起判断——
|
|
1390
|
+
# 只要整个会话出现过 coze-context,就说明是被注入的 agent,后续增量都应上报。
|
|
1391
|
+
def _turn_has_ctx(turn):
|
|
1392
|
+
return bool(coze_context_tags(
|
|
1390
1393
|
(turn.get("user_message", {}).get("message", {}) or {}).get("content")
|
|
1391
|
-
)
|
|
1392
|
-
|
|
1393
|
-
)
|
|
1394
|
+
))
|
|
1395
|
+
has_coze_ctx = any(_turn_has_ctx(t) for t in turns) or any(_turn_has_ctx(t) for t in history_turns)
|
|
1394
1396
|
if not has_coze_ctx:
|
|
1395
|
-
debug_log("No coze-context found in any turn, skipping upload.")
|
|
1397
|
+
debug_log("No coze-context found in any turn (incl. history), skipping upload.")
|
|
1396
1398
|
return
|
|
1397
1399
|
print(f"[CozeLoop] 开始上报: session={session_id}, turns={len(turns)}", file=sys.stderr)
|
|
1398
1400
|
send_turns_to_cozeloop(turns, session_id, history_turns)
|