fix(sdk): preserve mid-session model change across SDK warmup cycles#321
Closed
akuehner wants to merge 1 commit intochadbyte:mainfrom
Closed
fix(sdk): preserve mid-session model change across SDK warmup cycles#321akuehner wants to merge 1 commit intochadbyte:mainfrom
akuehner wants to merge 1 commit intochadbyte:mainfrom
Conversation
When a user changes the model mid-session via set_model, the change is stored in sm.currentModel. However, on each subsequent SDK warmup (which fires on session reconnect, tab reload, or session resumption), two sites unconditionally overwrote sm.currentModel with sm._savedDefaultModel, resetting any user-initiated change back to the project or server default. Fix: check sm.currentModel first in both warmup paths so an already-set in-memory value is preserved. Fall back to _savedDefaultModel (persisted default) and then to the SDK-reported model only when no current value exists. Affected: sdk-message-processor.js (system/init path) and sdk-bridge.js (warmup worker result path).
Contributor
|
This issue has been resolved in version 2.32.0-beta.5 (main). To update, run: -- Clay Deploy Bot Build anything, with anyone, in one place. |
Owner
|
Thanks for the PR! The fix is valid. Since the PR was opened, there have been major changes on main (Codex support, etc.), which caused merge conflicts. I resolved them manually and applied the same fix on main directly. The field name also changed from Committed in 420ad34. Closing this PR. Thanks again for catching this! |
Contributor
|
This issue has been resolved in version 2.32.0 (stable). To update, run: -- Clay Deploy Bot Build anything, with anyone, in one place. |
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.
Problem
When a user changes the model mid-session (via the model picker), the change is stored in
sm.currentModel. However, on each subsequent SDK warmup — which fires on session reconnect, tab reload, or session resumption — two sites unconditionally overwritesm.currentModelwithsm._savedDefaultModel, resetting the user's choice back to the project or server default without any action on their part.The symptom: you switch to
sonnet, send a message, and Clay silently resets back toopus(or whatever the default is). The UI reflects the reset and the actual API calls use the wrong model.Root Cause
Two warmup completion paths use the same pattern:
Both ignore any value already in
sm.currentModel, so a mid-sessionset_modelcall is always clobbered on the next warmup.Fix
Prepend a
sm.currentModelcheck in both paths so an already-set in-memory value is preserved:Priority order:
set_model)_savedDefaultModel)Testing
opus)sonnet)currentModelstarts unset)