Direct 回合在 begin 之后补分段 trace
Project CI / Backend tests (push) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (push) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (push) Has been cancelled
Project CI / AI game creator shell Rust smoke (push) Has been cancelled
Project CI / AI game creator shell Rust crates (push) Has been cancelled
Project CI / Native shell tests (push) Has been cancelled
Project CI / Frontend tests (push) Has been cancelled
Project CI / Repository checks (push) Has been cancelled
Project CI / AI game creator shell web tests (push) Has been cancelled

新增 direct_turn_trace:按 stage 写应用日志,定位回合在 begin 与执行器之间停在哪一步
覆盖 session-ready / run-analytics-accepted / goal-analytics-accepted / system-prompt-ready / executor-dispatch
仅在 cfg(not(test)) 生效,不污染用例与本机 AppData
This commit is contained in:
kdletters
2026-10-02 13:56:52 +08:00
parent b8a659c12f
commit 35af46dd94
@@ -4294,6 +4294,24 @@ pub(crate) fn check_direct_turn_preconditions(
.map_err(|detail| DirectTurnError::InputRejected { detail })?;
Ok(())
}
/// Direct 回合在 `direct_execution::begin` 之后的分段 trace。
///
/// 起因:2026-10-02 连续四轮回合都停在 `begin` 之后——账本 `phase=working`、
/// `nextSequence=0`、`active={}`、没有任何错误 sidecar、stderr 无 panic、连
/// `agent.direct_codex.*` 都没有。窗口就夹在 `begin` 与执行器调用之间,需要知道
/// 具体停在哪一步。测试态不写,避免污染本机 AppData。
#[cfg(not(test))]
fn direct_turn_trace(stage: &str) {
let _ = crate::append_application_log(
"info".to_string(),
"direct-turn".to_string(),
format!("agent.direct_turn.trace stage={stage}"),
);
}
#[cfg(test)]
fn direct_turn_trace(_stage: &str) {}
pub(crate) async fn run_direct_game_creator_turn_at_with_creation_type_and_emitter(
root: &Path,
prompt: &str,
@@ -4401,6 +4419,7 @@ async fn run_direct_game_creator_turn_inner(
})?;
let execution_session = execution_guard.session();
execution_session.set_analytics_capture(capture.clone());
direct_turn_trace("session-ready");
let started = execution_session
.newly_accepted
.then(std::time::Instant::now);
@@ -4411,6 +4430,7 @@ async fn run_direct_game_creator_turn_inner(
}
}
}
direct_turn_trace("run-analytics-accepted");
// 在 guard 仍存活时冻结整体结果,避免 Drop 的中断收尾覆盖真实失败原因。
let result: Result<String, DirectTurnError> = async {
if let Some(report) = super::direct_delivery::terminal_report(&execution_session) {
@@ -4444,6 +4464,7 @@ async fn run_direct_game_creator_turn_inner(
);
}
}
direct_turn_trace("goal-analytics-accepted");
emit_direct_game_creator_progress(root, "codex.turn", "陶泥儿正在处理这条消息");
if let Some(emitter) = turn_emitter {
emitter.emit("running", Some("preparing"));
@@ -4460,6 +4481,7 @@ async fn run_direct_game_creator_turn_inner(
DirectTurnError::turn_failed(DirectCodexFailureStage::CodeGeneration, error)
},
)?;
direct_turn_trace("system-prompt-ready");
// 三维请求:把"自选三维技术栈、解除 Phaser 固定约束"的合同放在系统提示最前,
// 避免被长度上限截断,也不阻断任何工具。
let engine_contract = direct_engine_three_dimensional_contract(root, prompt);
@@ -4471,6 +4493,7 @@ async fn run_direct_game_creator_turn_inner(
None => base_system_prompt,
};
let reply = if let Some(emitter) = turn_emitter {
direct_turn_trace("executor-dispatch");
let client_turn_id = emitter.turn_id().to_string();
let emitter = emitter.clone();
let mut observer = |observation: DirectCodexTurnObservation| {