feat(astrbot): record the message id value in the frame trace
The first capture answered the question the trace was built for and eliminated it: all 77 plain frames of one reply carried a message_id, so a reply splitting into two bubbles is not the event_id fallback in F-34. What remains depends on the value rather than its presence. If the id changes partway through a reply then the client is correctly showing two messages the server sent; if it stays the same then the split is ours, in the historySessionId fallback that loads another session's history. The id is an opaque row identifier, not content. Also record the length of a string data payload. It separates "the server streamed many small chunks" from "the server sent the reply in one piece" without recording any text. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
这个提交存在于:
父节点
06316a3240
当前提交
6060b968a7
共有 1 个文件被更改,包括 23 次插入 和 0 次删除
|
|
@ -765,6 +765,23 @@ fn trace_frame_shape(line: &str) {
|
|||
let has_message_id = value
|
||||
.get("message_id")
|
||||
.is_some_and(|field| !field.is_null());
|
||||
// The *value* decides whether a reply that renders as two bubbles is one
|
||||
// message the client split, or two messages the server sent. It is an
|
||||
// opaque row identifier, not content.
|
||||
let message_id = value
|
||||
.get("message_id")
|
||||
.and_then(|field| match field {
|
||||
Value::String(text) => Some(text.clone()),
|
||||
Value::Number(number) => Some(number.to_string()),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or_else(|| "<none>".to_owned());
|
||||
// Length only. Distinguishes "the server streamed many small chunks" from
|
||||
// "the server sent the whole reply at once" without recording any text.
|
||||
let data_len = match value.get("data") {
|
||||
Some(Value::String(text)) => text.chars().count(),
|
||||
_ => 0,
|
||||
};
|
||||
let has_session_id = value
|
||||
.get("session_id")
|
||||
.is_some_and(|field| !field.is_null());
|
||||
|
|
@ -773,9 +790,11 @@ fn trace_frame_shape(line: &str) {
|
|||
target: FRAME_TRACE_TARGET,
|
||||
frame_type,
|
||||
has_message_id,
|
||||
message_id = message_id.as_str(),
|
||||
has_session_id,
|
||||
?streaming,
|
||||
data_keys = data_keys.as_str(),
|
||||
data_len,
|
||||
"astrbot sse frame"
|
||||
);
|
||||
}
|
||||
|
|
@ -898,6 +917,10 @@ mod tests {
|
|||
);
|
||||
assert!(output.contains("frame_type=\"plain\""));
|
||||
assert!(output.contains("has_message_id=true"));
|
||||
// The value, and the chunk length, are what separate "one message the
|
||||
// client split" from "two messages the server sent".
|
||||
assert!(output.contains("message_id=\"42\""));
|
||||
assert!(output.contains("data_len=2"));
|
||||
assert!(output.contains("frame_type=\"image\""));
|
||||
// The key names are what identify the plugin attachment shape.
|
||||
assert!(output.contains("data_keys=\"url\""));
|
||||
|
|
|
|||
正在加载…
添加表格
在新工单中引用