Repository navigation
Conversation
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.
Why
Shadow requests let a team try a candidate variation on real traffic without serving it and compare it on the normal AI metrics. This replaces the closed #187, which shipped it as experimental behind a new core invocation hook. We are not shipping new features as experimental, and a judges-style core design is easier to read.
Summary
Adds
src/shadows.ts, called directly fromconfig().invoke()and.stream()the way judges are.config()evaluates withvariationDetail, picks the shadows for the matched rule or the fallthrough, samples them per context, and runs each as a background invoke of the candidate variation with its tools and judges removed. Shadow events carry the primary run'srunIdplusisShadow,primaryVariationKey,shadowRequestId,ownerKindandownerId, and the root span gets the threelaunchdarkly.shadowattributes.skipShadows: truereturns the tasks instead, to run later with the newrunShadow(task, handlers).shadowTimeoutMsdefaults to 30000, andshutdown()drops running shadows. Follows TESTING.md §3.30 and A.22.Testing approaches
skipShadows,runShadow,structuredCloneof a task and identical events in both modes.runShadow.Feature flags
N/A
Note
Overview
Adds shadow requests so
config().invoke()and.stream()can run candidate AI Config variations on the same input in the background, emit normal$ld:ai:*metrics tagged withisShadow: true, and never change the served response, latency, or primary events.config()now evaluates flags with optionalvariationDetail(when present) to learn which rule or fallthrough matched, readsshadowConfigurationfrom the raw variation, samples entries per context (Python-aligned bucketing), and starts each shadow after the primary handler begins. Shadows run as plain invokes with tools and judges stripped, share the primaryrunId, and honorshadowTimeoutMs(default 30s).skipShadows: truereturnsshadowTasksinstead (including on streamdone), mirroring deferred judges via the new publicrunShadow(task, handlers).Telemetry updates extend
TrackDataand root spans with shadow metadata (primaryVariationKey,shadowRequestId, owner fields,launchdarkly.is_shadowvia__ld_span), andextractVariationstripsshadowConfigurationfrom parsed configs while exposing raw variation + evaluation reason.shutdown()registers a Shadow requests hook that drops in-flight background shadows.Reviewed by Cursor Bugbot for commit 5194767. Bugbot is set up for automated code reviews on this repo. Configure here.