Skip to content

perf(codex): opt out of unconsumed app-server notifications - #151990

Closed
steipete wants to merge 1 commit into
mainfrom
steipete/perf-codex-appserver-notification-optout-20260918
Closed

steipete wants to merge 1 commit into
mainfrom
steipete/perf-codex-appserver-notification-optout-20260918

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Gateway decodes Codex app-server notifications for features it does not consume while handling concurrent streaming turns.

User Impact

New app-server connections ask stock Codex to suppress 34 unused notification methods. Streaming, native execution, usage, approvals, subagent receipts, and session observations keep their existing events.

Measured benefit is small: the representative fixture removes one 218-byte startup notification (0.24% of notification bytes). It does not demonstrate a material steady-state CPU reduction or solve the dominant parsing cost. The list adds 1,005 bytes to the initialize request once per connection; this fixture does not show a total bidirectional traffic saving.

Why This Change Was Made

The connection owner sends optOutNotificationMethods during initialize; previously it requested no exclusions. Connection initialization and version validation now live in client-initialize.ts, keeping the existing oversized transport owner from growing. The list sits beside the initialize call, based on the pinned 0.154.0 protocol and every plugin notification subscriber. No local drop filter or stock Codex modification is needed. Servers that ignore the request continue through the normal decoder and dispatcher.

