Skip to content

fix(AIC-3576): record deferred judge scores under the evaluated config - #13

Merged
jeffdupont merged 1 commit into
mainfrom
jdupont/aic-3576-deferred-judge-trackdata
Oct 21, 2026
Merged

jeffdupont merged 1 commit into
mainfrom
jdupont/aic-3576-deferred-judge-trackdata

Conversation

@jeffdupont

@jeffdupont jeffdupont commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes AIC-3576.

Why

When judges run in the background (SkipJudges: true and then RunJudge(ctx, task, handlers)), the returned TrackData started from the judge's own executeAndTrack result and copied over only the parent's GraphKey. A caller who then tracks it records the score under the judge config's ConfigKey, VariationKey, Version, RunID and model stamps, not under the config that was evaluated. The inline path already tracks a.parentTD plus JudgeConfigKey (aiserver/judges.go), so the same judge scored differently depending on which path ran it. JS and Python had the same bug and are fixed in the PRs below.

Fix

  • aiserver/judges.go: RunJudge builds the result from task.ParentTrackData and sets JudgeConfigKey. GraphKey is still carried because it is part of the parent's trackData.
  • aiserver/judges_test.go: new TestDeferredJudgeTrackDataMatchesInline. It checks that the deferred TrackData equals the parent invocation's TrackData plus JudgeConfigKey, that its JSON equals the inline quality metric payload (only the per-invocation runId differs), and that a parent GraphKey survives.

Testing

  • make test (go test -race ./...): all 16 packages ok (557 tests pass, 0 fail)
  • go vet ./... / make lint: clean
  • With the fix reverted, the new test fails: deferred map[configKey:judge … modelKey:judge-model … version:5] != inline map[configKey:cfg … modelKey:parent-model … version:3]

Related: launchdarkly/js-ai-sdk#148, launchdarkly/python-ai-sdk#190, spec https://github.com/launchdarkly/ai-sdks-monorepo/pull/74

🤖 Generated with Claude Code

RunJudge built its result trackData from the judge's own executeAndTrack
trackData, copying over only the parent's GraphKey, so a deferred judge score
was tracked under the judge config's configKey, variationKey, version, runId
and model stamps instead of the config it evaluated. It now returns the
parent's trackData plus JudgeConfigKey, the same payload the inline path
tracks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeffdupont
jeffdupont merged commit cd71325 into main Oct 21, 2026
5 checks passed
@jeffdupont
jeffdupont deleted the jdupont/aic-3576-deferred-judge-trackdata branch October 21, 2026 20:03
jeffdupont added a commit to launchdarkly/python-ai-sdk that referenced this pull request Oct 21, 2026
#190)

Fixes [AIC-3576](https://launchdarkly.atlassian.net/browse/AIC-3576).

## Why

When judges run in the background (`skip_judges=True` and then
`run_judge(task, handlers)`), the returned `track_data` was built by
spreading the judge's own call `track_data` over the parent's. A caller
who then tracks it records the score under the judge config's
`configKey`, `variationKey`, `version` and `runId`, not under the config
that was evaluated. The inline `run_judges` path already tracks
`{**base_track_data, "judgeConfigKey": ...}`, so the same judge scored
differently depending on which path ran it.

This reverses the model-stamp stripping that 5d1e678 added
(`omit_model_stamps(task.parent_track_data)`). That change assumed the
result described the judge, so it hid the parent's
`modelKey`/`modelVersion`. The identity is now the parent's, so the
parent's stamps describe it correctly, which is what the inline path
sends.

## Fix

- `packages/client/src/launchdarkly_ai_server/judges.py`: `run_judge`
returns `{**task.parent_track_data, "judgeConfigKey": task.config_key}`
and drops the `omit_model_stamps` import. `omit_model_stamps` stays
exported (`tests/test_public_surface.py`).
- `packages/client/tests/test_judges.py`: replaced 5d1e678's two stamp
tests in `TestRunJudgeTrackData` with one test asserting the deferred
`track_data` equals `{**parent, "judgeConfigKey": ...}` and equals the
payload `run_judges` passes to `track()`.

## Testing

- `make test`: 2543 passed, 14 skipped
- `make typecheck`: no issues in 75 source files
- `make lint`: all checks passed; `make format-check`: 161 files
formatted
- With the fix reverted, the new test fails: `{'configKey': 'judge-key'}
!= {'configKey': 'main-flag'}` (and runId, variationKey, version, model
fields).

Related: launchdarkly/js-ai-sdk#148,
launchdarkly/go-ai-sdk#13, spec
launchdarkly/ai-sdks-monorepo#74

🤖 Generated with [Claude Code](https://claude.com/claude-code)


[AIC-3576]:
https://launchdarkly.atlassian.net/browse/AIC-3576?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
jeffdupont added a commit to launchdarkly/js-ai-sdk that referenced this pull request Oct 21, 2026
#148)

Fixes [AIC-3576](https://launchdarkly.atlassian.net/browse/AIC-3576).

## Why

When judges run in the background (`skipJudges: true` and then
`runJudge(task, handlers)`), the returned `trackData` was built by
spreading the judge's own call `trackData` over the parent's. A caller
who then tracks it records the score under the judge config's
`configKey`, `variationKey`, `version` and `runId`, not under the config
that was evaluated. The inline `runJudges` path already tracks `{
...baseTrackData, judgeConfigKey }`, so the same judge scored
differently depending on which path ran it.

This reverses the model-stamp stripping that d374962 added
(`omitModelStamps(parentTrackData)`). That change assumed the result
described the judge, so it hid the parent's `modelKey`/`modelVersion`.
The identity is now the parent's, so the parent's stamps describe it
correctly, which is what the inline path sends.

## Fix

- `packages/client/src/judges.ts`: `runJudge` returns `trackData: {
...parentTrackData, judgeConfigKey: configKey }`. It drops the unused
`trackData` destructure and the `omitModelStamps` import.
`omitModelStamps` stays exported from the package root.
- `packages/client/src/__tests__/judges.test.ts`: replaced d374962's two
stamp tests with one test asserting the deferred `trackData` equals `{
...parentTrackData, judgeConfigKey }` and equals the payload `runJudges`
passes to `track()`.

## Testing

- `yarn typecheck`: pass
- `yarn code:check`: pass (237 files)
- `yarn test`: all workspaces pass (client: 1400 passed, 11 skipped)
- With the fix reverted, the new test fails: `expected { runId:
'judge-run', … } to deeply equal { runId: 'parent-run', … }` (configKey
`judge-key` vs `main-flag`).

Related: launchdarkly/python-ai-sdk#190,
launchdarkly/go-ai-sdk#13, spec
launchdarkly/ai-sdks-monorepo#74

🤖 Generated with [Claude Code](https://claude.com/claude-code)


[AIC-3576]:
https://launchdarkly.atlassian.net/browse/AIC-3576?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants