feat(astrbot): record the message id value in the frame trace
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run

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>
这个提交存在于:
YokiiroBW 2026-07-27 01:54:17 +08:00
父节点 06316a3240
当前提交 6060b968a7

查看文件

@ -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\""));