Update behavior: no update-path, configuration, schema, or state change. Negotiation occurs per new app-server connection. Both the minimum supported 0.149.0 and pinned 0.154.0 derive Serde Deserialize for capabilities without deny_unknown_fields (unknown fields are ignored; optional fields default to None, booleans use #[serde(default)]). Both already define this capability. The pinned binary also accepted an extra unknown capability in the live handshake. This does not broaden the supported-version floor.

Protocol evidence personally inspected in sibling Codex source at dcfcb570b2cd0a2500b1d47a7b04a7cb1b0a0bd2: codex-rs/app-server-protocol/src/protocol/v1.rs:43–65, app-server/src/request_processors/initialize_processor.rs:70–100, app-server/src/transport.rs:100–121, and app-server-protocol/src/protocol/common.rs:1841+. Exact pinned release sources confirm capability/deserialization, connection negotiation, and exact-name filtering. Minimum-version capabilities have the same permissive contract.

Dispatch audit for every exclusion

Paths below are relative to extensions/codex/src/; line references describe the pre-change dispatch source. The pinned protocol contains 83 methods: 34 excluded, 49 retained.

Excluded methods Why no Gateway consumer depends on them
account/login/completed, app/list/updated Account listeners use account/updated (command-plugins-runtime.ts:148, app-server/inference-routing.ts:50, app-server/client.ts:949); rate limits use client-runtime.ts:265. No subscriber handles these two.
command/exec/outputDelta, process/outputDelta, process/exited app-server/remote-workspace-media.ts:127,164 consumes the final command/exec response, not stream notifications. client.ts:851 records native execution on the request. sandbox-exec-server/processes.ts:227 emits a same-named message on a separate protocol; it is not an app-server consumer.
mcpServer/event/stream/notification, mcpServer/oauthLogin/completed, mcpServer/startupStatus/updated MCP lifecycle and receipts consume item/raw/turn events (app-server/event-projector-native-tool-lifecycle.ts:173–230); no subscriber consumes these three.
thread/goal/cleared, thread/queue/changed, project/changed, thread/project/updated, thread/environment/connected, thread/environment/disconnected Neither the catalog allowlist (session-catalog-events.ts:43–54,138) nor native monitor allowlist (app-server/native-subagent-monitor.ts:78–90,214) includes them. Their protocol payloads have no turn ID, so they do not drive turn progress.
thread/realtime/closed, thread/realtime/error, thread/realtime/item/completed, thread/realtime/item/started, thread/realtime/item/transcript/delta, thread/realtime/itemAdded, thread/realtime/outputAudio/delta, thread/realtime/sdp, thread/realtime/started, thread/realtime/transcript/delta, thread/realtime/transcript/done There is no realtime request caller or notification consumer. These envelopes have thread IDs but no turn IDs (codex-rs/app-server-protocol/src/protocol/v2/realtime.rs:375+); the projector rejects them at app-server/event-projector.ts:148, and the catalog/monitor allowlists reject them.
deprecationNotice, externalAgentConfig/import/completed, externalAgentConfig/import/progress, fs/changed, fuzzyFileSearch/sessionCompleted, fuzzyFileSearch/sessionUpdated, remoteControl/status/changed, windows/worldWritableWarning, windowsSandbox/setupCompleted No production dispatch site handles them. The router broadcasts only unscoped warning and configWarning (app-server/turn-router.ts:423–440), then drops notifications without a thread route (:443–447).

Preserved even without explicit method dispatch: thread/goal/updated, modelProvider/authRecoveryStarted, and modelProvider/authRecoveryCompleted carry turn IDs and therefore refresh run progress/native hook relay lifetime (run-attempt-notification-controller.ts:111–117, run-attempt-turn-state.ts:150–167). All explicit projector cases remain, including no-op cases at event-projector.ts:253–263. Both raw response methods remain for usage, native subagent delivery receipts, tool ordering, and abort markers. Future consumers must remove their method from the exclusion list.

Evidence

Before changing production code, a real local stock @openai/codex 0.154.0 app-server ran one representative turn against a loopback Responses API fixture. It streamed 71 assistant text chunks, 44 reasoning-summary chunks, 44 reasoning-text chunks, and executed a harmless command with two streamed output chunks and exit code 0. The model side was deterministic SSE; zero paid model calls. One turn uses two fixture Responses requests because the command result is followed by the assistant answer. The protocol client support was inspected and used for the unit proof (createClientHarness); the real binary probe follows Codex's own mock Responses fixture contract.

Bytes are UTF-8 stdout notification line bytes including LF, from initialize through turn completion; RPC responses and stderr are excluded. This is a synthetic workload, not a production distribution or CPU benchmark. Raw captures stay local and are not included in this PR. Dispatch paths in the table are relative to extensions/codex/src/app-server/, at the pre-change revision.

Method Lines Bytes Share Gateway consumer / dispatch site
rawResponseItem/completed 7 44,312 48.11% Yes — event-projector.ts:224, native-subagent-notification.ts:43,116, attempt-notifications.ts:65,85,156
item/agentMessage/delta 71 15,194 16.50% Yes — event-projector.ts:161, native-subagent-monitor.ts:78
item/reasoning/summaryTextDelta 44 10,648 11.56% Yes — event-projector.ts:167, native-subagent-monitor.ts:78
item/reasoning/textDelta 44 10,340 11.23% Yes — event-projector.ts:168
item/completed 4 3,646 3.96% Yes — event-projector.ts:181, client-runtime.ts:252
item/started 4 1,689 1.83% Yes — event-projector.ts:178, attempt-notifications.ts:18
turn/completed 1 1,269 1.38% Yes — event-projector.ts:218, turn-router.ts:450
thread/started 1 1,259 1.37% Yes — ../session-catalog-events.ts:43, native-subagent-monitor.ts:78
thread/tokenUsage/updated 2 992 1.08% Yes — event-projector.ts:203
rawResponse/completed 2 872 0.95% Yes — event-projector.ts:221, ephemeral-turn.ts:57
account/rateLimits/updated 2 586 0.64% Yes — client-runtime.ts:265
item/commandExecution/outputDelta 2 462 0.50% Yes — event-projector.ts:184, client.ts:937
thread/status/changed 2 317 0.34% Yes — ../session-catalog-events.ts:43, native-subagent-monitor.ts:78
turn/started 1 298 0.32% Yes — turn-router.ts:459, native-subagent-monitor.ts:78
remoteControl/status/changed 1 218 0.24% No — no consumer; unscoped notification rejected by turn-router.ts:423–447
Total 188 92,102 100%

With the capability enabled, the same fixture yielded 187 notifications / 91,883 bytes. remoteControl/status/changed disappeared; every consumed method retained its count, and assistant/reasoning/command output and completion assertions passed. The direct excluded-byte saving is 218 bytes; the remaining one-byte total difference is variable payload length. This event is startup-scoped, so no per-turn saving is established.

Consumed deltas account for 39.8% of baseline bytes; consumed raw-response items account for 48.1%. Most bytes belong to consumed raw items and deltas. No decoder change or speculative Buffer splitter is included; multiline recovery remains untouched.

Validation:

  • Regression first, on the original production code: client.test.ts initialize negotiation failed because optOutNotificationMethods was absent (1 failed, 1 passed, 54 skipped). The server-ignores-capability case passed.
  • After the change: ten client*.test.ts suites, including the unchanged multiline decoder suite, passed 176/176 tests through node scripts/run-vitest.mjs. The initialize regression and ignored-capability case both passed.
  • Independent Codex autoreview: scoped-clean through P2, no findings.
  • The initial line-cap growth failure (1,013 → 1,049 counted lines, cap 700) was resolved by extracting connection initialization and version validation; no baseline, budget, suppression, snapshot, or coverage exception was changed.
  • node scripts/check-changed.mjs: passed, including both extension typechecks, lint, all selected guards, six doctor contract tests, and zero runtime value import cycles.
  • git diff --check: passed.

No production Gateway, update mechanism, session projection, config option, or stock Codex binary was changed. No production CPU reprofiling or paid inference turn was performed.

Negotiate the audited unused notification set per connection while preserving streaming, turn liveness, usage, and native receipts. Keep initialization policy and version validation together outside the oversized transport client.

A stock 0.154.0 synthetic probe removed one 218-byte startup notification (0.24% of notification bytes); no steady-state CPU reduction is established. No config, state, schema, or update-path change.
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: M maintainer Maintainer-authored PR labels Sep 18, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 18, 2026, 1:29 PM ET / 17:29 UTC.

ClawSweeper review

What this changes

The Codex plugin requests suppression of 34 unused app-server notifications, extracts connection initialization, and adds compatibility coverage and documentation.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open. No blocking defect was found, and current main lacks this optimization. The overlapping same-author draft at #151998 does not establish supersession.

Priority: P3
Reviewed head: 341a52bf41963bab41fbaaafe98b6f8230f2f5f9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, compatible patch with useful consumer auditing and appropriately limited performance claims.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER author status exempts ordinary contributor proof. Supplemental evidence reports stock Codex filtering the requested startup event while preserving streaming and command completion; client tests cover the actual OpenClaw handshake and ignored-capability fallback.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER author status exempts ordinary contributor proof. Supplemental evidence reports stock Codex filtering the requested startup event while preserving streaming and command completion; client tests cover the actual OpenClaw handshake and ignored-capability fallback.
Evidence reviewed 9 items Introduced change and merge scope: The pinned introduction contains only initialization, client tests, and harness documentation. The test merge has the recorded base followed by the exact PR head as parents, and its comparison against that base contains the same four paths. Whitespace validation passed; the checkout remained clean.
Current main still lacks negotiation: The current-main initialize request enables experimental APIs and extensions but supplies no notification opt-outs. The extraction preserves version validation and runtime identity behavior.
Latest-release comparison: The client source at the supplied latest release, v2026.9.4, also initializes without optOutNotificationMethods. The release source was read through GitHub after its local blob was unavailable.
Findings None None.
Security None None.

How this fits together

The Codex plugin connects OpenClaw agent turns to the Codex app-server. Its notification dispatcher feeds streaming output, turn progress, session observations, and native subagent receipts back into OpenClaw.

flowchart LR
  A[New Codex connection] --> B[Initialize capabilities]
  B --> C[Codex notification filter]
  C --> D[Unused events suppressed]
  C --> E[OpenClaw dispatcher]
  E --> F[Streaming and turn progress]
  E --> G[Sessions and subagent receipts]
Loading

Before merge

  • Resolve merge risk (P1) - Production CPU benefit remains unmeasured; the reported fixture establishes only a small startup-notification reduction.
Agent review details

Security

None.

PR surface

Source +51, Tests +64, Docs +10. Total +125 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 145 94 +51
Tests 1 64 0 +64
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 219 94 +125

Review metrics

Metric Value Why it matters
Measured traffic tradeoff 218 startup bytes suppressed; 1,005 initialize bytes added The reported fixture supports notification suppression but does not demonstrate total traffic savings or steady-state CPU improvement.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep notification suppression in the existing connection handshake, preserve all consumed and liveness events, and describe the benefit within the measured limits.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep notification suppression in the existing connection handshake, preserve all consumed and liveness events, and describe the benefit within the measured limits.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction: this is an optimization. Source confirms the omitted capability on main, and the body reports a real-binary before/after comparison; no runtime checks were executed during this read-only review.

Is this the best way to solve the issue?

Yes, for suppressing unused notifications: existing Codex negotiation avoids a second local filtering owner and preserves compatibility. The evidence does not establish a material performance improvement.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 861e65d8c9fb.

Labels

Label changes:

  • add P3: This is a bounded internal optimization with a small demonstrated benefit and no established urgent user-facing failure.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author status exempts ordinary contributor proof. Supplemental evidence reports stock Codex filtering the requested startup event while preserving streaming and command completion; client tests cover the actual OpenClaw handshake and ignored-capability fallback.

Label justifications:

  • P3: This is a bounded internal optimization with a small demonstrated benefit and no established urgent user-facing failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author status exempts ordinary contributor proof. Supplemental evidence reports stock Codex filtering the requested startup event while preserving streaming and command completion; client tests cover the actual OpenClaw handshake and ignored-capability fallback.

Evidence

What I checked:

  • Introduced change and merge scope: The pinned introduction contains only initialization, client tests, and harness documentation. The test merge has the recorded base followed by the exact PR head as parents, and its comparison against that base contains the same four paths. Whitespace validation passed; the checkout remained clean. (extensions/codex/src/app-server/client-initialize.ts:26, 341a52bf4196)
  • Current main still lacks negotiation: The current-main initialize request enables experimental APIs and extensions but supplies no notification opt-outs. The extraction preserves version validation and runtime identity behavior. (extensions/codex/src/app-server/client.ts:332, 861e65d8c9fb)
  • Latest-release comparison: The client source at the supplied latest release, v2026.9.4, also initializes without optOutNotificationMethods. The release source was read through GitHub after its local blob was unavailable. (extensions/codex/src/app-server/client.ts:333, 3a9d69db306c)
  • Dependency contract personally inspected: The introduced initialize capability directly depends on Codex's protocol, making dependency inspection applicable. The sibling checkout resolves to the pinned rust-v0.154.0 commit; its backing repository remote verifies openai/codex ownership. Initialize stores exact method names per connection, and transport filtering applies only to app-server notifications, leaving requests and responses intact. (codex-rs/app-server/src/transport.rs:101, 6b9826e3aa83)
  • Minimum-version compatibility: The minimum supported 0.149.0 already defines optional opt_out_notification_methods with permissive capability deserialization. This change does not require raising OpenClaw's supported-version floor. (codex-rs/app-server-protocol/src/protocol/v1.rs:43, 758ef40f50c1)
  • Consumer and liveness audit: Inspected notification subscribers, projector dispatch, catalog and native-subagent allowlists, account observers, and remote command responses. Required methods remain enabled. Turn progress requires matching thread and turn IDs; inspected excluded thread-scoped protocol payloads lack turn IDs. The similarly named sandbox process event belongs to a separate outgoing protocol. (extensions/codex/src/app-server/run-attempt-notification-controller.ts:111, 341a52bf4196)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Closing without merging: the measurement in this PR is the useful output, the change is not. On the representative turn the opt-out removes one 218-byte notification (0.24% of bytes); 48% of bytes are rawResponseItem/completed and 40% are consumed deltas, none of which this list can suppress, so the extra initialize payload and a 34-entry exclusion list to maintain are not worth landing. The production profile implies far more app-server line volume per turn than this fixture produced, so the next step is a measurement on the live Gateway, not a fixture-derived exclusion list.

@steipete steipete closed this Sep 18, 2026
@steipete
steipete deleted the steipete/perf-codex-appserver-notification-optout-20260918 branch September 18, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant