修复 DirectProject 历史与线程初始化
尾行损坏时先允许底层 JSONL 追加逻辑修复 历史注入失败时淘汰未完成初始化的 Codex thread turn/start 传递稳定 clientUserMessageId
This commit is contained in:
@@ -977,6 +977,7 @@ fn codex_app_server_turn_start_params(
|
||||
model: &str,
|
||||
workspace_path: &std::path::Path,
|
||||
workspace_mode: CodexAppServerWorkspaceMode,
|
||||
client_user_message_id: Option<&str>,
|
||||
) -> serde_json::Value {
|
||||
let approval_policy = "never";
|
||||
let mut params = serde_json::json!({
|
||||
@@ -994,6 +995,13 @@ fn codex_app_server_turn_start_params(
|
||||
"networkAccess": false
|
||||
});
|
||||
}
|
||||
if let Some(client_user_message_id) = client_user_message_id
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty())
|
||||
{
|
||||
params["clientUserMessageId"] =
|
||||
serde_json::Value::String(client_user_message_id.to_string());
|
||||
}
|
||||
params
|
||||
}
|
||||
|
||||
@@ -2140,14 +2148,23 @@ impl CodexAppServerConnection {
|
||||
));
|
||||
}
|
||||
if thread_created {
|
||||
let items = read_direct_project_history_items_at(history_root)
|
||||
.map_err(platform_llm::LlmError::InvalidRequest)?;
|
||||
self.request(
|
||||
"thread/inject_items",
|
||||
serde_json::json!({"threadId": thread_id, "items": items}),
|
||||
)
|
||||
.await
|
||||
.map_err(platform_llm::LlmError::Transport)?;
|
||||
let items = match read_direct_project_history_items_at(history_root) {
|
||||
Ok(items) => items,
|
||||
Err(error) => {
|
||||
self.release_thread(snapshot, &thread_id).await;
|
||||
return Err(platform_llm::LlmError::InvalidRequest(error));
|
||||
}
|
||||
};
|
||||
if let Err(error) = self
|
||||
.request(
|
||||
"thread/inject_items",
|
||||
serde_json::json!({"threadId": thread_id, "items": items}),
|
||||
)
|
||||
.await
|
||||
{
|
||||
self.release_thread(snapshot, &thread_id).await;
|
||||
return Err(platform_llm::LlmError::Transport(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
let prompt = if self.inner.workspace_mode.uses_direct_conversation() {
|
||||
@@ -2186,6 +2203,7 @@ impl CodexAppServerConnection {
|
||||
model,
|
||||
&self.inner.workspace_path,
|
||||
self.inner.workspace_mode,
|
||||
_direct_client_turn_id,
|
||||
);
|
||||
apply_game_creator_codex_app_server_reasoning_effort(&mut params, &request);
|
||||
if let Some(schema) = game_creator_codex_cli_tool_output_schema(&request) {
|
||||
@@ -3630,6 +3648,7 @@ mod tests {
|
||||
"fixture-model",
|
||||
workspace,
|
||||
CodexAppServerWorkspaceMode::DirectHome,
|
||||
None,
|
||||
);
|
||||
assert_eq!(turn["threadId"], "home-thread");
|
||||
assert_eq!(turn["approvalPolicy"], "never");
|
||||
@@ -3690,6 +3709,7 @@ mod tests {
|
||||
"fixture-model",
|
||||
&workspace,
|
||||
CodexAppServerWorkspaceMode::DirectProject,
|
||||
None,
|
||||
);
|
||||
assert_eq!(
|
||||
turn.pointer("/sandboxPolicy/writableRoots/0"),
|
||||
|
||||
Reference in New Issue
Block a user