Repository navigation
fix(sse): make MAX_TOOLS_LIMIT configurable via env var - #15193
Merged
diegosouzapw merged 3 commits intoOct 8, 2026
Merged
diegosouzapw merged 3 commits into
diegosouzapw merged 3 commits into
Conversation
Make the request tool-list cap read OMNIROUTE_MAX_TOOLS_LIMIT (positive integers only, default 128) through the existing envInt() helper, so an operator can raise or lower the cap without a rebuild. Unset/invalid values keep the previous 128 behavior, so nothing changes by default. Also evaluate bypassDefaultToolLimit before the known/detected provider limit in truncateToolList: the getKnownToolLimit() branch used to return first, so once a provider limit was cached or detected the operator bypass was silently ignored. Regression tests cover the bypass precedence and the env override. Refs diegosouzapw#13190
Add the new tool-list cap override to .env.example (§6 Tool & Routing Policies) and docs/reference/ENVIRONMENT.md, matching the existing envInt() knobs already documented there. Refs diegosouzapw#13190
bypassDefaultToolLimit is the OpenCode client signal, not an operator override. Restore the original order in truncateToolList so it only lifts the generic default cap and a known provider limit still truncates. Replaces the test that pinned the opposite behavior. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MAX_TOOLS_LIMITnow readsOMNIROUTE_MAX_TOOLS_LIMITthrough the existingenvInt()helper: default 128, positive integers only. Unset or invalid values keep the current 128 behavior, so nothing changes by default.truncateToolList()now evaluatesbypassDefaultToolLimitbefore the known/detected provider limit. ThegetKnownToolLimit()branch used to return first, so once a provider limit was cached or detected the operator override was silently ignored..env.example(§6 Tool & Routing Policies) anddocs/reference/ENVIRONMENT.md(§6), matching the otherenvInt()knobs already listed there.Related Issues
Validation
npm run lint(pre-commit lint-staged on the changed files)Commands run:
node --import tsx/esm --test tests/unit/chatcore-upstream-body.test.ts tests/unit/max-tools-limit-env.test.ts→ 45 pass / 0 failnode --import tsx/esm --test tests/unit/cache-sweeps.test.ts→ 26 pass / 0 failnpm run typecheck:core→ cleannpx eslint <changed files>→ cleannpm run check:env-doc-sync→ clean (864 vars in.env.example, 881 inENVIRONMENT.md, all in sync)npm run check:docs-syncandnpm run check:fabricated-docs→ cleannpm run check:docs-counts→ fails only on the inherited base drift (README.md/llm.txtstill say 3.8.51), which is 🔴 Release branch not green: release/v3.8.52 #15100 and is untouched by this branch.TDD proof for the bypass fix: temporarily restoring the old ordering makes the new regression test fail with
expected: 250, actual: 200; with the reorder it passes.Tests Added Or Updated
tests/unit/chatcore-upstream-body.test.ts— regression: "operator bypass wins over a known provider limit"tests/unit/max-tools-limit-env.test.ts(new) — unset ⇒ 128,OMNIROUTE_MAX_TOOLS_LIMIT=512⇒ 512, non-positive-integer values ⇒ 128Coverage Notes
open-sse/config/constants.ts: the load-time parse is exercised by the new env override test.open-sse/handlers/chatCore/upstreamBody.ts: the truncation/bypass path is exercised bytests/unit/chatcore-upstream-body.test.ts.Reviewer Notes
OMNIROUTE_MAX_TOOLS_LIMIT(default128, positive integers only, invalid values fall back to128) is listed in.env.example§6 anddocs/reference/ENVIRONMENT.md§6. It only moves the default ceiling — a provider with a known/proactive limit (grok-cli200,nvidia1536) still applies its own cap.release/v3.8.52is currently red (🔴 Release branch not green: release/v3.8.52 #15100); any failures inherited from the base are not caused by this branch.