Skip to content
Source
Sign inSign up
pingdotgg/t3code

[codex] Sync app-server protocol, service tiers, and provider startup #3036

Mergedjuliusmarmingemerged 3 commits intomain fromrefs/pull/3036/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Summary

This PR broadens the Codex integration update beyond generated protocol bindings. It synchronizes with current Codex app-server behavior, makes model capabilities forward-compatible with new service tiers, and fixes provider reliability and startup performance issues uncovered during live probing.

Protocol and SDK sync

  • refresh generated Codex app-server JSON schemas and TypeScript SDK metadata from OpenAI Codex main at b39f943a634a6e7ba86c3d6e8cf6d5f35e612566
  • include the latest request, response, notification, account usage, permission, plugin, goal, and thread methods
  • support the renamed account/usage/read response type
  • allow extensible reasoning effort IDs returned by newer model catalogs
  • update the generator to use vp fmt

Service-tier capabilities

  • replace the Codex-specific Fast Mode boolean capability with a generic Service Tier select capability
  • expose every service tier returned by each model, including explicit standard routing
  • forward selected tier IDs unchanged to Codex app-server
  • retain compatibility with persisted legacy fastMode selections
  • allow future Codex tiers to appear in the UI without another adapter change

Provider reliability and startup

  • continuously drain Codex app-server stderr so large CLI diagnostics cannot fill the pipe and block JSON-RPC responses
  • keep provider probes off the server startup path
  • return cached/current provider snapshots immediately while managed providers refresh in background
  • attach registry subscriptions before reading current snapshots so background probe results are not lost

Why

Live probing showed two separate problems:

  1. Codex CLI diagnostics could exceed the child-process stderr pipe capacity. Because the SDK did not consume stderr, Codex blocked before returning model/list, and the provider status check timed out.
  2. Provider registry construction awaited provider probes. A timed-out Codex probe was performed twice during startup, delaying the HTTP listener by roughly 20 seconds.

The updated flow starts the server independently of external provider checks and lets the UI transition from cached or checking state when background results arrive.

Live verification

  • migrations completed at 16:11:31.949
  • HTTP listener started at 16:11:32.126, 177 ms later
  • Codex provider probe completed successfully in the background in 483 ms
  • model/list completed in 223 ms

Validation

  • vp check
  • vp run typecheck
  • vp run --filter effect-codex-app-server test
  • vp test packages/effect-codex-app-server/src/client.test.ts apps/server/src/provider/makeManagedServerProvider.test.ts apps/server/src/provider/Layers/ProviderRegistry.test.ts
  • vp test apps/server/src/provider/Layers/CodexProvider.test.ts apps/server/src/provider/Layers/CodexAdapter.test.ts apps/server/src/textGeneration/CodexTextGeneration.test.ts apps/server/src/codexModelOptions.test.ts
  • live server startup and Codex app-server probe against the local Codex installation

Note

Medium Risk Touches Codex session routing, model capability UI, and provider aggregation at server boot; mis-synced tiers or probe timing could affect model options or stale provider status until background refresh completes.

Overview Replaces Codex Fast Mode with a Service Tier select driven by catalog serviceTiers (plus a Standard default), with getCodexServiceTierOptionValue mapping new serviceTier selections and legacy fastMode to Codex routing. CodexAdapter and CodexTextGeneration forward arbitrary tier IDs to sessions and codex exec instead of hard-coding fast.

