Skip to content

[codex] Remove realtime initial state startup gate#166

Merged
VerioN1 merged 5 commits into
mainfrom
codex/realtime-startup-without-gate
Jun 18, 2026
Merged

[codex] Remove realtime initial state startup gate#166
VerioN1 merged 5 commits into
mainfrom
codex/realtime-startup-without-gate

Conversation

@VerioN1

@VerioN1 VerioN1 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remove the client-side realtime initial-state readiness gate and delete the gate module.
  • Let startup continue after LiveKit connect and immediate local track publish.
  • Surface initial prompt/image ack failures asynchronously through the existing session error event without retrying startup.
  • Update realtime unit tests for bundled initial state, faster startup, async ack failures, and published-track teardown.

Why

The backend now owns drop-until-initial-state behavior, so the SDK no longer needs to block connection readiness on the initial prompt/image ack. This lets clients publish immediately and realize the time-to-first-frame improvement while still reporting ack failures.

Verification

  • pnpm typecheck
  • pnpm test
  • pnpm build

pnpm test:e2e:realtime was not run locally because DECART_API_KEY is not set in this environment.


Note

Medium Risk
Changes realtime connect semantics (earlier connected state and track publish; ack failures no longer fail connect or trigger retry), which affects all SDK consumers of stream sessions.

Overview
Removes the client-side InitialStateGate and stops blocking connect() on the initial prompt/image WebSocket ack. After room join, the session proceeds through LiveKit connect and immediate local track publish, then marks connected—matching backend-owned drop-until-initial-state behavior for faster time-to-first-frame.

Initial-state ack failures are handled asynchronously via watchInitialStateAck, which emits the existing error event without tearing down or retrying startup. teardownGeneration prevents stale ack rejections from surfacing as errors when a connect retry tears down a pending handshake.

Unit tests drop gate-specific coverage and assert the new startup order, async ack errors, and no spurious errors when retry teardown invalidates a pending ack.

Reviewed by Cursor Bugbot for commit de3ca18. Bugbot is set up for automated code reviews on this repo. Configure here.

@pkg-pr-new

pkg-pr-new Bot commented Jun 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@decartai/sdk@166

commit: de3ca18

@VerioN1 VerioN1 marked this pull request as ready for review June 18, 2026 15:45

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0136351. Configure here.

Comment thread packages/sdk/src/realtime/stream-session.ts
VerioN1 and others added 2 commits June 18, 2026 18:55
…neration

Replace the per-run Set + threaded run id with a single generation counter
bumped in tearDown(). Every cancel site already called tearDown(), so the
explicit cancels and the Set were redundant.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@VerioN1 VerioN1 merged commit bbf8b2e into main Jun 18, 2026
5 checks passed
@VerioN1 VerioN1 deleted the codex/realtime-startup-without-gate branch June 18, 2026 16:36
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