[PR #549] [MERGED] Fix Claude (Subscription) silent model identity loss #4667

Closed
opened 2026-10-22 04:09:38 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/549
Author: @LukaTheHero
Created: 5/8/2026
Status: ✅ Merged
Merged: 5/8/2026
Merged by: @LukaTheHero

Base: main ← Head: fix/claude-subscription-fast-mode-downgrade


📝 Commits (1)

  • 332ebac Fix Claude (Subscription) silent model identity loss

📊 Changes

10 files changed (+414 additions, -1 deletions)

View changed files

📝 packages/client/src/components/connections/ConnectionEditor.tsx (+223 -0)
📝 packages/client/src/hooks/use-connections.ts (+19 -0)
📝 packages/server/src/db/migrate.ts (+5 -0)
📝 packages/server/src/db/schema/connections.ts (+8 -0)
📝 packages/server/src/routes/connections.routes.ts (+92 -0)
📝 packages/server/src/routes/generate.routes.ts (+1 -0)
📝 packages/server/src/services/llm/provider-registry.ts (+3 -0)
📝 packages/server/src/services/llm/providers/claude-subscription.provider.ts (+57 -1)
📝 packages/server/src/services/storage/connections.storage.ts (+5 -0)
📝 packages/shared/src/schemas/connection.schema.ts (+1 -0)

📄 Description

Summary

Roleplays on Claude (Subscription) felt much dumber than they should because the SDK was stripping the model's version awareness, and quality regressions were impossible to diagnose because the model itself would lie about which model it was.

Root cause

The Claude Agent SDK strips a model's version awareness when systemPrompt is passed as a plain string. Without the claude_code preset wrapping, every model — Opus, Sonnet, Haiku — falsely answers "Sonnet" when asked which model it is, because it has no framing for its own identity and falls back to the most-mentioned variant in its training data. Self-id is reliable when the preset is in place: opus → "Opus", sonnet → "Sonnet", haiku → "Haiku".

What changed

  • claude-subscription.provider.ts — wraps the caller's system content as the append of { type: 'preset', preset: 'claude_code' }. Identity now matches the model that's actually running, matching the claude CLI default. This is the load-bearing fix for the roleplay quality issue.
  • Diagnose Model Routing button on Claude (Subscription) connections. Sends a real prompt through the SDK and reports which model the SDK actually billed against, split into:
    • Roleplay generation — the model you picked.
    • SDK session bookkeeping — Haiku running the UserPromptSubmit hook for auto-titling (overhead, not your output). The card explains this so users don't misread it as a downgrade.
  • Per-connection Fast Mode toggle — off by default, with a destructive confirm-on-enable dialog ("YOU DON'T WANT THIS SETTING ON!"). Currently a no-op since Anthropic dropped fast-mode routing on current models and Opus 4.7 has no faster variant; toggle exists so we don't need a release if support returns.
  • Server-side warning log when modelUsage shows the SDK billed against a model different from the one requested — catches future silent downgrades.
  • DB migration — claude_fast_mode column on api_connections, applied automatically on next server start.

Notes

  • No linked issue — should one be opened retroactively per CONTRIBUTING.md § Before You Open a Pull Request?
  • Tested manually against Claude Opus 4.7 on a Pro/Max subscription. Diagnose button confirmed Roleplay generation: claude-opus-4-7 with self-id "Opus". Roleplay quality felt noticeably restored after the fix.
  • No version bump (no user-visible breaking change, no upgrade signal needed).

Summary by CodeRabbit

  • New Features
    • Added "Fast Mode" configuration toggle for Claude Subscription connections with destructive confirmation dialog.
    • Added "Diagnose Model Routing" test workflow that displays detailed routing diagnostics including requested model, billed model, fast-mode state, downgrade alerts, and SDK output.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/549 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 5/8/2026 **Status:** ✅ Merged **Merged:** 5/8/2026 **Merged by:** [@LukaTheHero](https://github.com/LukaTheHero) **Base:** `main` ← **Head:** `fix/claude-subscription-fast-mode-downgrade` --- ### 📝 Commits (1) - [`332ebac`](https://github.com/Pasta-Devs/Marinara-Engine/commit/332ebac285cebcb28a13dad0bf74fcbc65c2dc98) Fix Claude (Subscription) silent model identity loss ### 📊 Changes **10 files changed** (+414 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+223 -0) 📝 `packages/client/src/hooks/use-connections.ts` (+19 -0) 📝 `packages/server/src/db/migrate.ts` (+5 -0) 📝 `packages/server/src/db/schema/connections.ts` (+8 -0) 📝 `packages/server/src/routes/connections.routes.ts` (+92 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+1 -0) 📝 `packages/server/src/services/llm/provider-registry.ts` (+3 -0) 📝 `packages/server/src/services/llm/providers/claude-subscription.provider.ts` (+57 -1) 📝 `packages/server/src/services/storage/connections.storage.ts` (+5 -0) 📝 `packages/shared/src/schemas/connection.schema.ts` (+1 -0) </details> ### 📄 Description ## Summary Roleplays on Claude (Subscription) felt much dumber than they should because the SDK was stripping the model's version awareness, and quality regressions were impossible to diagnose because the model itself would lie about which model it was. ## Root cause The Claude Agent SDK strips a model's version awareness when `systemPrompt` is passed as a plain string. Without the `claude_code` preset wrapping, every model — Opus, Sonnet, Haiku — falsely answers `"Sonnet"` when asked which model it is, because it has no framing for its own identity and falls back to the most-mentioned variant in its training data. Self-id is reliable when the preset is in place: `opus → "Opus"`, `sonnet → "Sonnet"`, `haiku → "Haiku"`. ## What changed - **`claude-subscription.provider.ts`** — wraps the caller's system content as the `append` of `{ type: 'preset', preset: 'claude_code' }`. Identity now matches the model that's actually running, matching the `claude` CLI default. This is the load-bearing fix for the roleplay quality issue. - **Diagnose Model Routing** button on Claude (Subscription) connections. Sends a real prompt through the SDK and reports which model the SDK actually billed against, split into: - *Roleplay generation* — the model you picked. - *SDK session bookkeeping* — Haiku running the `UserPromptSubmit` hook for auto-titling (overhead, not your output). The card explains this so users don't misread it as a downgrade. - **Per-connection Fast Mode toggle** — off by default, with a destructive confirm-on-enable dialog ("YOU DON'T WANT THIS SETTING ON!"). Currently a no-op since Anthropic dropped fast-mode routing on current models and Opus 4.7 has no faster variant; toggle exists so we don't need a release if support returns. - **Server-side warning log** when `modelUsage` shows the SDK billed against a model different from the one requested — catches future silent downgrades. - **DB migration** — `claude_fast_mode` column on `api_connections`, applied automatically on next server start. ## Notes - No linked issue — should one be opened retroactively per `CONTRIBUTING.md § Before You Open a Pull Request`? - Tested manually against Claude Opus 4.7 on a Pro/Max subscription. Diagnose button confirmed `Roleplay generation: claude-opus-4-7` with self-id `"Opus"`. Roleplay quality felt noticeably restored after the fix. - No version bump (no user-visible breaking change, no upgrade signal needed). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added "Fast Mode" configuration toggle for Claude Subscription connections with destructive confirmation dialog. * Added "Diagnose Model Routing" test workflow that displays detailed routing diagnostics including requested model, billed model, fast-mode state, downgrade alerts, and SDK output. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:09:38 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4667
No description provided.