Bumps effect-codex-app-server to upstream b39f943… (new thread/plugin/account methods, account/usage/read, generator uses vp fmt). ProviderRegistry no longer awaits force-refreshes on layer build—it subscribes, reads current snapshots, and relies on managed providers’ background probes—while makeManagedServerProvider getSnapshot reads cached state without triggering a probe.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 34629c2a50464debd45038f7ce01edd44e762de1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Sync Codex app-server protocol, replace fastMode with serviceTier, and defer provider startup probes

  • Updates generated protocol bindings to a new upstream ref, adding new client/server methods and types (e.g., thread/delete, thread/goal/*, account/usage/read, plugin/*, attestation and moderation notifications).
  • Replaces the boolean fastMode model option with a string serviceTier option across CodexAdapter, CodexProvider, and CodexTextGeneration; a new getCodexServiceTierOptionValue helper maps legacy fastMode=true to "fast" for backward compatibility.
  • mapCodexModelCapabilities now returns a serviceTier select capability (with a Standard default and catalog tiers) instead of a fastMode boolean toggle.
  • ProviderRegistryLive no longer triggers provider refreshes during layer construction; it subscribes to change streams and reads current snapshots, deferring probe results to each managed provider's background startup.
  • Child process clients now fork a fiber to drain stderr via Stream.runDrain, preventing backpressure from blocking protocol I/O.
  • getSnapshot in makeManagedServerProvider now reads directly from the cached snapshotStateRef instead of calling applySnapshot, removing error logging and orDie from that path.
Macroscope summarized 34629c2.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: c707ac43-ae7f-4c7f-bdf9-0c880c7c399d

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `codex/resync-codex-app-server-sdk`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Expo continuous deployment is ready!

      • Project → t3-code
      • Platforms → android, ios
      • Scheme → t3code-preview
       🤖 Android🍎 iOS
      Fingerprintae17d94b35f91f9c608a63dadbc3ddd9f4ba056e313e506a7f15a9c3f15b01d787d68a12382432bf
      Build DetailsBuild Permalink
      DetailsDistribution: INTERNAL
      Build profile: preview:dev
      Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
      App version: 0.1.0
      Git commit: b943153f74685ad06bbffb657cb247c99ed146af
      Build Permalink
      DetailsDistribution: INTERNAL
      Build profile: preview:dev
      Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
      App version: 0.1.0
      Git commit: b943153f74685ad06bbffb657cb247c99ed146af
      Update DetailsUpdate Permalink
      DetailsBranch: pr-3036
      Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
      Git commit: b943153f74685ad06bbffb657cb247c99ed146af
      Update Permalink
      DetailsBranch: pr-3036
      Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
      Git commit: b943153f74685ad06bbffb657cb247c99ed146af
      Update QR
    4. juliusmarminge changed the title

    5. Cursor Bugbot has reviewed your changes and found 2 potential issues.

      Fix All in Cursor

      Bugbot Autofix prepared fixes for both issues found in the latest run.

      • ✅ Fixed: Forwards synthetic default service tier
        • Added a guard in getCodexServiceTierOptionValue to return undefined when the tier value is the synthetic 'default' id, preserving the previous behavior of omitting the service tier for standard routing.
      • ✅ Fixed: Registry sync can miss probe
        • Added a deferred re-read of instance snapshots after an additional yieldNow, which captures any probe result that landed in the ref between the initial getSnapshot and the forked subscriber becoming active on the PubSub.

      Create PR

      Or push these changes by commenting:

      @cursor push cb4e8f4b61
      You can send follow-ups to the cloud agent here. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 34629c2a50464debd45038f7ce01edd44e762de1. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -0,0 +1,13 @@
      1+import type { ModelSelection } from "@t3tools/contracts";
      2+import {
      3+ getModelSelectionBooleanOptionValue,
      4+ getModelSelectionStringOptionValue,
      5+} from "@t3tools/shared/model";
      6+
      7+export function getCodexServiceTierOptionValue(
      8+ modelSelection: ModelSelection | null | undefined,
      9+): string | undefined {
      10+ return (
      11+ getModelSelectionStringOptionValue(modelSelection, "serviceTier") ??
      12+ (getModelSelectionBooleanOptionValue(modelSelection, "fastMode") === true ? "fast" : undefined)
      13+ );

      Forwards synthetic default service tier

      Medium Severity

      getCodexServiceTierOptionValue returns the UI-only default tier id unchanged, so turns and codex exec can send service_tier="default" even though standard routing previously omitted serviceTier entirely.

      Additional Locations (2)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 34629c2a50464debd45038f7ce01edd44e762de1. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -557,10 +556,14 @@
      557- // Force-refresh every new/rebuilt instance in parallel and wait
      558- // for them all to complete. The refresh's result is piped
      559- // directly into `syncProvider`, so `providersRef` is populated
      560- // deterministically by the time this block returns — regardless
      561- // of PubSub subscription timing. Failures are logged and
      562- // swallowed so one bad driver can't wedge the whole registry.
      556+ // Snapshot current state without starting a probe. Managed providers
      557+ // launch their startup refresh independently, so this closes the
      558+ // subscription race without putting external work on the registry
      559+ // or HTTP server construction path.
      563560 yield* Effect.forEach(
      564561 newlyAdded,
      565562 ([, instance]) =>
      566- refreshOneSource(buildSnapshotSource(instance)).pipe(Effect.ignoreCause({ log: true })),
      563+ Effect.gen(function* () {
      564+ const source = buildSnapshotSource(instance);
      565+ const provider = yield* source.getSnapshot;
      566+ yield* correlateSnapshotWithSource(source, provider).pipe(
      567+ Effect.flatMap(syncProvider),
      568+ );
      569+ }).pipe(Effect.ignoreCause({ log: true })),

      Registry sync can miss probe

      Medium Severity

      After subscribing, syncLiveSources reads getSnapshot once instead of awaiting refresh. If the managed provider’s background probe finishes and publishes after that read but before the forked streamChanges consumer subscribes, the aggregator can keep an older snapshot until the next refresh.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 34629c2a50464debd45038f7ce01edd44e762de1. Configure [here](https://www.cursor.com/dashboard/bugbot).
    6. Approvability

      Verdict: Needs human review

      Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    7. juliusmarminge merged thisae7e88b

    8. juliusmarminge closed this

Sign in to join this conversation.