Skip to content

js_repl: remove codex.state helper references#12275

Merged
fjord-oai merged 1 commit intomainfrom
fjord/js_repl_seq---4ht5fx8yw23p4e
Feb 20, 2026
Merged

js_repl: remove codex.state helper references#12275
fjord-oai merged 1 commit intomainfrom
fjord/js_repl_seq---4ht5fx8yw23p4e

Conversation

@fjord-oai
Copy link
Contributor

@fjord-oai fjord-oai commented Feb 19, 2026

Summary

This PR removes codex.state from the js_repl helper surface and removes all corresponding documentation/instruction references.

Motivation

Top-level bindings in js_repl now persist across cells, so the extra codex.state helper is redundant and adds unnecessary API/docs surface.

Changes

  • Removed the long-lived state object from the Node kernel helper wiring.
  • Stopped exposing codex.state (and context.state) during js_repl execution.
  • Updated user-facing js_repl docs to remove codex.state.
  • Updated generated instruction text and related test expectations to list only:
    • codex.tmpDir
    • codex.tool(name, args?)

git stack

@fjord-oai fjord-oai force-pushed the fjord/js_repl_seq---4ht5fx8yw23p4e branch 4 times, most recently from 09f02d7 to aa9752f Compare February 20, 2026 06:19
@fjord-oai fjord-oai changed the base branch from main to fjord/js_repl_seq---4ht_g82psfv2f9 February 20, 2026 06:19
@fjord-oai fjord-oai changed the base branch from fjord/js_repl_seq---4ht_g82psfv2f9 to main February 20, 2026 06:19
@fjord-oai fjord-oai force-pushed the fjord/js_repl_seq---4ht5fx8yw23p4e branch from aa9752f to 6a126ca Compare February 20, 2026 06:19
@fjord-oai fjord-oai changed the base branch from main to fjord/js_repl_seq---4ht_g82psfv2f9 February 20, 2026 06:19
@fjord-oai fjord-oai changed the base branch from fjord/js_repl_seq---4ht_g82psfv2f9 to main February 20, 2026 06:31
@fjord-oai fjord-oai force-pushed the fjord/js_repl_seq---4ht5fx8yw23p4e branch from 6a126ca to ce9b946 Compare February 20, 2026 06:31
@fjord-oai fjord-oai changed the base branch from main to fjord/js_repl_seq---4ht_g82psfv2f9 February 20, 2026 06:31
@fjord-oai fjord-oai changed the base branch from fjord/js_repl_seq---4ht_g82psfv2f9 to main February 20, 2026 15:48
@fjord-oai fjord-oai force-pushed the fjord/js_repl_seq---4ht5fx8yw23p4e branch from ce9b946 to 9fea5de Compare February 20, 2026 15:48
@fjord-oai fjord-oai changed the base branch from main to fjord/js_repl_seq---4ht_g82psfv2f9 February 20, 2026 15:48
fjord-oai added a commit that referenced this pull request Feb 20, 2026
## Summary

Tighten the `js_repl` freeform Lark grammar to block the most common
malformed payload wrappers before they reach runtime validation.

## What Changed

- Replaced the overly permissive `js_repl` freeform grammar (`start:
/[\s\S]*/`) with a structured grammar that still supports:
  - plain JS source
  - optional first-line `// codex-js-repl:` pragma followed by JS source
- Added grammar-level filtering for common bad payload shapes by
rejecting inputs whose first significant token starts with:
  - `{` (JSON object wrapper like `{"code":"..."}`)
  - `"` (quoted code string)
  - `` ``` `` (markdown code fences)
- Implemented the grammar without regex lookahead/lookbehind because the
API-side Lark regex engine does not support look-around.
- Added a unit test to validate the grammar shape and guard against
reintroducing unsupported lookaround.

## Why

`js_repl` is a freeform tool, but the model sometimes emits wrapped
payloads (JSON, quoted strings, markdown fences) instead of raw
JavaScript. We already reject those at runtime, but this change moves
the constraint into the tool grammar so the model is less likely to
generate invalid tool-call payloads in the first place.

## Testing

- `cargo test -p codex-core
js_repl_freeform_grammar_blocks_common_non_js_prefixes`
- `cargo test -p codex-core parse_freeform_args_rejects_`

## Notes

- This intentionally over-blocks a few uncommon valid JS starts (for
example top-level `{ ... }` blocks or top-level quoted directives like
`"use strict";`) in exchange for preventing the common wrapped-payload
mistakes.



#### [git stack](https://github.com/magus/git-stack-cli)
- 👉 `1` #12300
- ⏳ `2` #12275
- ⏳ `3` #12205
- ⏳ `4` #12185
- ⏳ `5` #10673
Base automatically changed from fjord/js_repl_seq---4ht_g82psfv2f9 to main February 20, 2026 18:47
git-stack-id: fjord/js_repl_seq---4ht5fx8yw23p4e
git-stack-title: js_repl: remove codex.state helper references
@fjord-oai fjord-oai force-pushed the fjord/js_repl_seq---4ht5fx8yw23p4e branch from 9fea5de to 71bdc9d Compare February 20, 2026 18:48
@fjord-oai fjord-oai merged commit 0976202 into main Feb 20, 2026
58 of 61 checks passed
@fjord-oai fjord-oai deleted the fjord/js_repl_seq---4ht5fx8yw23p4e branch February 20, 2026 19:20
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 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

Comments