coze_lab 0.1.47 → 0.1.48
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
|
@@ -1472,7 +1472,12 @@ def send_steps_realtime(turns, session_id, history_turns, state, coze_tags_overr
|
|
|
1472
1472
|
if token:
|
|
1473
1473
|
os.environ["COZELOOP_API_TOKEN"] = token
|
|
1474
1474
|
workspace_id = os.environ.get("COZELOOP_WORKSPACE_ID", "") or _DEFAULT_WORKSPACE_ID
|
|
1475
|
-
|
|
1475
|
+
upload_events: List[str] = []
|
|
1476
|
+
client_kwargs = {
|
|
1477
|
+
"ultra_large_report": True,
|
|
1478
|
+
"upload_timeout": 120,
|
|
1479
|
+
"trace_finish_event_processor": _make_finish_event_processor(upload_events),
|
|
1480
|
+
}
|
|
1476
1481
|
if workspace_id:
|
|
1477
1482
|
client_kwargs["workspace_id"] = workspace_id
|
|
1478
1483
|
if token:
|
|
@@ -1539,6 +1544,9 @@ def send_steps_realtime(turns, session_id, history_turns, state, coze_tags_overr
|
|
|
1539
1544
|
# 实测:root finish 后,子 span 仍可用其 header 挂到同一 trace_id 下,不影响后续增量。
|
|
1540
1545
|
root_span.finish()
|
|
1541
1546
|
client.flush()
|
|
1547
|
+
if upload_events:
|
|
1548
|
+
debug_log(f"[rt] upload failed after root flush: {upload_events[-1][:500]}")
|
|
1549
|
+
return None
|
|
1542
1550
|
debug_log(f"[rt] root created+finished trace_id={getattr(root_ctx,'trace_id','?')}")
|
|
1543
1551
|
|
|
1544
1552
|
# ---- 发新完成的 step ----
|
|
@@ -1622,6 +1630,9 @@ def send_steps_realtime(turns, session_id, history_turns, state, coze_tags_overr
|
|
|
1622
1630
|
sent += 1
|
|
1623
1631
|
# 每个 step 立即 flush —— 这是“结束即可见”的关键。
|
|
1624
1632
|
client.flush()
|
|
1633
|
+
if upload_events:
|
|
1634
|
+
debug_log(f"[rt] upload failed after step flush: {upload_events[-1][:500]}")
|
|
1635
|
+
return None
|
|
1625
1636
|
|
|
1626
1637
|
new_last = last_global + sent
|
|
1627
1638
|
state["rt_last_global_step"] = new_last
|
|
@@ -1650,8 +1661,15 @@ def send_steps_realtime(turns, session_id, history_turns, state, coze_tags_overr
|
|
|
1650
1661
|
fin.set_output(last_output)
|
|
1651
1662
|
fin.finish()
|
|
1652
1663
|
client.flush()
|
|
1664
|
+
if upload_events:
|
|
1665
|
+
debug_log(f"[rt] upload failed after final flush: {upload_events[-1][:500]}")
|
|
1666
|
+
return None
|
|
1653
1667
|
debug_log(f"[rt] finalized, total sent steps={new_last}")
|
|
1654
1668
|
|
|
1669
|
+
if upload_events:
|
|
1670
|
+
debug_log(f"[rt] upload failed, state not advanced. Last failure: {upload_events[-1][:500]}")
|
|
1671
|
+
return None
|
|
1672
|
+
|
|
1655
1673
|
debug_log(f"[rt] sent {sent} new step(s), last_global={new_last}/{total_steps}, terminal={is_terminal}")
|
|
1656
1674
|
return True
|
|
1657
1675
|
except Exception as e:
|
|
@@ -1251,7 +1251,12 @@ def send_steps_realtime(turns, session_id, state, model_name="codex", coze_tags_
|
|
|
1251
1251
|
if token:
|
|
1252
1252
|
os.environ["COZELOOP_API_TOKEN"] = token
|
|
1253
1253
|
workspace_id = os.environ.get("COZELOOP_WORKSPACE_ID", "") or _DEFAULT_WORKSPACE_ID
|
|
1254
|
-
|
|
1254
|
+
upload_events: List[str] = []
|
|
1255
|
+
client_kwargs = {
|
|
1256
|
+
"ultra_large_report": True,
|
|
1257
|
+
"upload_timeout": 120,
|
|
1258
|
+
"trace_finish_event_processor": _make_finish_event_processor(upload_events),
|
|
1259
|
+
}
|
|
1255
1260
|
if workspace_id:
|
|
1256
1261
|
client_kwargs["workspace_id"] = workspace_id
|
|
1257
1262
|
if token:
|
|
@@ -1307,6 +1312,9 @@ def send_steps_realtime(turns, session_id, state, model_name="codex", coze_tags_
|
|
|
1307
1312
|
root_ctx = client.get_span_from_header(state["rt_root_header"])
|
|
1308
1313
|
root_span.finish() # 立即 finish 落库(后端按 root_span 查),子 span 仍可挂同 trace
|
|
1309
1314
|
client.flush()
|
|
1315
|
+
if upload_events:
|
|
1316
|
+
hook_log(f"[rt] upload failed after root flush detail={upload_events[-1][:500]}")
|
|
1317
|
+
return None
|
|
1310
1318
|
hook_log(f"[rt] root created trace_id={getattr(root_ctx,'trace_id','?')}")
|
|
1311
1319
|
|
|
1312
1320
|
# 线性展开所有 tool_call(带 result 的才算完成),按全局序增量发
|
|
@@ -1361,6 +1369,9 @@ def send_steps_realtime(turns, session_id, state, model_name="codex", coze_tags_
|
|
|
1361
1369
|
tspan.finish()
|
|
1362
1370
|
sent += 1
|
|
1363
1371
|
client.flush() # 每个 tool_call 立即 flush → 结束即可见
|
|
1372
|
+
if upload_events:
|
|
1373
|
+
hook_log(f"[rt] upload failed after tool flush detail={upload_events[-1][:500]}")
|
|
1374
|
+
return None
|
|
1364
1375
|
|
|
1365
1376
|
state["rt_last_tool"] = last_tool + sent
|
|
1366
1377
|
if sent > 0:
|
|
@@ -1382,8 +1393,15 @@ def send_steps_realtime(turns, session_id, state, model_name="codex", coze_tags_
|
|
|
1382
1393
|
fin.set_output(truncate_text(last_out))
|
|
1383
1394
|
fin.finish()
|
|
1384
1395
|
client.flush()
|
|
1396
|
+
if upload_events:
|
|
1397
|
+
hook_log(f"[rt] upload failed after final flush detail={upload_events[-1][:500]}")
|
|
1398
|
+
return None
|
|
1385
1399
|
hook_log(f"[rt] finalized total_tools={state['rt_last_tool']}")
|
|
1386
1400
|
|
|
1401
|
+
if upload_events:
|
|
1402
|
+
hook_log(f"[rt] upload failed state not advanced detail={upload_events[-1][:500]}")
|
|
1403
|
+
return None
|
|
1404
|
+
|
|
1387
1405
|
hook_log(f"[rt] sent {sent} tool span(s), last_tool={state['rt_last_tool']}, terminal={is_terminal}")
|
|
1388
1406
|
return True
|
|
1389
1407
|
except Exception as e:
|