Repository navigation
feat(eu): route AI through OpenRouter's EU endpoint and turn chat back on - #1052
Conversation
…k on The EU instance shipped with AI off (#997) because model calls would carry customer spans and logs to US providers. OpenRouter's in-region routing closes that: requests to eu.openrouter.ai are decrypted and served only by providers inside the EU, and a model with no EU provider is a 404 rather than a hop to the US. With MAPLE_REGION=eu, every OpenRouter call (chat, reviews, embeddings, decisions) goes to https://eu.openrouter.ai/api/v1. The EU catalogue serves none of the US defaults, so the EU instance defaults to openai/gpt-6-luna for chat, triage and reviews. Jev has no EU provider, so the EU has no decision model unless MAPLE_DECISION_MODEL is set; the triage route says so without calling out, and the gate reads no verdict as "investigate". Reverts the web gating from #997 so every chat entry point is back on EU.
Maple review
Why 3/5: I verified the EU endpoint/model plumbing in Warning This review ended early; what follows is what it established. The EU instance now routes every OpenRouter call to
What was checked
Observability coverage: 1 of 1 changes observable
Updated on every push. Resolve a thread or reply "won't fix" to dismiss a finding, or mention @maple to ask about one. Confidence is the reviewer's judgement of merge risk, capped at 2 by a critical finding and 3 by a warning. Quality: 100, minus 25 per critical finding, 10 per warning and 2 per note still open. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… reviews short (#1053) * fix(pr-review): stop small reviews running out of budget before reading the diff A 9-file review (#1052) was cut off after 18 model calls: the 800k token budget counts every re-sent prompt, cache reads included, so at ~45k a prompt any review got about 18 calls. The close-out then showed the agent each earlier tool result cut to 4,000 characters, so the web diffs it had read arrived truncated, and the close-out prompt capped confidence at 3. - PR_REVIEW_BUDGET: 500 tool calls, 20M tokens; the 10 minute wall clock stays the runaway guard. - reviewCallBudget: min(500, max(40, 10 * files + 20)), was capped at 60. - review_files children: 100 calls, 4M tokens (was 16 and 250k). - Close-out keeps up to 60k characters per tool result, above the 50k tool output cap, so it sees what the pass saw. * fix(ai): make every agent budget a runaway guard instead of a pace The engine's token count includes every re-sent prompt, cache reads too, so it grows with the square of a run's length and says little about spend. Sized from p95 traffic it cut normal runs short: a review at 18 calls, a chat turn at 23. Every budget now clears maxToolCalls calls at a full live context, so the call cap or the wall clock binds first, and a test holds all four agents to that. - Investigation: 200 calls, 25.6M tokens (was 100 and 1.2M). A run cost about $0.04 at 79% cache reads. - PR reply: 200 calls, 25.6M tokens (was 40 and 600k). - PR review: 64M tokens, 500 calls. - The review no longer states a call budget in pr_changed_files, and the prompt's "Spending your calls" section, which told it to read narrow line ranges and never a whole file, becomes "Reading the change": read every reviewed diff, batch, and read beyond the diff whenever a decision depends on it. - The close-out caps confidence at 3 only when a reviewed diff went unread, not on every early end.
The EU instance shipped with AI off (#997) because model calls carry customer spans and logs to model providers. OpenRouter's in-region routing fixes that: requests to
eu.openrouter.aiare decrypted and served only by providers inside the EU, and a model with no EU provider returns a 404 instead of hopping to the US.Changes
apps/ai/src/platform/Llm.ts: withMAPLE_REGION=eu(already on the AI worker viaselfObservabilityEnv), every OpenRouter call goes tohttps://eu.openrouter.ai/api/v1: chat, reviews, embeddings and decisions. US stays on the global endpoint.openai/gpt-6-lunafor chat, triage and reviews. The EU catalogue (66 models on 2026-09-25) serves none of the US defaults (glm-5.3-flash,deepseek-v4.1-flash, Jev).MAPLE_TRIAGE_MODEL_OPENROUTER/MAPLE_REVIEW_MODEL_OPENROUTERstill override it. Its context limits are added to the table.MAPLE_DECISION_MODELis set. The triage route returns "no decision model is served in this region" without calling out. The gate already treats no verdict as "investigate".aiChatEnabled): the header button, command palette action,Cshortcut, widget fix action and/chatare back on EU.docs/eu-region-plan.md: Phase 4 rewritten for the new setup.Before deploying
prod-euprod-eu'sOPENROUTER_API_KEYmust be on OpenRouter's Business or Enterprise plan. Otherwise every EU model call fails.MAPLE_LLM_PROVIDERmust stay unset onprod-eu: Workers AI has no region pin.openai/text-embedding-3-smallis served in the EU. The public embeddings listing ignoresregion=eu. If it isn't, the review feedback filter's embeddings fail there.Tests
Llm.test.tscovers the EU URL and default models, the US instance staying on the global endpoint, and the decision model being unset in the EU.apps/webtypecheck is clean.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
Bug Fixes