mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Separate thread startup metadata from replay history (#46294)
## Why `CodexThread` retained the full `SessionConfiguredEvent`, including initial replay messages, and cloned it even for callers that only needed thread or session IDs. ## What changed Store `ThreadStartupMetadata` without replay history and expose it by reference through `startup_metadata()`. Update callers to read IDs from this metadata. When rejoining a running thread, rebuild the startup response using the supplied resume history for `initial_messages`. ## Testing Extend the resume test to verify that rejoining reuses the loaded thread, preserves startup metadata, and still returns the original replay messages as a prefix. GitOrigin-RevId: 9d656063088c28f091d29e5862e4b9d894b7642c
This commit is contained in:
1 parent
47fc8d661e
commit
17baabd01b
11 files changed
+171
-25
No files matched your search
@@ -739,7 +739,7 @@ pub(super) async fn handle_pending_thread_resume_request(
|
||||
let instruction_sources = pending.instruction_sources;
|
||||
let active_permission_profile =
|
||||
thread_response_active_permission_profile(active_permission_profile);
|
||||
let session_id = conversation.session_configured().session_id.to_string();
|
||||
let session_id = conversation.startup_metadata().session_id.to_string();
|
||||
thread.session_id = session_id;
|
||||
|
||||
let response = ThreadResumeResponse {
|
||||
|
||||
@@ -2035,7 +2035,7 @@ impl ThreadRequestProcessor {
|
||||
&self.config.cwd,
|
||||
);
|
||||
if let Ok(loaded_thread) = self.thread_manager.get_thread(thread_uuid).await {
|
||||
thread.session_id = loaded_thread.session_configured().session_id.to_string();
|
||||
thread.session_id = loaded_thread.startup_metadata().session_id.to_string();
|
||||
let config_snapshot = loaded_thread.config_snapshot().await;
|
||||
apply_live_thread_settings(&mut thread, &config_snapshot);
|
||||
}
|
||||
@@ -4396,7 +4396,7 @@ impl ThreadRequestProcessor {
|
||||
config_snapshot.model_provider_id.as_str(),
|
||||
/*include_turns*/ false,
|
||||
);
|
||||
thread_summary.session_id = existing_thread.session_configured().session_id.to_string();
|
||||
thread_summary.session_id = existing_thread.startup_metadata().session_id.to_string();
|
||||
thread_summary.thread_source = config_snapshot.thread_source.clone().map(Into::into);
|
||||
apply_live_thread_settings(&mut thread_summary, &config_snapshot);
|
||||
thread_summary.can_accept_direct_input = Some(can_accept_direct_input(
|
||||
@@ -4686,7 +4686,7 @@ impl ThreadRequestProcessor {
|
||||
include_turns: bool,
|
||||
) -> std::result::Result<Thread, String> {
|
||||
let config_snapshot = thread.config_snapshot().await;
|
||||
let session_id = thread.session_configured().session_id.to_string();
|
||||
let session_id = thread.startup_metadata().session_id.to_string();
|
||||
let can_accept_direct_input = can_accept_direct_input(
|
||||
thread.multi_agent_version(),
|
||||
&config_snapshot.session_source,
|
||||
@@ -6323,7 +6323,7 @@ fn build_thread_from_loaded_snapshot(
|
||||
) -> Thread {
|
||||
build_thread_from_snapshot(
|
||||
thread_id,
|
||||
loaded_thread.session_configured().session_id.to_string(),
|
||||
loaded_thread.startup_metadata().session_id.to_string(),
|
||||
loaded_thread.multi_agent_version(),
|
||||
config_snapshot,
|
||||
loaded_thread.rollout_path(),
|
||||
|
||||
@@ -1473,7 +1473,7 @@ impl TurnRequestProcessor {
|
||||
} = self
|
||||
.agent_runner
|
||||
.start(
|
||||
parent_thread.session_configured().thread_id,
|
||||
parent_thread.startup_metadata().thread_id,
|
||||
AgentInvocation {
|
||||
config,
|
||||
prompt: prompt.to_string(),
|
||||
@@ -1504,7 +1504,7 @@ impl TurnRequestProcessor {
|
||||
if let Some(mut thread) = stored_thread {
|
||||
let config_snapshot = review_thread.config_snapshot().await;
|
||||
apply_live_thread_settings(&mut thread, &config_snapshot);
|
||||
thread.session_id = review_thread.session_configured().session_id.to_string();
|
||||
thread.session_id = review_thread.startup_metadata().session_id.to_string();
|
||||
self.thread_watch_manager
|
||||
.upsert_thread_silently(&thread.id)
|
||||
.await;
|
||||
|
||||
Reference in new issue
Block a user