Skip to content

fix: skip load for pristine sessions#172

Closed
lynnzc wants to merge 2 commits intoopenclaw:mainfrom
lynnzc:fix/issue-165-pristine-session-load
Closed

fix: skip load for pristine sessions#172
lynnzc wants to merge 2 commits intoopenclaw:mainfrom
lynnzc:fix/issue-165-pristine-session-load

Conversation

@lynnzc
Copy link
Copy Markdown
Contributor

@lynnzc lynnzc commented Mar 23, 2026

Summary

  • skip session/load for pristine saved sessions that have no turns yet and only need a fresh ACP session
  • keep existing resume behavior for sessions with history, explicit mode state, or config replay needs
  • add a regression test covering the pristine-session fast path

Why

Issue #165 reports a large delay before the first streamed text event on codex prompt --session compared with codex exec.

For freshly ensured sessions with no prior turns, acpx was still attempting session/load before the first prompt. On Codex, that extra resume path appears to be the wrong fit for a pristine session and can delay the first streamed output. This change sends those pristine sessions straight to session/new instead.

Fixes #165.

Validation

  • pnpm run build
  • pnpm run build:test
  • node --test dist-test/test/connect-load.test.js
  • node --test dist-test/test/prompt-runner.test.js

@osolmaz
Copy link
Copy Markdown
Contributor

osolmaz commented Mar 28, 2026

Triage result

  • Solves the right problem: 🛑 Localized, bad, or unclear fix
  • Close PR: 🛑 Yes
  • Recommendation: 🏁 close PR

Quick read

This PR targets the right symptom from #165, but the current solution is not safe enough to continue. The new "pristine session" heuristic relies only on locally persisted state, so it can misclassify a legitimately resumed ACP session as disposable and replace it with a fresh one.

Intent

The intent here is to avoid an unnecessary session/load for freshly ensured, still-unused sessions so the first streamed output is not delayed by the slow resume path.

Why

The problem is that the heuristic is too local.

  • src/session-runtime/connect-load.ts now bypasses session/load whenever the saved record has no local messages, no lastPromptAt, no current_mode_id, and no config_options.
  • src/session-runtime.ts creates records for sessions new --resume-session and sessions ensure --resume-session with exactly that same empty local shape.
  • That means a real remote ACP session resumed via --resume-session can later be treated as "pristine" after the original process exits, even though the remote ACP session may still contain real state that should be loaded.
  • The added tests cover the new fast path and warmed resumed sessions, but there is no regression test for prompting a session created via --resume-session after reconnect.

Codex review

Not run in this step. This was a read-only triage judgment.

CI/CD

Not run in this step. Validation and CI are intentionally deferred by the flow.

Recommendation

Close this PR. A follow-up should distinguish "fresh local wrapper around a brand-new ACP session" from "empty local record that points at a resumed remote ACP session", and it should add a regression test covering prompt/reconnect behavior for sessions created via --resume-session.

@osolmaz
Copy link
Copy Markdown
Contributor

osolmaz commented Mar 28, 2026

Closed by automated triage.

@osolmaz osolmaz closed this Mar 28, 2026
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.

codex prompt --session delays first text event by ~190s on a prompt where codex exec completes in ~208s

2 participants