Skip to content

feat(mcp): route hosted AI through OpenRouter with gpt-5.6-luna@medium - #1213

Open
sentry-junior[bot] wants to merge 6 commits into
mainfrom
feat/openrouter-gpt-5.5
Open

feat(mcp): route hosted AI through OpenRouter with gpt-5.6-luna@medium#1213
sentry-junior[bot] wants to merge 6 commits into
mainfrom
feat/openrouter-gpt-5.5

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Route hosted MCP AI through OpenRouter and default to openai/gpt-5.6-luna with reasoningEffort=medium.

Key Changes

  • Chat playground: hardcoded OpenAI gpt-4o → shared OpenRouter provider
  • Default OpenRouter model: openai/gpt-5openai/gpt-5.6-luna
  • Default OpenRouter reasoning effort: medium (override with OPENROUTER_REASONING_EFFORT)
  • Chat maxOutputTokens: 200016000 so reasoning does not starve text/tool output
  • Worker/env docs/tests accept OPENROUTER_* + EMBEDDED_AGENT_PROVIDER

Why

Prod is moving off a direct OpenAI key onto OpenRouter. Luna@medium is the cheap/fast GPT-5.6 tier at OpenRouter's own default effort — enough for schema-constrained NL→Sentry query agents without the latency/cost of always-on high. We can bump effort or model via env if quality dips.

Deploy notes

After merge, hosted worker should have:

  • OPENROUTER_API_KEY
  • EMBEDDED_AGENT_PROVIDER=openrouter
  • optional OPENROUTER_MODEL=openai/gpt-5.6-luna (also the code default)
  • optional OPENROUTER_REASONING_EFFORT=medium (also the code default; set high without redeploy if needed)
  • OPENAI_API_KEY can be removed once this is live

How we'll measure

  • Sentry error rate on embedded agents / chat (callEmbeddedAgent, LLM provider failures, NoObjectGeneratedError rescues)
  • Tool failure rate for search_events / search_issues / search_issue_events (7d baseline ~11–12% on agent trio)
  • Existing alert 444138 (global tool failure rate, critical 18%)
  • Latency + OpenRouter spend vs prior OpenAI baseline

Risks / follow-ups

  • Luna may underperform on harder NL→query cases vs gpt-5 / sol / terra; easy env bump if needed
  • Chat now requires OPENROUTER_API_KEY
  • If both OpenAI and OpenRouter keys remain set without EMBEDDED_AGENT_PROVIDER, provider selection still errors by design
  • Did not run live OpenRouter evals in this PR

Checks run

  • vitest run packages/mcp-core/src/internal/agents/openrouter-provider.test.ts (pass)

Requested by David Cramer via Junior.

--

View Junior Session

sentry-junior Bot and others added 2 commits July 29, 2026 22:25
Move the Cloudflare chat playground off the hardcoded OpenAI gpt-4o path
onto the shared OpenRouter provider, and bump the OpenRouter default model
to openai/gpt-5.5 so hosted agents and chat use the same modern model.

Co-Authored-By: David Cramer <david@sentry.io>
Switch the shared OpenRouter default from gpt-5.5 to the cheaper
gpt-5.6-luna tier and send reasoningEffort=high for agents and chat.
Effort remains overridable via OPENROUTER_REASONING_EFFORT.

Co-Authored-By: David Cramer <david@sentry.io>
@sentry-junior sentry-junior Bot changed the title feat(mcp): route hosted AI through OpenRouter with gpt-5.5 feat(mcp): route hosted AI through OpenRouter with gpt-5.6-luna@high Jul 29, 2026
@dcramer
dcramer marked this pull request as ready for review July 29, 2026 22:43
Comment thread packages/mcp-cloudflare/src/server/routes/chat.ts
sentry-junior Bot and others added 2 commits July 29, 2026 22:49
High reasoning effort spends completion budget before visible text or
tool calls. Bump the playground cap so luna@high does not truncate.
Luna agents are schema-constrained NL→query hops, not long-horizon
coding. Start at OpenRouter's medium default and keep OPENROUTER_REASONING_EFFORT
for a no-deploy bump if quality dips.

Co-Authored-By: David Cramer <david@sentry.io>
@sentry-junior sentry-junior Bot changed the title feat(mcp): route hosted AI through OpenRouter with gpt-5.6-luna@high feat(mcp): route hosted AI through OpenRouter with gpt-5.6-luna@medium Jul 29, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cc5b0a2. Configure here.

Comment thread packages/mcp-core/src/internal/agents/openrouter-provider.ts
@ai-sdk/openai only accepts none/minimal/low/medium/high/xhigh. Reject
unknown OPENROUTER_REASONING_EFFORT values early, map max→xhigh, and
document empty string as omit-provider-option rather than disable.
Comment thread packages/mcp-core/src/internal/agents/openrouter-provider.ts Outdated
Use a null-prototype alias map and Object.hasOwn so prototype keys like
constructor cannot bypass validation and leak a function into provider options.
HazAT added a commit that referenced this pull request Jul 31, 2026
## Summary
Moves the eval CI job and eval harness off a direct OpenAI key onto
OpenRouter, so GitHub Actions no longer needs `OPENAI_API_KEY` for
evals.

## Changes
- `.github/workflows/eval.yml` now injects `OPENROUTER_API_KEY` and
`EMBEDDED_AGENT_PROVIDER=openrouter`
- eval scorers/task runners default to `getOpenRouterModel()` instead of
hardcoding `openai("gpt-4o")`
- MSW unhandled-request filters also allow `openrouter.ai` traffic
during evals
- docs/comments updated to mention `OPENROUTER_API_KEY`

## Follow-up
- Ensure the Actions environment has an `OPENROUTER_API_KEY` secret
before relying on eval CI results
- Hosted Cloudflare chat OpenAI usage is covered separately by #1213

## Test plan
- [x] `pnpm --filter @sentry/mcp-server-evals exec tsc -b --force`
- [x] After secret is set, confirm Eval workflow can call OpenRouter
successfully

<!-- junior-request-attribution:start -->
Requested by **Daniel Griesser**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC08J1NSPU6S%3A1785497651.998319 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AC08J1NSPU6S%3A1785497651.998319)
[Sentry](https://sentry.sentry.io/explore/conversations/slack%3AC08J1NSPU6S%3A1785497651.998319/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Daniel Griesser <dgriesser@sentry.io>
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.

0 participants