Skip to content

fix(knowledge): wait for embedding admission instead of deferring documents for an hour - #7720

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/embedding-admission-wait
Sep 10, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/embedding-admission-wait

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Knowledge-path embedding batches now wait up to 60 s for the shared admission bucket instead of 5 s. Under load the expected queueing time is minutes, so a 5 s wait turned almost every contested batch into a full document re-dispatch with a 1-to-60-minute delay, for a limiter we run ourselves while the provider was healthy
  • The embedding request bucket admits 64 concurrent starts instead of 8, so documents that begin together no longer lose a race for slots while the token budget sits unused. The per-minute rate is unchanged and still governs sustained throughput
  • When an admission wait still expires, the document resumes after the bucket's stated wait, clamped to 10–60 s with jitter, and the yield counts against the processing-slice budget rather than the provider-failure attempts. Provider-side 429s and quota exhaustion keep the exponential ladder
  • The admission deadline path now carries the bucket's last stated wait so the scheduler can use it

Type of Change

  • Bug fix

Testing

  • New tests: admission-timeout continuation uses the short jittered delay and slice budget, provider throttling keeps the exponential ladder, admission resumes are bounded independently, delay helper clamps and jitters; request burst asserted in admission tests; wait constant asserted in the embedding client test
  • vitest across lib/knowledge/documents, lib/core/rate-limiter, lib/embeddings, background/knowledge-processing: 828 passing
  • bun run type-check, bun run lint, bun run check:audits, docs-manifest:check pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…uments for an hour

Every embedding batch on the indexing path waited at most five seconds for
the deployment's shared admission bucket. Twenty concurrent documents fanning
out eight batches each queue for minutes behind the configured per-minute
budget, so under load most batches timed out, the document stopped, and it
was re-dispatched with a delay that started at a minute and doubled to an
hour. The bucket's own estimate of when capacity returns was only a floor
under that ladder. During a bulk sync this produced thousands of hour-long
deferrals for a limiter we run ourselves, while the provider was healthy.

The knowledge path now waits up to a minute for admission, which is cheaper
than the re-dispatch it replaces and still bounded by the per-request retry
budget. The request bucket admits 64 concurrent starts instead of 8, so
documents that begin together no longer lose a race for slots while the
token budget sits unused. When an admission wait still expires, the document
resumes after the bucket's stated wait, clamped to 10 to 60 seconds with
jitter, and the yield counts against the processing-slice budget rather than
the provider-failure attempts, since the provider did nothing wrong. The
deadline path now carries the bucket's last stated wait so that estimate is
available to the scheduler.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 10, 2026 7:06am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no new actionable failures or outstanding previous findings remain.

Summary

  • Extends checkpointed embedding admission waits to 60 seconds while keeping them within the reserved request-retry budget.
  • Raises the embedding request-bucket burst capacity without changing sustained per-minute throughput.
  • Carries admission retry timing into short, jittered document continuations.
  • Accounts admission timeouts against processing slices rather than provider-failure attempts.
  • Adds focused coverage for admission bursts, retry-budget invariants, continuation accounting, and delay bounds.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  D[Document processing] --> C[Embedding client]
  C --> A[Shared provider admission bucket]
  A -->|Admitted| E[Embedding provider request]
  A -->|Wait expires| T[Admission timeout with remaining wait]
  T --> J[Clamp and jitter 10–60 seconds]
  J --> S[Dispatch processing-slice continuation]
  S --> D
  E -->|Provider throttling| P[Exponential provider continuation]
  P --> D
Loading

Reviews (2) · Last reviewed commit: "fix(knowledge): report only the admissio..."

Comment thread apps/sim/lib/embeddings/client.ts
Comment thread apps/sim/lib/core/rate-limiter/provider-admission.ts Outdated
…line

The bucket's stated wait is stored as an absolute instant so a deadline hit
after a sleep carries the remainder, not the original duration. A test pins
the knowledge admission wait below the retry budget the processing deadline
reserves for each request.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1
waleedlatif1 merged commit 230de4d into staging Sep 10, 2026
33 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/embedding-admission-wait branch September 10, 2026 07:13
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.

1 participant