Skip to content

Commit 79cbca3

Browse files
Skip history metadata scan for subagents (openai#12918)
Summary - Skip `history_metadata` scanning when spawning subagents to avoid expensive per-spawn history scans. - Keeps behavior unchanged for normal sessions. Testing - `cd codex-rs && cargo test -p codex-core` - Failing in this environment (pre-existing and I don't think something I did?): - `suite::cli_stream::responses_mode_stream_cli` (SIGKILL + OTEL export error to http://localhost:14318/v1/logs) - `suite::grep_files::grep_files_tool_collects_matches` (unsupported call: grep_files) - `suite::grep_files::grep_files_tool_reports_empty_results` (unsupported call: grep_files) Co-authored-by: Codex <noreply@openai.com>
1 parent 79d6f80 commit 79cbca3

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

codex-rs/core/src/codex.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ impl Session {
11241124
//
11251125
// - initialize RolloutRecorder with new or resumed session info
11261126
// - perform default shell discovery
1127-
// - load history metadata
1127+
// - load history metadata (skipped for subagents)
11281128
let rollout_fut = async {
11291129
if config.ephemeral {
11301130
Ok::<_, anyhow::Error>((None, None))
@@ -1141,7 +1141,16 @@ impl Session {
11411141
}
11421142
};
11431143

1144-
let history_meta_fut = crate::message_history::history_metadata(&config);
1144+
let history_meta_fut = async {
1145+
if matches!(
1146+
session_configuration.session_source,
1147+
SessionSource::SubAgent(_)
1148+
) {
1149+
(0, 0)
1150+
} else {
1151+
crate::message_history::history_metadata(&config).await
1152+
}
1153+
};
11451154
let auth_manager_clone = Arc::clone(&auth_manager);
11461155
let config_for_mcp = Arc::clone(&config);
11471156
let auth_and_mcp_fut = async move {

0 commit comments

Comments
 (0)