Repository navigation
fix(models): close two carryover gaps found in post-merge review of #295 - #308
Merged
Merged
Conversation
OpenRouter rides the same openai-adapter ItemID-dedup path as OpenAI, so a cross-provider switch onto it hit the same "Duplicate item" collision the OpenAI-specific synthesis was meant to prevent — gate on openrouter too, not just the literal "openai" provider id. A failed carryover create's enter-to-retry re-fires a plain, non-carryover create, but the switch-note armed by the original pick survived the failure and falsely reported "conversation kept" on the retry's success. Clear it in the restartFailedMsg reducer. Co-Authored-By: Claude Sonnet 5 <[email protected]>
JAORMX
approved these changes
Jul 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Post-merge review of #295 (seamless model-switch carryover) ran a 5-angle
expert panel (architecture, security, protobuf/wire, duplication, design/UX)
over the merged diff. Two independent reviewers converged on the same root
cause from different angles; I verified both concretely and fixed them here.
OpenRouter still hits the "Duplicate item" bug the PR meant to fix.
validateCarryoveronly synthesized stableItemIDs(
carryover_item_N) when the destination provider was the literalstring
"openai". Butopenrouteris built on the exact sameopenai-Responses-family adapter (newOpenAICompatEntryininternal/app/registry.go) that de-duplicates replayedfunction_callitems by
ItemID(internal/adapter/openai/request.go:359-361). Across-provider carryover landing on an OpenRouter model still stripped
ItemIDs without re-synthesizing them, so it could hitHTTP 400: Duplicate item found with id fc_Non the second post-switchturn — the exact failure feat(models): seamless model switch that always keeps the conversation (#20) #295 was written to prevent, just missed for
one of its two intended destinations. Fix: gate on
newProv == "openai" || newProv == "openrouter"instead of the literalprovider id alone.
A failed carryover retry lies about keeping the conversation.
chooseModelarms a one-shotpendingModelSwitchNote("switched to X —conversation kept") before the async create even runs. If that create
fails,
restartFailedMsgleft the note armed; the user's enter-to-retryre-fires a plain, non-carryover create (by design — see
onIdleSubmit), and on successapplySessionReadystill found thestale note and reported "conversation kept" even though the retry
actually dropped the conversation. Fix: clear the note in the
restartFailedMsgreducer.Testing
task buildandgo test ./internal/adapter/server/... ./cmd/mecatui/...green before and after rebase onto current
main.genuinely distinct provider ids/adapters):
opencodemodel, had it run a shellcommand (so the history has a real tool call + result), then said
something memorable.
/modelsto anopenroutermodel — gotswitched to <model> — conversation kept (prior reasoning cache dropped), no confirm dialog.calls survived the provider-state strip).
another tool call) — this is exactly the window where the
pre-fix
Duplicate item found with id fc_Ncollision would havesurfaced on OpenRouter. Stayed healthy, confirming the fix live.
/clearstill resets the transcript as expected.Not in scope (raised by the panel, not acted on here)
ForkSessionRPC andCreateSession.source_session_idare two adjacent"clone a conversation" mechanisms with no cross-reference in the
.protocomments — a documentation nit, not a bug.cmd/mecatui/ui/models.go(restartOnModel/switchEffort/restartOnModelWithCarryover) are a real Rule-of-Three duplicationcandidate, but a refactor-only change felt like scope creep for a
bugfix PR — flagging for a follow-up.
for cross-provider switches (stripping is one-way lossy), and the
always-carry default has a real, under-argued cost for a deliberate
fresh-topic model switch. Design feedback, not a defect.
🤖 Generated with Claude Code