增强策划Agent流式调试记录

记录流式事件时间、序号、增量与累计文本长度及结束原因

扩大异步调试队列容量,保持调试写入不阻塞正常运行
This commit is contained in:
2026-09-13 07:34:12 +00:00
parent 85e1503217
commit d9f1376beb
@@ -473,7 +473,7 @@ fn design_debug(root: &Path, kind: &str, data: Value) {
type Entry = (PathBuf, Value);
static QUEUE: OnceLock<std::sync::mpsc::SyncSender<Entry>> = OnceLock::new();
let sender = QUEUE.get_or_init(|| {
let (sender, receiver) = std::sync::mpsc::sync_channel::<Entry>(16);
let (sender, receiver) = std::sync::mpsc::sync_channel::<Entry>(256);
let _ = std::thread::Builder::new()
.name("design-debug".into())
.spawn(move || {
@@ -546,8 +546,26 @@ async fn request_design_provider(
None,
));
let result = if llm.stream {
let mut stream_sequence = 0_u64;
client
.stream_run(request.clone(), |delta| {
stream_sequence = stream_sequence.saturating_add(1);
design_debug(
root,
"stream",
json!({
"turnId": turn_id,
"requestIndex": session.turn.as_ref().map(|turn| turn.request_index),
"attempt": attempt,
"sequence": stream_sequence,
"occurredAtUnixNanos": unix_timestamp_nanos().to_string(),
"model": llm.model,
"deltaChars": delta.delta_text.chars().count(),
"accumulatedChars": delta.accumulated_text.chars().count(),
"deltaText": delta.delta_text,
"finishReason": delta.finish_reason,
}),
);
emit(design_event(
root,
&turn_id,