fix(cron): restore persistent session targets#98947
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 2:47 AM ET / 06:47 UTC. Summary PR surface: Source -34, Tests -63, Docs 0. Total -97 across 17 files. Reproducibility: yes. Source inspection shows PR head still reports isolated run-scoped session keys but gateway cleanup no longer uses them, and task child-session resolution mishandles Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Land the persistent-session restoration only after repairing isolated cleanup and task child-session resolution, while keeping Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows PR head still reports isolated run-scoped session keys but gateway cleanup no longer uses them, and task child-session resolution mishandles Is this the best way to solve the issue? No, not yet. Restoring persistent cron sessions is the right policy direction if maintainers accept the tradeoff, but the branch needs the cleanup and task drill-down repairs before it is the best merge shape. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2913d3aee90c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source -34, Tests -63, Docs 0. Total -97 across 17 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69cb904aac
ℹ️ 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".
| await cleanupBrowserSessionsForLifecycleEnd({ | ||
| sessionKeys: [cleanupSessionKey], | ||
| sessionKeys: [sessionKey], |
There was a problem hiding this comment.
Use actual isolated run session for browser cleanup
When an isolated cron job opens browser tabs, the browser tool tracks them under the run key passed into the agent (agent:<id>:cron:<job>:run:<sessionId>), but this cleanup now always sends the pre-run target key (cron:<jobId>). Since browser cleanup matches exact session keys, isolated cron runs no longer close their tracked tabs at completion; keep using the execution/result session key for isolated runs.
Useful? React with 👍 / 👎.
| if (params.job.sessionTarget !== "isolated") { | ||
| return undefined; |
There was a problem hiding this comment.
Resolve session targets for task drill-down
For jobs created with sessionTarget: "session:<id>" but without a separate sessionKey field (for example CLI --session session:...), this branch returns undefined even though the cron run executes in that persistent session. The task ledger then loses childSessionKey, so task drill-down cannot open the transcript the run actually used; parse the key from sessionTarget before dropping non-isolated jobs.
Useful? React with 👍 / 👎.
Cron jobs run in the session they were created from unless the job explicitly requests an isolated fresh session.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f160075c36
ℹ️ 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".
| const explicitSessionKey = params.job.sessionKey?.trim(); | ||
| if (explicitSessionKey) { | ||
| // Explicit session bindings must win over generated cron session keys so | ||
| // task drill-down opens the same transcript the cron run actually used. | ||
| return explicitSessionKey; |
There was a problem hiding this comment.
Route isolated task drill-down to the cron run
When an isolated cron job also carries a creator sessionKey for delivery context, this early return records the task ledger against that creator chat instead of the isolated cron transcript. The gateway still executes sessionTarget: "isolated" jobs with the generated cron:${job.id} key, so task drill-down for those jobs opens the wrong session and misses the run output; only persistent session:<id> targets should prefer their explicit session binding here.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
Cron jobs run in the session they were created from unless the job explicitly requests an isolated fresh session. Co-authored-by: Peter Steinberger <[email protected]>
Cron jobs run in the session they were created from unless the job explicitly requests an isolated fresh session. Co-authored-by: Peter Steinberger <[email protected]>
Related: #98121
Follow-up to PR #98755. Pinned-base context: PR #98812.
What Problem This Solves
Fixes an issue where users scheduling cron work in
currentorsession:<id>would unexpectedly lose persistent session history because every agent-turn cron target was changed to a detached fresh run. The merged change also caused deterministic session-state and shared run-context failures on exact-head CI.Why This Change Was Made
Cron jobs now follow the clarified product contract: a job normally runs in the session it was created from, while only an explicitly
isolatedjob requests a detached fresh session. This restores the shipped canonical persistence path across target resolution, session identity, storage, prompt caching, run-context ownership, task drill-down, gateway wiring, tests, and docs, while retaining the independently valid stale childless-task cancellation from PR #98755.The approved patch originated as head
69cb904aaceeeb8be8448be7157b16e66e411123, parent27104c1afb13af39e675f637b5812b12a7088ba7, treecdec0b484879ceba63e6542835587e9da60e9f55. The single required main sync produced the textually equivalent headf160075c36e8e1c925e1148236d50492486ecc11, parented directly on main2913d3aee90c79bc420129606b3912662359723d, with tree889530c73c8426dc61d9fd6bcb42e889718547e9. A wrapper-created ancestry-only heada5ddfe7eda69b77cc177f93aa923476f82a7230ewas replaced withf160075c…using an exact force-with-lease. The live PR remains 17 files, +90/-187, with stable patch ID94180b4fcbf752cfa56db33df28bf4620ef633a2and full-index diff SHA-256bf7396ac69911e288ba1e0fd3f20cfee1b19e44e3b35f855cf65bea0a0b751d9.User Impact
Recurring cron workflows can again build on prior context in
currentand namedsession:<id>sessions.isolatedjobs remain fresh and detached, and main-session cron behavior is unchanged.Evidence
v24.13.0Testbox: 323/323 tests passed; wrapper exit0.check:changed: both core typechecks, all core lint shards, import-cycle checks, and repository guards passed; wrapper exit0.oxfmt --checkpassed for all 17 files; scoped Oxlint,pnpm docs:list, andgit diff --checkpassed.gpt-5.6-solxhigh autoreview reported zero findings with correctness confidence0.97.f160075c36e8e1c925e1148236d50492486ecc11has parent2913d3aee90c79bc420129606b3912662359723dand tree889530c73c8426dc61d9fd6bcb42e889718547e9; its patch ID and full-index diff digest exactly match the approved pre-sync patch.Contributor credit: Ethan Sarif-Kattan (
@EthanSK) supplied the original report and discussion in issue #98121. Ayaan Zaidi (@obviyus) authored PR #98755, including the stale childless-task cancellation retained here.AI-assisted: yes, prepared and independently reviewed with Codex under Peter Steinberger's explicit product-contract and landing approval.