Skip to content

Persist js_repl codex helpers across cells#14503

Merged
fjord-oai merged 1 commit intomainfrom
fjord/codex_js_persist
Mar 12, 2026
Merged

Persist js_repl codex helpers across cells#14503
fjord-oai merged 1 commit intomainfrom
fjord/codex_js_persist

Conversation

@fjord-oai
Copy link
Copy Markdown
Contributor

@fjord-oai fjord-oai commented Mar 12, 2026

Summary

This changes js_repl so saved references to codex.tool(...) and codex.emitImage(...) keep working across cells.

Previously, those helpers were recreated per exec and captured that exec's message.id. If a persisted object or saved closure reused an old helper in a later cell, the nested tool/image call could fail with js_repl exec context not found.

This patch:

  • keeps stable codex.tool and codex.emitImage helper identities in the kernel
  • resolves the current exec dynamically at call time using AsyncLocalStorage
  • adds regression coverage for persisted helper references across cells
  • updates the js_repl docs and project-doc instructions to describe the new behavior and its limits

Why

We already support persistent top-level bindings across js_repl cells, so persisted objects should be able to reuse codex helpers in later active cells. The bug was that helper identity was exec-scoped, not kernel-scoped.

Using AsyncLocalStorage fixes the cross-cell reuse case without falling back to a single global active exec that could accidentally attribute stale background callbacks to the wrong cell.

@fjord-oai
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ 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".

@fjord-oai fjord-oai force-pushed the fjord/codex_js_persist branch from 705de5d to ebba0c4 Compare March 12, 2026 21:53
@fjord-oai fjord-oai marked this pull request as ready for review March 12, 2026 21:57
@fjord-oai fjord-oai merged commit b560494 into main Mar 12, 2026
52 of 54 checks passed
@fjord-oai fjord-oai deleted the fjord/codex_js_persist branch March 12, 2026 22:41
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants