Repository navigation
test(e2e): run real Codex with the PowerContext plugin against a Server in CI - #2624
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
hidb4ai
left a comment
There was a problem hiding this comment.
The new host test still races MCP discovery on Linux, and the Responses fixture has a reproducible pending-call replay error. Details are inline. Full tool-chain acceptance remains unverified: making MCP required in a disposable startup probe got the initial approval-denial step through, but the resumed search_memory call then returned HTTP 422 (invalid_access_request).
The Responses fake repeats a call whose result the host has not returned yet, at the address it first issued. `setdefault` still evaluated the lookup in the request's own tool list, so a repeat in a request that offered no tools raised KeyError and the fake answered 500. Look the address up only for a new call.
The plugin's MCP server is optional, and Codex lists a session's first tools after a one-second grace whether or not it has connected. On a slow runner the first scripted tool call then finds no PowerContext tools. Set mcp_optional_startup_grace_ms = 0 so Codex waits for the server, up to its startup timeout, before the first model request.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed at f7332c8. Both previous findings are fixed. The real Codex flow now completes approval, session-scope binding, Memory writes and search on Linux with Codex 0.167.2, Python 3.12, SQLite and fixture models. The change remains confined to tests and CI.
Which issue or RFC does this PR close?
No tracking issue. It follows the real-host service chains for Pi (#2531) and OpenCode (#2533). Codex was covered only by calling the plugin's hook scripts directly, so regressions that depend on what Codex itself sends, such as #2287 (fork SessionStart), only surfaced with a manual run.
Rationale for this change
tests/e2e/test_codex_service_chain.pyandtests/codex_plugin/invokerecall.py,session_binding.pyandbind_tools.pywith hand-built payloads. They cannot catch changes in Codex's hook payloads, in when Codex runs each hook, in how it offers and approves MCP tools, or in hook trust. This PR runs the realcodex execagainst an in-process Server, installed and trusted the way a user does it.What changes are included in this PR?
tests/e2e/test_codex_host_service_chain.pyruns Codex CLI 0.167.2 (CODEX_CLI_BIN) with an isolatedHOME,CODEX_HOMEand XDG directories. InheritedPOWERCONTEXT_*,CODEX_*,OPENAI_*and proxy variables are dropped.powercontext setup codexfrom this checkout, which also saves the Server credential and the MCP header helper.codex execruns withoutPOWERCONTEXT_CODEX_AUTHORIZATION, so hooks and MCP use the saved credential.hooks/list, thenconfig/batchWriteofhooks.state), the calls the TUI's/hooksreview makes.startup,resume,startup.POWERCONTEXT_CODEX_BOOTSTRAP_CONTEXT=true, tagged bootstrap Memory precedes the first prompt once, the receipt is recorded asinjected, and the turn's preparation carries the receipt and does not repeat it. Without the setting, only prompt-time recall supplies it.remember_memorycall is refused bycodex execuntil the tool is approved in the Codex configuration. After approval it writes to the session's Scope although the model names another Scope, andsearch_memoryfinds it.POWERCONTEXT_CODEX_PROMPT_RECALLandPOWERCONTEXT_CODEX_CAPTURE_PROMPTSact independently.tests/e2e/host_models/holds a wire-neutralScriptedTurnsscript and a streamed/v1/responsesfake (ResponsesModelFixture). Codex 0.167 accepts onlywire_api = "responses"for a custom provider and offers MCP tools as amcp__powercontextnamespace tool. A Messages API fake can sit beside it.zcode_acceptance/protocol.pyis unchanged; itsHostModelFixturestill serves the Server's generation model.codex-hostjob inmaster.ymlinstalls@openai/codex@0.167.2from npm, checkscodex --version, refuses to run without the binary, runs the cases and uploadscodex.logon failure..github/ci-paths.tomladds acodexsuite for the Codex plugin, the new test and fixtures, and the shared ZCode wire fixtures, and adds it to the shared runtime consumers.tests/test_ci_changes.pycovers the new rows.Are there any user-facing changes?
No. This PR changes tests and CI only.
Observations from the real host, not changed here:
PreToolUsehook answersallow. Undercodex execwithapproval_policy = "never"the call fails. The Codex integration docs do not mention this.required: false). Setup could build that environment at install time; that would be a separate change.How was this change tested?
CODEX_CLI_BIN=<codex 0.167.2> uv run pytest tests/e2e/test_codex_host_service_chain.pyon macOS (arm64): 5 passed in about 26 s, also three times in a row with-n 5. WithoutCODEX_CLI_BINthe cases skip.Each mutation below was applied, the cases were run, and the change was reverted:
additionalContextPOWERCONTEXT_CODEX_PROMPT_RECALLPOWERCONTEXT_CODEX_CAPTURE_PROMPTSPreToolUsekeeps the model'sscope_idresumeremember_memoryread-only (no approval needed)http_headers_helpermake check;uv run pytest tests/test_ci_changes.py tests/test_ci_pipeline.py.The
codex-hostjob itself has not run yet; the npm install path is first exercised by this PR's CI.A self-review (code-review, high) found six issues. Five are fixed: a timed-out
codex execlost its output, the fake failed on a repeated call in a request without tools, the credential check skipped incomplete requests, a malformed event line crashed parsing, and a dead thread-id fallback hid a missingthread.started. Not changed: the Scope and flush helpers repeat the OpenCode test's; sharing them would touch that test.AI usage statement
Claude Code (Claude Opus 5.5) wrote the test, the model fake, the CI wiring and this description, and ran the local verification.