Skip to content

⏳ fix: Let BYOM Workspace Calls Queue Past Thirty Seconds - #264

Merged
danny-avila merged 2 commits into
mainfrom
lia/byom-queue-deadline
Sep 27, 2026
Merged

danny-avila merged 2 commits into
mainfrom
lia/byom-queue-deadline

Conversation

@lia-by-librechat

@lia-by-librechat lia-by-librechat Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Removes the fixed 30-second Code API workspace admission cutoff. Connected callers may wait up to the smaller of Code API JOB_TIMEOUT and five minutes. Admission and execution still have separate budgets.
  • Recomputes serial-lock and workspace-slot reservation TTLs at capacity acquisition, plus assignment metadata TTLs from the final execution deadline. A long queue allowance no longer extends stale reservations for an extra five minutes. Preserves the absolute-deadline caller path.
  • Updates the canonical BYOM and worker documentation with timeout math and safe retry guidance. FIFO, authorization, cancellation, and typed timeout semantics remain unchanged.

End-to-end limitation

Code API does not receive the caller's absolute deadline. LibreChat dev 129a1de52c still budgets 30 seconds of queue wait in each HTTP attempt, producing 65/70/340-second total transport limits for non-command/default-command/five-minute-command operations. The server's default five-minute queue requires caller/proxy limits of at least 335/340/610 seconds respectively, including delivery allowance. An earlier tool signal, client, or proxy timeout disconnects the request, possibly after a mutation starts. Align the client and intermediaries separately before relying on the full window. No deployment or VM configuration changes are included.

Verification

  • Focused Bun tests for store, admission, worker/HTTP bridge, slots, settlement, cancellation, and workspace router: 204 passed, 12 existing skipped across 14 files. New serial-lock, slot and absolute-deadline TTL regressions failed before and passed after the fix.
  • Isolated TypeScript check of edited service files passed. Full service tsc --noEmit is blocked by the same seven unrelated diagnostics seen before the runtime edit.
  • Touched-file ESLint passed for the router, router test and worker-admission test; full-file ESLint for store and concurrent-store test still reports inherited formatting/Lua-string and missing-return-type issues, with no findings on added hunks. git diff --check passed.
  • No whole suite, live proxy or worker test was run. CI and human review must be checked at the exact latest head.

@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T16:19:11.279496Z bbd246a Manual request
ℹ️ 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 review" or "@codex security review".

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 chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 52d9a9d4ff

ℹ️ 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 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 address that feedback".

Comment on lines +61 to +64
const queueBudgetMs = options.queueTimeoutMs ?? Math.min(
options.timeoutMs ?? 30_000,
MAX_WORKSPACE_QUEUE_WAIT_MS,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update all caller-timeout docs for the new queue budget

With the default JOB_TIMEOUT, this raises admission from 30 to 300 seconds, but docs/byom-worker-admission.md still specifies a 30-second maximum and caller/proxy totals of 65/70/340 seconds, while packages/code/README.md also promises admission waits at most 30 seconds. Operators following those timeout instructions will disconnect well before the new queue-plus-execution budgets (approximately 335/340/610 seconds including the documented delivery allowance), cancelling the wait and defeating this fix under contention. Update both canonical documents and their timeout calculations alongside this default.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid, addressed in bbd246a. Updated docs/byom-worker-admission.md and packages/code/README.md, with a link from docs/remote-bridge/README.md. They now calculate 335/340/610 seconds at the default five-minute JOB_TIMEOUT and explain the proxy/client/tool-disconnect and retry risks. I also traced LibreChat dev (129a1de52c): its per-attempt HTTP timer still assumes 30 seconds of admission, even though maxQueueWaitMs allows five minutes of retries after typed 503s. This PR does not change that other service, so it does not yet guarantee the full extended wait; the limitation and required client/intermediary follow-up are explicit in the docs and PR summary.

// The HTTP disconnect cancels waiting; this bounds admission while the caller remains connected.
const queueBudgetMs = options.queueTimeoutMs ?? Math.min(
options.timeoutMs ?? 30_000,
MAX_WORKSPACE_QUEUE_WAIT_MS,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recompute reservation TTLs after the extended admission wait

When a request waits near this new 300-second maximum before admission, RedisBridgeStore.dispatch has already computed ttlSeconds from the full queue deadline plus execution budget, and then applies that entire relative TTL when the lock or workspace slot is finally acquired. If the API crashes or cleanup fails after dispatch, a maximum-duration command admitted at the end of the wait therefore leaves its reservation alive for roughly 10.5 minutes from acquisition even though its fresh execution deadline ends after about 5 minutes, blocking subsequent work for an extra queue-length interval rather than only the intended 30-second cleanup grace. Recompute the reservation TTL at acquisition from the post-admission execution deadline, or otherwise subtract elapsed admission time.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid, fixed in bbd246a. RedisBridgeStore.dispatch now calculates TTL on each actual serial-lock or workspace-slot acquisition, using a fresh execution allowance for split deadlines or only the remaining time for legacy absolute deadlines; enqueue recalculates assignment/queue metadata TTL from the final expiresAt. The new worker-admission and concurrent-store tests reproduced the ~635-second stale reservation with a 300-second queue allowance plus 305-second execution, then confirmed lock, slot and assignment expiries near the final execution deadline plus ~30 seconds. A separate test covers the absolute-deadline path. Existing cancellation, identity revalidation and durable workspace fences remain unchanged and were covered by focused tests.

@lia-by-librechat

Copy link
Copy Markdown
Contributor Author

Exact-head review handoff for bbd246a: both Codex findings on 52d9a9d are addressed and answered in their inline threads. This head adjusts serial and workspace-slot TTLs, updates all canonical BYOM timeout docs, and has 204 passing focused tests (12 existing skips); changed-source TypeScript passes and full service typecheck remains blocked by the same seven baseline diagnostics. Please have a maintainer trigger a fresh Codex review for this exact head; the Lia GitHub App cannot trigger one. End-to-end caveat: LibreChat dev still budgets a 30-second admission window per HTTP attempt, so its client/tool/proxy timeout also needs follow-up before the full server window is usable. CI was still running when this handoff was posted.

@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review the latest head

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: bbd246a297

ℹ️ 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 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 address that feedback".

@danny-avila
danny-avila merged commit 6732988 into main Sep 27, 2026
10 checks passed
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