René's URL Explorer Experiment


Title: fix(knowledge): stop one env knob from setting the embedding request fan-out by waleedlatif1 · Pull Request #6852 · simstudioai/sim · GitHub

Open Graph Title: fix(knowledge): stop one env knob from setting the embedding request fan-out by waleedlatif1 · Pull Request #6852 · simstudioai/sim

X Title: fix(knowledge): stop one env knob from setting the embedding request fan-out by waleedlatif1 · Pull Request #6852 · simstudioai/sim

Description: Problem KB_CONFIG_CONCURRENCY_LIMIT was read in three places with three different meanings: Consumer What it actually controlled Effective value background/knowledge-processing.ts Trigger.dev queue depth — concurrent document task runs 20 lib/embeddings/client.ts Embedding API requests issued concurrently within one embed call 50 lib/knowledge/documents/service.ts /5 → concurrent documents in the in-process path 4 The first two multiply. Every admitted task run reaches the embed path and opens its own fan-out, so the default put on the order of 1,000 embedding requests in flight against a single provider key. A provider's rate limit is per key, so the pipeline held itself at its own limit — and no retry policy can absorb a load its own concurrency is generating. Two things hid this: The same variable was read with a different inline fallback in each place (50, 20, 20/5). createEnv runs with skipValidation: true, and t3-env returns runtimeEnv untouched in that mode, so the .default(...) declarations never execute — the inline fallbacks are the real defaults, and they disagreed with each other and with the declaration. KB_CONFIG_BATCH_SIZE had the same conflation, between chunks-per-embedding-request (2000) and documents-per-batch (/2 → 10). Separately, rate-limit rejections discarded what the provider said about when to retry. EmbeddingAPIError was built from status text only and the response headers were dropped, so retryWithExponentialBackoff's support for a server-stated wait was dead code on this path. Every attempt fired blind: 3 retries capped at 10s, ~7s of total backoff, all of it spent inside a window that had not reopened. Change One consumer per variable, so the fallbacks cannot drift: KB_CONFIG_CONCURRENCY_LIMIT — task-queue depth only KB_CONFIG_EMBEDDING_CONCURRENCY (new) — embedding fan-out, 50 → 8 KB_CONFIG_DOCUMENT_CONCURRENCY (new) — in-process document concurrency, default 4 KB_CONFIG_BATCH_SIZE — chunks per embedding request only KB_CONFIG_DOCUMENT_BATCH_SIZE (new) — documents per batch, default 10 The divisors are gone and the previous effective values are the declared defaults, so when these variables are unset the only behaviour change is the embedding fan-out. If a deployment sets KB_CONFIG_CONCURRENCY_LIMIT or KB_CONFIG_BATCH_SIZE explicitly, more moves — that is the whole point of the split, but it is worth stating exactly what: Set in env Before After KB_CONFIG_CONCURRENCY_LIMIT=50 queue 50, embedding 50, in-process docs 10 queue 50, embedding 8, in-process docs 4 KB_CONFIG_BATCH_SIZE=2000 2000 chunks/request, 1000 docs/batch 2000 chunks/request, 10 docs/batch Each of those collateral values was set by a divisor rather than by intent, so the new numbers are the intended ones — but they would be changes, not no-ops. Checked against every env source, and none of these variables are set anywhere: Source Keys KB_CONFIG_* set Secrets Manager, production 301 none Secrets Manager, staging 275 none Trigger.dev, prod (where the document task runs) 179 none Trigger.dev, staging 179 none trigger.config.ts syncs only DB_APP_NAME, so the worker env is the dashboard's and had to be checked separately from Secrets Manager. Since every variable is unset, the inline fallbacks are what run today, and for this deployment the sole behavioural change is the embedding fan-out, 50 → 8. Honor the provider's stated wait. The headers now travel with the error the way fetchWithRetry already does for connectors, via the existing attachRetryHeaders (non-enumerable, so the bag stays out of log lines). The wait is read from Retry-After, falling back to the reset header for whichever limit dimension is actually exhausted — a tokens-per-minute rejection and a requests-per-minute rejection reopen at different times, and a reset read while quota remains says nothing about this request. Those reset headers carry a Go duration (6m0s, 12ms, 23h47m36.648s), not the epoch seconds the shared connector helper reads. Teaching the shared reader both spellings would change retry behaviour for every connector on fetchWithRetry, so the provider-specific reading lives in a new lib/embeddings/rate-limit.ts instead. Note m vs ms: a loosely-scanning parser reads 12ms as twelve minutes, so the parser matches sticky and rejects anything it cannot fully consume. There is a test for exactly that. The retry budget is sized against a rate-limit window rather than a blip (5 retries, 30s ceiling) — the previous 10s ceiling clamped every stated wait to below the reopen time, spending the whole budget for nothing. It stays well inside KB_CONFIG_MAX_DURATION, and batches wait concurrently rather than in sequence. Verification 14,422 tests pass; 29/29 audits; type-check clean in touched code Each new test was verified to fail without its fix — including reordering the duration-unit alternation to confirm the ms/m test genuinely catches it Retry-budget assertions now derive from an exported constant rather than a hardcoded attempt count, so they cannot silently drift again Not in this PR The stuck-document sweep re-queues every pending/failed doc in its 7-day window on every sync, with no attempt counter and no cooldown (there is no retry-count column). Under sustained failure that re-attempts the whole backlog each cycle. Fixing it properly needs a schema migration, which does not belong in a config and retry change — filed as follow-up.

