Skip to content

Surface Codex hook activation failures and accept null feature values - #339

Merged
Abhijeet Prasad (AbhiPrasad) merged 4 commits into
mainfrom
abhi/sdk-992-bt-codex-hook-activation-rejects-null-feature
Nov 25, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 4 commits into
mainfrom
abhi/sdk-992-bt-codex-hook-activation-rejects-null-feature

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Fixes SDK-992 and SDK-990. Both show up as the same unexplained Codex plugin installed, but hook activation failed, but they have different causes.

SDK-992: null feature values

Codex 0.172.0's config/read returns features.network_proxy = null. Config.features was a BTreeMap<String, bool>, so deserialization failed before bt checked the plugin or the hooks. features now models only the typed hooks/codex_hooks toggles as optional booleans, and Serde skips every other feature entry.

SDK-990: hidden errors

  • The activation error now puts the cause chain in its top-level message, because bt prints only that line.
  • Both app-server probes (activate and run_trust_override) now capture the last 4 KiB of Codex's stderr and add it to the error. Before, stderr was Stdio::null(). The pipe is drained continuously, so Codex can't block on a full stderr buffer. An older Codex that rejects --no-daemon now produces:
Codex plugin installed, but hook activation failed: Codex closed the probe stream
Codex stderr:
error: unexpected argument '--no-daemon' found

Preventing a repeat

  • Contract test in CI: codex_hooks::tests::activation_succeeds_against_real_codex installs the plugin into an isolated CODEX_HOME and requires activate() to fully succeed against a real Codex. CI runs it in the daemon job against the latest Codex on Linux, macOS, and Windows. It needs no credentials and takes about 1.5 s. On main it fails with the SDK-992 error. activate() now delegates to activate_with(command) so the test can choose the binary and home.
  • AGENTS.md: for agent-owned responses and config, model only the fields we read and never use a closed type like BTreeMap<String, bool>.
  • add-coding-agent-setup skill: surface agent errors and stderr, and add a real-agent contract test for setup protocols.

Tests

  • A table test for config: null/nested unrelated features, null or missing features, and hooks: false / codex_hooks: false.
  • Stderr tail truncation at 4 KiB.
  • Unix end-to-end test: a fake codex script that rejects --no-daemon makes run_trust_override report its stderr.

Manually ran activate() against real Codex binaries, using an isolated empty CODEX_HOME:

Codex main this PR
0.172.0 hook activation failed: invalid Codex result: invalid type: null, expected a boolean gets past config/read and stops at the expected plugin is not installed and enabled check
0.140.0 (npm) hook activation failed: Codex closed the probe stream same, plus Codex stderr: error: unexpected argument '--no-daemon' found ...

A default 0.172.0 config already reports features.network_proxy = null, so every 0.172.0 user hits SDK-992.

Codex 0.172.0 returns `features.network_proxy = null` from `config/read`,
which failed to deserialize into `BTreeMap<String, bool>` and aborted hook
activation. Only the `hooks`/`codex_hooks` toggles are now interpreted.

Activation errors now inline their cause chain, and both app-server probes
capture the tail of Codex's stderr so failures such as an older Codex
rejecting `--no-daemon` explain themselves instead of reporting only the
generic activation message.

Fixes SDK-992
Fixes SDK-990
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T16:18:16.188536Z b59865a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

let disabled = |key| self.features.get(key) == Some(&Value::Bool(false));
!disabled("hooks") && !disabled("codex_hooks")

P1 Badge Keep known Codex hook flags in a typed configuration schema

The root AGENTS.md explicitly prohibits storing known configuration fields and flags as serde_json::Value or reading them through string-keyed .get(), but this change introduces both for hooks and codex_hooks. Supporting null or nested values in unrelated features does not require abandoning typed hook flags: model the optional features object and its optional boolean hook fields, letting Serde ignore unrelated entries. This preserves the compatibility fix while respecting the repository's required schema boundary.

AGENTS.md reference: AGENTS.md:L46-L53

ℹ️ 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 (@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 (@codex) address that feedback".

Per AGENTS.md, known config fields must not be read from serde_json::Value.
Unrelated feature entries are skipped by Serde instead.
@AbhiPrasad

Copy link
Copy Markdown
Member Author

Addressed in 106f9a7: Config.features is now an optional typed struct with hooks/codex_hooks: Option<bool>. Serde skips unrelated entries such as network_proxy: null, so nothing reads through serde_json::Value. Re-verified against real Codex 0.172.0.

@Qard Stephen Belanger (Qard) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, but CI failures need addressing.

Hook activation (`bt trace install/update codex`) was never exercised
against a real Codex, so Codex 0.172.0's `features.network_proxy = null`
reached users. The new ignored test installs the plugin into an isolated
CODEX_HOME and requires full activation; CI runs it against the latest
Codex on Linux, macOS, and Windows. It fails on main with the SDK-992 error.

Also record the lesson in AGENTS.md (model only the agent-owned fields we
read) and the add-coding-agent-setup skill (surface agent errors; add a
real-agent contract test for setup protocols).
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 7ab47ac into main Nov 25, 2026
23 of 27 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/sdk-992-bt-codex-hook-activation-rejects-null-feature branch November 25, 2026 16:24
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.

2 participants