refactor: use common LDValueConverter and LDContextEncoder in AI SDK#188
Draft
mattrmc1 wants to merge 3 commits into
Draft
refactor: use common LDValueConverter and LDContextEncoder in AI SDK#188mattrmc1 wants to merge 3 commits into
mattrmc1 wants to merge 3 commits into
Conversation
3 tasks
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
Switches the AI SDK (
server-ai) to consume the sharedLDValueConverterandLDContextEncoderfromcommon(com.launchdarkly.sdk) and removes the SDK's internal copies. This is a behavior-preserving refactor — the interpolation and config-parsing output are unchanged; the logic now lives in one shared place.This PR depends on the
commonutilities added in #187. Becausecommonis a separately published artifact, #188 can only merge tomainafter:commonrelease containingLDValueConverter+LDContextEncoderis published, andcommonversion.Merging this before that release would leave
server-aireferencingcommonsymbols that aren't in a published artifact yet. Do not merge until the release dependency is satisfied.Changes
Interpolator— the privatecontextToMap/singleContextToMapmethods are removed; theldctxtemplate variable is now built viaLDContextEncoder.encode(context). The interpolation policy is unchanged (no HTML escaping, missing/null → empty string,ldctxmerged last so it always wins).AIConfigParser— now imports and usescom.launchdarkly.sdk.LDValueConverter(formodel.parameters,model.custom, and toolparameters/customParameters) instead of the SDK-local copy.LDValueConverterand itsLDValueConverterTest; that coverage now lives incommon.Migration
None. All changes are internal to
server-ai; the public API and the rendered output (config maps andldctxtemplate values) are unchanged.Test plan
server-aimodule builds and tests pass against the releasedcommonversionInterpolatorTest— existing cases still pass (interpolation parity preserved), including single- and multi-kindldctxrenderingAIConfigParserbehavior unchanged formodel.parameters/model.custom/ tool paramscommon(LDValueConverterTest,LDContextEncoderTest)