Skip to content

Import external agent sessions in background#20284

Merged
stefanstokic-oai merged 1 commit intomainfrom
stefans/async-external-agent-session-import
Apr 30, 2026
Merged

Import external agent sessions in background#20284
stefanstokic-oai merged 1 commit intomainfrom
stefans/async-external-agent-session-import

Conversation

@stefanstokic-oai
Copy link
Copy Markdown
Contributor

@stefanstokic-oai stefanstokic-oai commented Apr 29, 2026

Summary:

  • Return from external agent import before session history import finishes
  • Run session import work in the background and emit the existing completion notification when it is done
  • Serialize session imports so duplicate requests do not create duplicate imported threads

Verification:

  • cargo test -p codex-app-server external_agent_config_
  • cargo test -p codex-external-agent-sessions
  • just fix -p codex-app-server
  • just fix -p codex-external-agent-sessions
  • git diff --check

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1ea81e3e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +172 to +174
if selected_session_paths.insert(canonical_path) {
selected_sessions.push(session);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve canonical path through background import

The request is validated against a canonical path, but the canonical value is discarded and the original path is queued for background work. Because import now runs later, that path can be retargeted (e.g., symlink swap) before prepare_validated_session_imports reads it, enabling import of a different file than was validated.

Useful? React with 👍 / 👎.

Comment on lines +1267 to +1273
Err(error) => {
tracing::warn!(
error = %error.message,
path = %pending_session_import.source_path.display(),
"external agent session import failed"
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Report session import failures instead of silently succeeding

After moving session imports to a background task, errors from import_external_agent_session are only logged and never propagated. The client already got ExternalAgentConfigImportResponse {} and later a completion notification, even when imports fail (e.g., config load/start-thread errors). Previously this path used ? and failed the request.

Useful? React with 👍 / 👎.

@alexsong-oai
Copy link
Copy Markdown
Collaborator

@codex review

@stefanstokic-oai stefanstokic-oai enabled auto-merge (squash) April 29, 2026 23:51
@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@stefanstokic-oai stefanstokic-oai merged commit c8abcbf into main Apr 30, 2026
25 checks passed
@stefanstokic-oai stefanstokic-oai deleted the stefans/async-external-agent-session-import branch April 30, 2026 00:00
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants