Skip to content

fix(worker): route OpenAI-compatible summarize turns to CLAUDE_MEM_TIER_SUMMARY_MODEL (closes #3240)#3257

Open
rodboev wants to merge 1 commit into
thedotmack:mainfrom
rodboev:fix/3240-summary-tier-openai-compatible
Open

fix(worker): route OpenAI-compatible summarize turns to CLAUDE_MEM_TIER_SUMMARY_MODEL (closes #3240)#3257
rodboev wants to merge 1 commit into
thedotmack:mainfrom
rodboev:fix/3240-summary-tier-openai-compatible

Conversation

@rodboev

@rodboev rodboev commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

CLAUDE_MEM_TIER_SUMMARY_MODEL is ignored on OpenRouter and Gemini because the only current tier-routing write goes to session.modelOverride, and those providers never read it. This change resolves the summary-tier model at summarize dequeue time inside the shared OpenAI-compatible provider path, so summaries can switch models without touching the session-wide config or the Claude provider path.

Closes #3240

Why

The issue's queue-depth diagnosis identifies a real gate in SessionRoutes, but it is not enough for the reporter's provider. On current base, applyTierRouting() writes only session.modelOverride, and ClaudeProvider is the only reader. OpenRouter and Gemini resolve config.model from provider settings and keep using it for every per-message request, including summaries.

The fix therefore belongs at the request boundary that actually serves the summarize turn. A pure helper in model-aliases.ts mirrors the existing summary-tier semantics, and OpenAICompatibleProvider.processSummaryMessage() uses that helper to pick the effective model just before the summarize request is sent.

Scope

This PR fixes summary-tier routing for OpenRouter and Gemini summarize turns only. It does not change SessionRoutes, does not change observation-tier routing, does not change Claude live-generator summarize behavior, and does not add new settings or defaults.

Risk

The model decision moves to the real consumer boundary, which is the smallest correct fix. The remaining unproved area is live provider confirmation in a real OpenRouter or Gemini session. Local behavioral tests can prove the request boundary but cannot prove remote provider logs without owner-reaching execution.

Verification

  • bun test tests/worker/openai-compatible-summary-tier.test.ts
  • bun test tests/worker/model-aliases.test.ts
  • npm run typecheck
  • npm run build
  • npm run lint:hook-io && npm run lint:spawn-env
  • npm run strip-comments:check
  • Manual provider proof, if available

Closes #3240

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR routes OpenAI-compatible summarize turns through the configured summary-tier model. The main changes are:

  • Adds resolveSummaryTierModel for summary model selection when tier routing is enabled.
  • Uses the resolved summary model in OpenAICompatibleProvider.processSummaryMessage() for Gemini and OpenRouter-style providers.
  • Keeps init and observation requests on the session model.
  • Adds helper and provider-boundary tests for enabled, disabled, and fallback behavior.
  • Regenerates bundled plugin artifacts.

Confidence Score: 5/5

Safe to merge with minimal risk.

The change is narrowly scoped to summarize-turn model selection for OpenAI-compatible providers. The original config object is preserved for init and observation turns. Targeted tests cover the helper behavior and request-boundary model selection. No blocking correctness or security issues were identified.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the OpenAI-compatible summary-tier routing test and confirmed it finished with exit code 0.
  • Ran the model aliases test and confirmed it finished with exit code 0.
  • Ran npm run typecheck and confirmed it finished with exit code 0.
  • Cross-checked the three test logs to confirm a consistent passing validation across components.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/services/worker/OpenAICompatibleProvider.ts Adds summarize-turn model resolution at the OpenAI-compatible request boundary while preserving observation/init model behavior.
src/services/worker/model-aliases.ts Adds a pure helper that applies summary-tier routing only when tier routing is enabled and falls back to the current model.
tests/worker/openai-compatible-summary-tier.test.ts Adds provider-boundary tests proving summarize turns use the summary model while init/observation turns keep the session model.
tests/worker/model-aliases.test.ts Extends alias tests to cover summary-tier enabled, disabled, and empty-summary fallback behavior.
plugin/scripts/worker-service.cjs Regenerated bundled worker artifact reflecting the summary-tier routing helper and provider boundary change.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Queue as Message Iterator
participant Provider as OpenAICompatibleProvider
participant Settings as SettingsDefaultsManager
participant Helper as resolveSummaryTierModel
participant API as OpenAI-compatible API

Queue->>Provider: summarize message
Provider->>Provider: buildSummaryPrompt(...)
Provider->>Settings: loadFromFile(USER_SETTINGS_PATH)
Settings-->>Provider: settings
Provider->>Helper: resolveSummaryTierModel(config.model, settings)
Helper-->>Provider: summary model or current model
Provider->>API: query(conversationHistory, summaryConfig)
API-->>Provider: summaryResponse
Provider->>Provider: processAgentResponse(..., servedModel ?? summaryConfig.model)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Queue as Message Iterator
participant Provider as OpenAICompatibleProvider
participant Settings as SettingsDefaultsManager
participant Helper as resolveSummaryTierModel
participant API as OpenAI-compatible API

Queue->>Provider: summarize message
Provider->>Provider: buildSummaryPrompt(...)
Provider->>Settings: loadFromFile(USER_SETTINGS_PATH)
Settings-->>Provider: settings
Provider->>Helper: resolveSummaryTierModel(config.model, settings)
Helper-->>Provider: summary model or current model
Provider->>API: query(conversationHistory, summaryConfig)
API-->>Provider: summaryResponse
Provider->>Provider: processAgentResponse(..., servedModel ?? summaryConfig.model)
Loading

Reviews (1): Last reviewed commit: "fix(worker): honor summary-tier routing ..." | Re-trigger Greptile

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.

CLAUDE_MEM_TIER_SUMMARY_MODEL ignored when summarize is queued to running generator

1 participant