Skip to content

Make zero-latency combo optimizations opt-in - #2917

Merged
diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.7from
rdself:coder/zero-latency-combo-toggle
May 29, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.7from
rdself:coder/zero-latency-combo-toggle

Conversation

@rdself

@rdself rdself commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a zeroLatencyOptimizationsEnabled combo runtime switch, defaulting to false
  • gate hedging, predictive TTFT skips, and proactive fallback compression behind that explicit opt-in
  • expose the switch in Combo Defaults and allow the related runtime config fields through validation
  • cover the default-preserve and explicit-compress fallback paths in combo routing tests

Rationale

@herjarsa The zero-latency work is useful, but latency optimizations must not mutate user prompts, tool outputs, or fallback request bodies by default. Proactive fallback compression can truncate or otherwise change request content, so it needs an explicit operator opt-in instead of being enabled implicitly.

Validation

  • node --import tsx/esm --test tests/unit/combo-config.test.ts
  • node --import tsx/esm --test tests/unit/combo-routing-engine.test.ts
  • npm run typecheck:core
  • npm run lint (passes with existing warnings only)

@rdself
rdself requested a review from diegosouzapw as a code owner May 29, 2026 19:43
Copilot AI review requested due to automatic review settings May 29, 2026 19:43

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an opt-in mechanism for zero-latency combo optimizations (including hedging, predictive TTFT skips, and proactive fallback compression) to ensure fallback targets receive the original request body exactly by default. The changes include adding a zeroLatencyOptimizationsEnabled configuration flag, updating the backend logic in handleComboChat to respect this flag, introducing a UI toggle in the settings dashboard, updating validation schemas, and adding comprehensive unit tests to verify the behavior. There are no review comments, and I have no additional feedback to provide.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR makes “zero-latency” combo-routing behaviors explicitly opt-in, wiring the new flag through config validation, defaults, UI, docs, and adding unit tests around fallback request-body preservation vs proactive compression.

Changes:

  • Add zeroLatencyOptimizationsEnabled to combo defaults/config and gate hedging, predictive TTFT skips, and proactive fallback compression behind it.
  • Extend validation schema + defaults and expose the toggle in the dashboard settings UI.
  • Add unit tests covering fallback-body preservation when optimizations are disabled and compression when enabled.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/unit/combo-routing-engine.test.ts Adds unit tests validating fallback-body behavior with/without zero-latency opt-in.
tests/unit/combo-config.test.ts Expands assertions for new default combo config fields and schema acceptance.
src/shared/validation/schemas.ts Extends runtime combo config schema with zero-latency-related fields.
src/app/api/settings/combo-defaults/route.ts Adds zeroLatencyOptimizationsEnabled to API-provided defaults.
src/app/(dashboard)/dashboard/settings/components/ComboDefaultsTab.tsx Adds a settings toggle for zero-latency optimizations.
open-sse/services/comboConfig.ts Adds opt-in default for zeroLatencyOptimizationsEnabled.
open-sse/services/combo.ts Gates hedging/predictive TTFT/compression behind zeroLatencyOptimizationsEnabled.
docs/guides/USER_GUIDE.md Documents opt-in nature and tradeoffs of zero-latency optimizations.

Comment on lines 627 to +635
failoverBeforeRetry: z.boolean().optional(),
maxSetRetries: z.coerce.number().int().min(0).max(10).optional(),
setRetryDelayMs: z.coerce.number().int().min(0).max(60000).optional(),
zeroLatencyOptimizationsEnabled: z.boolean().optional(),
hedging: z.boolean().optional(),
hedgeDelayMs: z.coerce.number().int().min(0).max(60000).optional(),
fallbackCompressionMode: compressionModeSchema.optional(),
fallbackCompressionThreshold: z.coerce.number().int().min(0).max(2_000_000).optional(),
predictiveTtftMs: z.coerce.number().int().min(0).max(300000).optional(),
Comment on lines +1345 to +1350
combo: {
name: "zero-latency-disabled-preserves-body",
strategy: "priority",
models: ["provider-a/model-a", "provider-b/model-b"],
config: { maxRetries: 0, retryDelayMs: 1, fallbackCompressionThreshold: 1 },
},
Comment thread tests/unit/combo-routing-engine.test.ts Outdated
Comment on lines +1405 to +1407
assert.equal(result.status, 200);
assert.notEqual(fallbackBody.messages[1].content, longToolOutput);
assert.match(fallbackBody.messages[1].content, /\.\.\.\[truncated\]$/);
Comment on lines +565 to +569
{translateOrFallback(
t,
"zeroLatencyOptimizationsDesc",
"Opt in to hedging, predictive TTFT skips, and proactive fallback compression. Leave off to preserve request bodies exactly."
)}
Comment thread docs/guides/USER_GUIDE.md Outdated
Comment on lines +984 to +987
Zero-latency combo optimizations are opt-in. Leave **Zero-latency optimizations** disabled when
fallback targets must receive the original request body exactly; enabling it allows configured
hedging, predictive TTFT skips, and proactive fallback compression to trade request fidelity for
lower tail latency.
task.finally(() => runningTasks.delete(task));

if (config.hedging && i + 1 < orderedTargets.length) {
if (zeroLatencyOptimizationsEnabled && config.hedging && i + 1 < orderedTargets.length) {
@kilo-code-bot

kilo-code-bot Bot commented May 29, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No New Issues Found | Recommendation: Merge

The PR implements an opt-in mechanism for zero-latency combo optimizations (hedging, predictive TTFT skips, and proactive fallback compression). The implementation is well-structured with:

  • Schema validation in schemas.ts via .superRefine() to enforce that zeroLatencyOptimizationsEnabled: true is required before enabling subfeatures
  • Runtime guards in combo.ts to check zeroLatencyOptimizationsEnabled before activating hedging or fallback compression
  • Default config in comboConfig.ts with appropriate comment explaining the opt-in nature
  • UI controls in ComboDefaultsTab.tsx for users to toggle the feature
  • Comprehensive tests covering both enabled and disabled states
  • Documentation in USER_GUIDE.md

All existing inline comments have been accounted for. The code follows existing patterns and adds appropriate validation without introducing security, performance, or correctness issues.

Files Reviewed (7 files)
  • src/shared/validation/schemas.ts - Schema validation for zero-latency opt-in
  • open-sse/services/combo.ts - Runtime guards for hedging and compression
  • open-sse/services/comboConfig.ts - Default config with comment
  • src/app/(dashboard)/dashboard/settings/components/ComboDefaultsTab.tsx - UI toggle
  • src/app/api/settings/combo-defaults/route.ts - API defaults
  • tests/unit/combo-config.test.ts - Schema validation tests
  • tests/unit/combo-routing-engine.test.ts - Runtime behavior tests
  • docs/guides/USER_GUIDE.md - Documentation

Reviewed by laguna-m.1-20260312:free · 1,068,970 tokens

@diegosouzapw diegosouzapw 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.

Approved after local verification, quality checks and merging into release/v3.8.7.

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.7 May 29, 2026 20:42
@diegosouzapw
diegosouzapw merged commit 41ef944 into diegosouzapw:release/v3.8.7 May 29, 2026
3 checks passed
@rdself
rdself deleted the coder/zero-latency-combo-toggle branch May 29, 2026 21:07
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…ombo-toggle

Make zero-latency combo optimizations opt-in
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.

3 participants