Open Graph Description: Problem KB_CONFIG_CONCURRENCY_LIMIT was read in three places with three different meanings: Consumer What it actually controlled Effective value background/knowledge-processing.ts Trigger.de...

X Description: Problem KB_CONFIG_CONCURRENCY_LIMIT was read in three places with three different meanings: Consumer What it actually controlled Effective value background/knowledge-processing.ts Trigger.de...

Opengraph URL: https://github.com/simstudioai/sim/pull/6852

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7c139f68-dd9f-af7d-0908-ae7210d497bd
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA08E:CE688:CA32D:11816C:6AFB7597
html-safe-nonceb342f0644437d3e31a2e285ba0aa0be4c850937d3d97840c4727356228753d7c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDhFOkNFNjg4OkNBMzJEOjExODE2Qzo2QUZCNzU5NyIsInZpc2l0b3JfaWQiOiI4NzgyNzUzMzA2NTUzMDU0NjE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac7d15c9f44d2439fe102ae799d5cf62e9463473bf77252d74c4821f1dfac9e599
hovercard-subject-tagpull_request:4316622520
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6852/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altProblem KB_CONFIG_CONCURRENCY_LIMIT was read in three places with three different meanings: Consumer What it actually controlled Effective value background/knowledge-processing.ts Trigger.de...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0e29e7974fdda2feeaf5c891efd4b23b0734b23480232b62c7bdef13f40b5b48
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2e8872b770cc4d5d0cc1f2026afab747a268e2ce
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/6852/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6852%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6852%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/6852/files
Reloadhttps://github.com/simstudioai/sim/pull/6852/files
Reloadhttps://github.com/simstudioai/sim/pull/6852/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests201 (201)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/kb-embedding-concurrencyhttps://github.com/simstudioai/sim/tree/fix/kb-embedding-concurrency
Conversation 15 https://github.com/simstudioai/sim/pull/6852
Commits 3 https://github.com/simstudioai/sim/pull/6852/commits
Checks 30 https://github.com/simstudioai/sim/pull/6852/checks
Files changed https://github.com/simstudioai/sim/pull/6852/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6852/files
fix(knowledge): stop one env knob from setting the embedding request fan-out https://github.com/simstudioai/sim/pull/6852/files#top
Show all changes 3 commits https://github.com/simstudioai/sim/pull/6852/files
1ffdc37 fix(knowledge): stop one env knob from setting the embedding request … waleedlatif1 Aug 19, 2026 https://github.com/simstudioai/sim/pull/6852/commits/1ffdc3755d6dc0270b1155f717be9c6460798a57
2b357ff fix(knowledge): stop retrying an embedding wait we will not honor waleedlatif1 Aug 19, 2026 https://github.com/simstudioai/sim/pull/6852/commits/2b357ff6c87d5c613c297f4e3955200092a2ba61
a4ae48f fix(knowledge): measure a stated wait against the whole retry budget waleedlatif1 Aug 19, 2026 https://github.com/simstudioai/sim/pull/6852/commits/a4ae48f2da05f14c6acc2a67fb8a2797957f6695
Clear filters https://github.com/simstudioai/sim/pull/6852/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6852/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6852/files
env.ts https://github.com/simstudioai/sim/pull/6852/files#diff-7db3fc610ff89cf819c4eb69b43ec37ae18530e1861f6c322faeb62f8f48f298
client.test.ts https://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
client.ts https://github.com/simstudioai/sim/pull/6852/files#diff-bff32d70819c246fcf759a2ace839aa7e4569d2c62cf0658c5d2613a89d1170c
rate-limit.test.ts https://github.com/simstudioai/sim/pull/6852/files#diff-d0b1a5e8ad4c1f3509235564507c90b43999316aa9e3629ac0cbc72053c44b06
rate-limit.ts https://github.com/simstudioai/sim/pull/6852/files#diff-0a23e7afb9f359b857dffb5fca7c23d77adf363173406274b147a69eba9fff2d
service.ts https://github.com/simstudioai/sim/pull/6852/files#diff-12adff6ec055d413ec20f1debed4ca207b994d23df6de9aa4ef79bf47f2857b2
apps/sim/lib/core/config/env.tshttps://github.com/simstudioai/sim/pull/6852/files#diff-7db3fc610ff89cf819c4eb69b43ec37ae18530e1861f6c322faeb62f8f48f298
View file https://github.com/simstudioai/sim/blob/a4ae48f2da05f14c6acc2a67fb8a2797957f6695/apps/sim/lib/core/config/env.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6852/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6852/files#diff-7db3fc610ff89cf819c4eb69b43ec37ae18530e1861f6c322faeb62f8f48f298
Please reload this pagehttps://github.com/simstudioai/sim/pull/6852/files
https://github.com/simstudioai/sim/pull/6852/files#diff-7db3fc610ff89cf819c4eb69b43ec37ae18530e1861f6c322faeb62f8f48f298
https://github.com/simstudioai/sim/pull/6852/files#diff-7db3fc610ff89cf819c4eb69b43ec37ae18530e1861f6c322faeb62f8f48f298
https://github.com/simstudioai/sim/pull/6852/files#diff-7db3fc610ff89cf819c4eb69b43ec37ae18530e1861f6c322faeb62f8f48f298
apps/sim/lib/embeddings/client.test.tshttps://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
View file https://github.com/simstudioai/sim/blob/a4ae48f2da05f14c6acc2a67fb8a2797957f6695/apps/sim/lib/embeddings/client.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6852/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
https://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
https://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
https://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
https://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
https://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
https://github.com/simstudioai/sim/pull/6852/files#diff-776dd477f81ddfab85944a291f03f7cd5365106f51de7615adc673aac72a589a
apps/sim/lib/embeddings/client.tshttps://github.com/simstudioai/sim/pull/6852/files#diff-bff32d70819c246fcf759a2ace839aa7e4569d2c62cf0658c5d2613a89d1170c
View file https://github.com/simstudioai/sim/blob/a4ae48f2da05f14c6acc2a67fb8a2797957f6695/apps/sim/lib/embeddings/client.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6852/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6852/files#diff-bff32d70819c246fcf759a2ace839aa7e4569d2c62cf0658c5d2613a89d1170c
https://github.com/simstudioai/sim/pull/6852/files#diff-bff32d70819c246fcf759a2ace839aa7e4569d2c62cf0658c5d2613a89d1170c
https://github.com/simstudioai/sim/pull/6852/files#diff-bff32d70819c246fcf759a2ace839aa7e4569d2c62cf0658c5d2613a89d1170c
https://github.com/simstudioai/sim/pull/6852/files#diff-bff32d70819c246fcf759a2ace839aa7e4569d2c62cf0658c5d2613a89d1170c
https://github.com/simstudioai/sim/pull/6852/files#diff-bff32d70819c246fcf759a2ace839aa7e4569d2c62cf0658c5d2613a89d1170c
Please reload this pagehttps://github.com/simstudioai/sim/pull/6852/files
https://github.com/simstudioai/sim/pull/6852/files#diff-bff32d70819c246fcf759a2ace839aa7e4569d2c62cf0658c5d2613a89d1170c
Please reload this pagehttps://github.com/simstudioai/sim/pull/6852/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6852/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.