fix(wecom): degrade stream replies to proactive msg when callback req_id stale

Turns that outlive the WeCom callback req_id window (e.g. approval
round-trips >5min) had their delta/finish frames silently rejected by
the gateway, so the user saw 'clicked approve, nothing happened' while
the agent kept working. Track req_id recv time; past a 240s TTL, stream
updates fall back to proactive aibot_send_msg. Also log non-zero
errcode ack frames so future gateway rejections are visible.
This commit is contained in:
openbot committed 2026-10-24 09:18:19 +08:00
1 parent e07f37fbb4
commit 59c44e94ca
3 files changed
+55 -21

No files matched your search

+2 -2
View File
@@ -37,7 +37,7 @@ def _channel() -> tuple[WecomAibotChannel, MockWS]:
def test_small_final_single_stream_frame():
ch, ws = _channel()
ch._req_ids["c1"] = "r1"
ch._req_ids["c1"] = ("r1", __import__("time").time())
ch._stream_close("c1", "hello")
streams = [m for m in ws.sent if m.get("cmd") == "aibot_respond_msg"]
assert len(streams) == 1
@@ -47,7 +47,7 @@ def test_small_final_single_stream_frame():
def test_large_final_splits_into_stream_plus_markdown():
ch, ws = _channel()
ch._req_ids["c1"] = "r1"
ch._req_ids["c1"] = ("r1", __import__("time").time())
big = "字" * 12000 # 3 bytes/char -> 36000 bytes > 19000 limit
ch._stream_close("c1", big)
streams = [m for m in ws.sent if m.get("cmd") == "aibot_respond_msg"]