Skip to content

[Improve] Re-land the router lookup gate (gate only, no model changes)#728

Draft
daniel-lxs wants to merge 4 commits into
developfrom
feature/router-gate-reland
Draft

[Improve] Re-land the router lookup gate (gate only, no model changes)#728
daniel-lxs wants to merge 4 commits into
developfrom
feature/router-gate-reland

Conversation

@daniel-lxs

@daniel-lxs daniel-lxs commented Jul 23, 2026

Copy link
Copy Markdown
Member

Re-lands the two-step lookup gate from #716 (reverted in #726) with all model-resolution changes stripped per review. types.ts and router-service.ts are zero-diff against develop — the router model remains exactly what it is today (context.routingModel → deployment R_SMALL_MODEL), for every routing call including the gate's precheck and the informed re-route.

What this PR is now

One behavior change, in mcp-gather.ts only: routing runs a tool-free precheck first, and the linked-issue fetch from #693 (up to 8s) executes only when that precheck returns needsExternalLookup=true and URL parsing finds a fetchable issue link. When context is fetched, routing runs once more with the issue as untrusted reference material (phase: 'mcp'); every degraded case — no lookup requested, no links, integration down, deadline expired — ships the precheck decision (phase: 'direct'), preserving fail-open.

Incident linkage

The 2026-07-23 routing outage was caused solely by #716's hardcoded google/gemini-3.6-flash default resolving to the unauthenticated direct-Google provider (ProviderAuthError → fallback picker on every message). The gate was never implicated — the throw happened before gate code ran. This PR contains no model ids and no model logic.

Verification

  • 98 router tests green (gate flow: ask→fetch→re-route, skip-fetch, fetch-fails fail-open); pnpm knip, tsc --noEmit, format:check clean.
  • Live end-to-end through the real routeTask + OpenCode provider path (scripts/verify-reland.ts): the incident's exact message ("Review the README in the Roomote repo") routes to the Roomote environment, confidence 0.99, model="roomote-small-model", phase: 'direct', zero fetches.

Related

🤖 Generated with Claude Code

daniel-lxs and others added 2 commits July 23, 2026 12:29
…k; default routing to Gemini 3.6 Flash (#716)" (#726)

This reverts commit 15c4f69.
Re-lands #716's two-step gate (precheck without tools; fetch linked-issue
context only on needsExternalLookup=true) after the #726 revert. The
routing model is now resolved as context.routingModel -> R_ROUTER_MODEL
-> undefined, deferring to the deployment small-model resolution. No
model id is hardcoded: the correct id depends on the deployment's
provider configuration (openrouter/google/... via OpenRouter vs
google/... direct), which is what broke routing in production —
google/gemini-3.6-flash resolved to the unauthenticated direct Google
provider and every routing call fell back to the manual picker.

The routing decision's model field reports the resolved id when an
override is set and the roomote-small-model label otherwise.

Verified through the real routeTask against the production provider
path (scripts/verify-reland.ts): default -> routed on the deployment
small model; R_ROUTER_MODEL=openrouter/google/gemini-3.6-flash ->
routed on Gemini with the id in debug output; the incident's message
routes to the right environment in both.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@roomote-roomote

roomote-roomote Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

2 issues outstanding. See task

  • packages/cloud-agents/scripts/verify-reland.ts:33 The script always prints model: undefined, so it cannot verify or display the resolved default/override model that the PR claims to validate.
  • packages/cloud-agents/src/server/router/mcp-gather.ts:102 If the informed re-route rejects after a successful issue fetch, the exception reaches routeTask and replaces the valid precheck with a fallback. Preserve the precheck response when this second inference fails to maintain the advertised fail-open behavior.

Reviewed 0d07fb4

daniel-lxs and others added 2 commits July 23, 2026 13:44
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Per review: the router model stays exactly as on develop
(context.routingModel -> deployment small model). types.ts and
router-service.ts are now zero-diff against develop; the PR touches
only mcp-gather.ts (the two-step gate), its tests, and the
verify-reland script.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@daniel-lxs daniel-lxs changed the title [Improve] Re-land router lookup gate — no hardcoded model id [Improve] Re-land the router lookup gate (gate only, no model changes) Jul 23, 2026
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