Skip to content

Commit 3e335bb

Browse files
jsonbaileyclaude
andcommitted
fix: Reorder context param and omit empty variationKey from resumption token
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bcc58bf commit 3e335bb

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

lib/server/ai/ai_config_tracker.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AIConfigTracker
5757
# @param provider_name [String] The name of the AI provider
5858
# @param context [LDContext] The context used for the flag evaluation
5959
#
60-
def initialize(ld_client:, run_id:, config_key:, variation_key:, version:, model_name:, provider_name:, context:)
60+
def initialize(ld_client:, run_id:, config_key:, variation_key:, version:, context:, model_name:, provider_name:)
6161
@ld_client = ld_client
6262
@variation_key = variation_key
6363
@config_key = config_key
@@ -80,12 +80,9 @@ def initialize(ld_client:, run_id:, config_key:, variation_key:, version:, model
8080
# @return [String] the resumption token
8181
#
8282
def resumption_token
83-
payload = {
84-
runId: @run_id,
85-
configKey: @config_key,
86-
variationKey: @variation_key,
87-
version: @version,
88-
}
83+
payload = { runId: @run_id, configKey: @config_key }
84+
payload[:variationKey] = @variation_key if @variation_key && !@variation_key.empty?
85+
payload[:version] = @version
8986
Base64.urlsafe_encode64(JSON.generate(payload), padding: false)
9087
end
9188

@@ -105,11 +102,11 @@ def self.from_resumption_token(token:, ld_client:, context:)
105102
ld_client: ld_client,
106103
run_id: payload['runId'],
107104
config_key: payload['configKey'],
108-
variation_key: payload.fetch('variationKey', ''),
105+
variation_key: payload.fetch('variationKey', nil),
109106
version: payload['version'],
107+
context: context,
110108
model_name: '',
111-
provider_name: '',
112-
context: context
109+
provider_name: ''
113110
)
114111
end
115112

0 commit comments

Comments
 (0)