Skip to content

Commit a67c618

Browse files
committed
remove the unnecessary version clamp
1 parent 1688f7a commit a67c618

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

lib/sdk/server-ai/src/main/java/com/launchdarkly/sdk/server/ai/AIGraphTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static AIGraphTracker fromResumptionToken(
109109
public static AIGraphTracker fromResumptionToken(
110110
String token, LDClientInterface client, LDContext context, LDLogger logger) {
111111
ResumptionTokens.DecodedGraph d = ResumptionTokens.decodeGraph(token);
112-
int version = Math.max(1, d.getVersion());
112+
int version = d.getVersion();
113113
return new AIGraphTracker(
114114
client,
115115
d.getRunId(),

lib/sdk/server-ai/src/test/java/com/launchdarkly/sdk/server/ai/AIGraphTrackerTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,18 +401,14 @@ public void fromResumptionTokenWithLoggerRoutesWarningsThroughIt() {
401401
}
402402

403403
@Test
404-
public void fromResumptionTokenClampsVersionLessThanOne() {
405-
AIGraphTracker t = new AIGraphTracker(client, RUN_ID, GRAPH_KEY, null, 0, CONTEXT, logger);
406-
// Version 0 → token contains 0, but fromResumptionToken should clamp to 1
407-
// Actually: the tracker stores version as-is, but fromResumptionToken clamps
408-
// Encode a token with version = 0 manually:
404+
public void fromResumptionTokenPreservesVersionZero() {
409405
String token = com.launchdarkly.sdk.server.ai.internal.ResumptionTokens.encodeGraph(
410406
RUN_ID, GRAPH_KEY, null, 0);
411407
AIGraphTracker reconstructed = AIGraphTracker.fromResumptionToken(token, client, CONTEXT);
412408
reconstructed.trackInvocationSuccess();
413409
ArgumentCaptor<LDValue> captor = ArgumentCaptor.forClass(LDValue.class);
414410
verify(client).trackMetric(eq("$ld:ai:graph:invocation_success"), any(), captor.capture(), anyDouble());
415-
assertThat(captor.getValue().get("version").intValue(), is(1));
411+
assertThat(captor.getValue().get("version").intValue(), is(0));
416412
}
417413

418414
// ---- constructor null checks ---------------------------------------------

0 commit comments

Comments
 (0)