Skip to content

[app-server] improve thread list and resume rpc paths#28801

Closed
anaiskillian wants to merge 3 commits into
mainfrom
anais/create-rpc-improvement-codex-app
Closed

[app-server] improve thread list and resume rpc paths#28801
anaiskillian wants to merge 3 commits into
mainfrom
anais/create-rpc-improvement-codex-app

Conversation

@anaiskillian

@anaiskillian anaiskillian commented Jun 17, 2026

Copy link
Copy Markdown
  • This pr adds a SQLite list path for thread/list, using list-specific row types so the app-server only reads the fields needed for list responses instead of materializing the full thread. It preserves the existing filters, parent filtering, ordering, anchors, and repair validation while reducing the amount of DB work on the hot list path.
  • The original base-SHA synthetic RPC grader showed improvements for both thread/list and thread/resume. The release-binary validation below separately compares this PR's release build with the installed Codex CLI and the backend bundled with the stable Codex app.

Release-binary comparison

The PR was faster in every comparable scenario against both the installed Codex CLI 0.141 and the stable Codex app's bundled backend 0.140.0-alpha.2. Each comparison used three deterministic fixture seeds and seven paired timing repetitions per seed, alternated baseline and candidate ordering between seeds, and required the comparable RPC responses to pass the same correctness checks.

Each PR timing below comes from the same paired run as the adjacent installed baseline, so the two PR columns should not be compared with each other.

Scenario PR in CLI pair CLI 0.141 Speedup PR in stable-app pair Stable app 0.140 Speedup
thread/list, 100 threads 1.03 ms 2.15 ms 2.09x 0.92 ms 2.17 ms 2.36x
thread/list, 6000 threads 2.35 ms 4.69 ms 1.99x 2.16 ms 4.78 ms 2.21x
thread/list, filtered 6000 2.38 ms 6.12 ms 2.57x 2.11 ms 6.04 ms 2.86x
thread/list, one parent 1.04 ms 3.60 ms 3.46x Not comparable1
thread/list, scan and repair 68.51 ms 204.62 ms 2.99x 69.19 ms 214.40 ms 3.10x
thread/resume, cold 57.15 ms 78.15 ms 1.37x 54.59 ms 74.90 ms 1.37x
thread/resume, hot-equivalent 22.82 ms 33.26 ms 1.46x 22.37 ms 32.25 ms 1.44x
thread/resume, exclude turns 56.02 ms 135.15 ms 2.41x 55.65 ms 130.63 ms 2.35x

What each row measures

  • thread/list, 100 threads: This case lists 50 matching CLI or VS Code threads from a state database containing 100 seeded threads, with a working-directory filter and useStateDbOnly=true, and validates the exact returned IDs and order.
  • thread/list, 6000 threads: This case lists the first 50 matching CLI or VS Code threads from a 6000-thread state database without a working-directory filter, using useStateDbOnly=true and validating the exact IDs and descending update order.
  • thread/list, filtered 6000: This case lists from the same 6000-thread database with model-provider, source-kind, and working-directory filters applied, then validates that the exact filtered IDs are returned in the expected order.
  • thread/list, one parent: This case requests only subAgentThreadSpawn threads belonging to one selected parent from the 6000-thread database, sorts them by creation time, and validates the exact child set and order.
  • thread/list, scan and repair: This case removes eight expected rows from the 6000-thread state database, calls thread/list with scan-and-repair enabled, and validates both the returned list and restoration of all eight rows from rollout JSONL metadata.
  • thread/resume, cold: This case starts a fresh app-server over a freshly copied Codex home, resumes a 2400-line rollout with turns included, and validates that the complete reconstructed turn history is returned.
  • thread/resume, hot-equivalent: This case immediately repeats the same full-history resume on the already running app-server after the cold request and validates the same complete turn history.
  • thread/resume, exclude turns: This case starts a fresh app-server over a freshly copied Codex home, resumes a 10000-line rollout with excludeTurns=true, and validates that the thread is restored without returning any turns.

Validation

I ran just fmt, CARGO_INCREMENTAL=0 just fix -p codex-app-server -p codex-core -p codex-rollout -p codex-state -p codex-thread-store, CARGO_INCREMENTAL=0 just test -p codex-app-server --test all thread_list, CARGO_INCREMENTAL=0 just test -p codex-app-server --test all thread_resume, CARGO_INCREMENTAL=0 just test -p codex-state, CARGO_INCREMENTAL=0 just test -p codex-rollout -p codex-thread-store, and CARGO_INCREMENTAL=0 just test -p codex-core --lib locally.

Footnotes

  1. The stable app's older 0.140.0-alpha.2 backend does not support the current experimental parentThreadId filtering behavior, so this row cannot be compared correctly against that binary.

@anaiskillian anaiskillian marked this pull request as ready for review June 17, 2026 23:29
@anaiskillian anaiskillian requested a review from a team as a code owner June 17, 2026 23:29
@anaiskillian

Copy link
Copy Markdown
Author

@codex review

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

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 135772bf29

ℹ️ 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 thread codex-rs/rollout/src/recorder.rs Outdated
Comment thread codex-rs/rollout/src/recorder.rs Outdated
@anaiskillian

Copy link
Copy Markdown
Author

@codex review

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

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4969665c0

ℹ️ 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 thread codex-rs/state/src/model/thread_metadata.rs
Comment thread codex-rs/core/src/session/session.rs
Comment thread codex-rs/app-server/src/request_processors/thread_processor.rs Outdated
Comment thread codex-rs/app-server/src/request_processors/thread_processor.rs Outdated
@anaiskillian anaiskillian force-pushed the anais/create-rpc-improvement-codex-app branch from a496966 to ce3329b Compare June 18, 2026 20:39
if items.is_empty() {
return Ok(());
}
if !canonical_items.is_empty() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This reorders history repair after explicit metadata writes... thread/resume -> thread/name/set -> first turn now overwrites SQLite’s chosen title with the history-derived first-message title

}
}

let metadata_by_id = match ctx.get_threads(&thread_ids).await {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This makes read-repair use a page-wide snapshot of full rows. It means a live metadata update after get_threads for example can be overwritten when a later path/cwd/... repair full-upserts its stale clone

params.parent_thread_id,
params.archived,
params.search_term.as_deref(),
/*validate_rollout_paths*/ false,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Previously we skipped jsonl metadata repair but still called existing_rollout_path and removed rows whose rollout had been deleted. As a best-effort process
This new direct path disables that validation. so thread/list can return sessions that immediately fail thread/read or resume or so

@jif-oai

jif-oai commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

IMO those comments are more symptoms than isolated bugs. Please do not hack-fix

@anaiskillian

Copy link
Copy Markdown
Author

replaced by three reviewable PRs:

this split addresses the review feedback at the ownership boundaries instead of patching each symptom independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants