Conversation
Member
|
@dadachann Check if this PR is okay for merging, if not, submit your review |
Collaborator
|
👋 I’m dadachann, the LangBot community maintenance agent. I’ve picked up the review/task on this pull request and will share findings and next steps here. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
|
自托管 Coze 的结束事件不是 done,runner 又只在 message_idx % 8 == 0 的边界 flush,于是落在边界之后的尾巴会丢;恰好结束在边界上时更糟,一个 is_final 的块 都不会发,respback 取到的 is_final 恒为 False,wecombot 这类"只在 is_final 时 投递"的适配器会一直挂到超时。 循环结束后补发一次完整内容并标记 is_final,保证正常结束时上游一定收到终态快照。 判断用 is_final 而不是内容长度:结束在边界上时长度没有变化,但终态信号仍然必须 补发;重复发送的是同一份累计内容,下游是覆盖语义,重复无副作用。error 事件与 取消路径在循环内 return/raise,走不到这里。 测试直接驱动真实 runner,覆盖 1..40 全长度、7/15/23/31/39 边界长度、done 出现在 各位置、自托管结束事件、error 事件与中途抛异常。 Refs langbot-app#2518
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Self-hosted Coze does not emit a terminating
doneevent, but the runner detects theterminal event with
event_type.split('.')[-1] == 'done', sois_finalcan stayFalsefor the whole stream. Since the runner only flushed on a
message_idx % 8 == 0boundary:is_finalat all, leaving theupstream stream open -- adapters that only deliver on
is_final(e.g. WeCom) hanguntil timeout.
The runner now emits one final cumulative snapshot after the loop whenever no terminal
event was seen. The guard is
not is_finalrather than a content-length comparison: ona boundary ending the content length is unchanged, yet the terminal signal still has to
be sent. Re-sending the same cumulative snapshot is safe -- every
reply_message_chunkimplementation treats chunk content as the full message text (replace semantics, never
append).
Tests
tests/unit_tests/provider/runners/test_coze_tail_flush.pydrives the real runner(
_chat_messages_chunk) with a mocked Coze client:doneevent -> the last chunk is complete andis_final;doneat every position, plus the self-hosted end event(
conversation.chat.completed), which the runner does not match;errorevent and a mid-stream exception are never reported as success.