Skip to content

fix(videos): hold active turn capacity through content delivery - #9156

Merged
lidge-jun merged 3 commits into
lidge-jun:devfrom
luvs01:codex/video-read-turn-capacity
Nov 27, 2026
Merged

lidge-jun merged 3 commits into
lidge-jun:devfrom
luvs01:codex/video-read-turn-capacity

Conversation

@luvs01

@luvs01 luvs01 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Account for video status reads and content downloads in the listener's active turn limit. Polling or downloading a previously created job remains available when the model workflow budget has been spent.
  • Bind upstream reads to shutdown and keep a download's slot until delivery ends. Cancellation, stream failure and the existing download deadline release capacity even while the client has paused reads. Document the overload response in the English and Spanish video guides.

Verification

  • The 31 video handler and HTTP route cases passed on Windows across the initial run and a focused recheck of the workflow refusal assertion. Tests use local fixtures for capacity, successful recovery, normal byte delivery, cancellation, source failure and the download deadline.
  • 36 additional tests passed across HTTP admission, the video client and bridge, and the file-size gate.
  • bun run typecheck, bun run structure:check, and bun run privacy:scan passed. Local coverage targeted the changed data-plane paths. The PR workflow covers the wider import graph.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Documentation

    • Clarified that creating, checking, and downloading video jobs each requires an available request slot. Downloads hold the slot until the transfer ends; when all slots are occupied, responses include a retry delay.
    • Existing jobs can still be checked or downloaded after creation workflows reach their limits, provided a request slot is available.
    • Documented download size limits and that transfers may be interrupted by timeouts, shutdown, or cancellation.
  • Bug Fixes

    • Video requests now respect request-slot limits, and download slots are released when transfers finish, fail, or are cancelled.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Video routes now use active turn slots for creates, status checks, and downloads. Existing-job reads do not reserve model-workflow capacity. Content downloads retain their slot until the stream completes or terminates, with upstream work tied to deadlines and shutdown.

Changes: Video route capacity

Layer / File(s) Summary
Admit video route requests
src/server/admitted-http-turn.ts, src/server/index/serve-options.ts, tests/server/server-videos-routes.test.ts, tests/lib/workflow-budget.test.ts, docs-site/src/content/docs/guides/video-bridge.md, docs-site/src/content/docs/es/guides/video-bridge.md
All matched video routes now receive an admission lease. Existing-job GET requests use a turn slot without model-workflow admission. Tests cover busy turn slots and workflow limits. The guides describe the active-slot requirements and the documented HTTP 503 response with Retry-After.
Manage upstream work and download streams
src/images/openai-video-client.ts, src/server/videos.ts, tests/server/server-videos.test.ts, structure/data-planes/images.md
Retrieval and content operations are bound to the route lease. Content fetching returns a deadline signal, and the capped response stream releases the lease on completion or termination. Tests cover stream completion, cancellation, errors, and deadline aborts. The data-plane documentation describes the lifecycle.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant handleContent
  participant fetchOpenAiVideoContentWithDeadline
  participant cappedBody
  participant Client
  handleContent->>fetchOpenAiVideoContentWithDeadline: Fetch content with the operation signal
  fetchOpenAiVideoContentWithDeadline-->>handleContent: Return response and deadline signal
  handleContent->>cappedBody: Wrap upstream body with size limit and lease cleanup
  cappedBody-->>Client: Stream response body
  Client->>cappedBody: Consume or cancel stream
  cappedBody-->>handleContent: Release lease on completion or termination
Loading

Possibly related PRs

  • lidge-jun/opencodex#9128: Adds the video routes and initial turn-slot handling that this change extends for status reads and content downloads.
Merge Risk: Minimal · up to 61594

Video status reads and content downloads now count against the active-turn limit, and downloads hold their slot until delivery ends. The reviewed paths show no concrete defect, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(videos): hold active turn capacity through content delivery" matches the main change. The PR counts video status reads and content downloads against the active-turn limit, and holds a d…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(videos): hold active turn capacity through content delivery" matches the main change. The PR counts video status reads and content downloads against the active-turn limit, and holds a download's slot until delivery ends. The changed files (videos.ts, admitted-http-turn.ts, serve-options.ts, openai-video-client.ts, and the docs) all support this. The title is specific and concise, and it follows the conventional commit style.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 42dc700 and 61594c2.

Files selected for processing: 1

  • structure/data-planes/images.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

…ntext

The video route now calls runAdmittedHttpTurn with an options object after
{ requestId, start, logCtx }, so the source oracle in workflow-budget.test.ts
counted it as a call site that threads no log context (expected 1, got 2).
The log context is threaded; allow an optional trailing options object. The
oracle still requires every call site but count_tokens to carry it.
@lidge-jun lidge-jun added the ci:full Run the four full Ubuntu test shards on this pull request label Nov 27, 2026

@lidge-jun lidge-jun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verified on exact head 61594c2 (L3 review blocker resolved, docs-es + workflow-budget 89/89, exact-head ci:full 33/33 green across all 5 full Ubuntu shards). Merging into dev.

@lidge-jun
lidge-jun merged commit da106c7 into lidge-jun:dev Nov 27, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci:full Run the four full Ubuntu test shards on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants