Skip to content

fix(sync): check the model in prompt files at plan time (AIC-3647) - #1062

Open
nkester-ld wants to merge 9 commits into
mainfrom
AIC-3647/nkester/model-validation
Open

nkester-ld wants to merge 9 commits into
mainfrom
AIC-3647/nkester/model-validation

Conversation

@nkester-ld

@nkester-ld nkester-ld commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Human

The bug

Sync never checked the model: block of a prompt file. You could set modelName: gpt-4o on the Anthropic.claude-haiku-4-5 model config, and sync pushed it; LaunchDarkly stored the wrong name. modelName: with no value re-pushed on every run and never settled. And with modelConfigVersion pinned, sync skipped looking up the model config at all, so a bad key passed the dry run and --yes created the config before failing.

Failure and reason for change

  • What failed: blitz report (AIC-3647): "I edited the model name to be something totally different, not sure if it sync'd". Reproduced locally on 2026-11-25: the mismatched name was stored as-is; modelName: with no value planned "" → null forever; a bad key with a pinned version made a partial write.
  • Why this changes it: these are checks on what you typed, so they belong in ldcli before anything is written. gonfalon already rejects a missing key or version; it doesn't check modelName, and the UI itself sometimes stores the model config key there, so a server-side check would break existing data.

What changes

File says Before After
modelName: gpt-4o on the Anthropic.claude-haiku-4-5 model config pushed, and LaunchDarkly stored the wrong name refused before anything is written. Model name needs to match the model config. The error names both models: the file says gpt-4o, but the model config uses claude-haiku-4-5. It suggests using claude-haiku-4-5 or removing modelName.
modelName: (no value) re-pushes forever refused when the file is read: model.modelName must be text, suggestion Set it to the model config's name, or remove modelName.
bad key + modelConfigVersion: 1 clean dry run, then config created and 404 refused at plan time, nothing written
pinned version above the latest fails at write time model config "…" has no version 5, suggestion Its latest version is 2. Pin that version, or remove modelConfigVersion.

Pinned files (what sync prompts add writes) are checked against the pinned version's model name: the latest model config when the pin is the latest, otherwise the version list (listModelConfigVersions), fetched only when the name differs from LaunchDarkly's and cached per run.

Golden path

A prompt file pulled with ldcli sync prompts add names its model like this, and every step below syncs or refuses before anything is written:

modelConfigKey: Anthropic.claude-haiku-4-5
modelConfigVersion: 1
model:
  modelName: claude-haiku-4-5
  1. Pull it: ldcli sync prompts add --project P --config-key C --key K. The file matches LaunchDarkly; ldcli sync prompts --dry-run says No changes.
  2. Change the prompt or parameters and push: the model check passes (the name is the model config's id) and the push goes through.
  3. Switch models: change modelConfigKey to another model config and modelName to that config's id (or remove modelName), then push.
  4. Switch models the wrong way. Change modelConfigKey but keep the old modelName, or type a name that isn't the model config's. The plan stops with an error that names both models: the one in the file and the one the model config uses. Nothing is pushed. The full error reads:
    model "gpt-4o" does not match model config "Anthropic.claude-haiku-4-5", whose model is "claude-haiku-4-5" (code: invalid_reference)
    Suggestion: Use that name, or remove modelName.
    

Edge cases

File Result
modelName = the model config's id accepted
modelName = the model config's key (some UI paths store this) accepted
modelName that LaunchDarkly already holds for this variation under the same model config, even if it's neither (legacy data). A pinned file also needs the same pinned version; an unpinned file needs LaunchDarkly to pin the latest version or none, because the push stamps the latest accepted; only an edit is checked
no model: block accepted; the name comes from the model config
modelName: "" refused: model.modelName is empty (code: invalid_source), suggestion Set it to the model config's name, or remove modelName. Accepted only when LaunchDarkly already holds "" for this variation (gonfalon stores "" for a missing name)
modelName: with no value, or not text refused when the file is read: model.modelName must be text…
modelConfigKey that doesn't exist (pinned or not) refused at plan time: model config "…" was not found in project "…"; no config is created
modelConfigVersion above the latest, or below 1 refused: model config "…" has no version N, suggestion names the latest. Versions run 1 to latest with no gaps, so nothing else needs the version list
pinned file whose key and version LaunchDarkly already holds in sync; no lookup, so a model config LaunchDarkly no longer lists does not block the run
pin moved to another version, name unchanged checked against the new version's name
pinned to an older version whose model name differs from the latest checked against that version's name (listModelConfigVersions, fetched only when the name differs from LaunchDarkly's)
global model configs (version 0) name checked against the current config; no version bounds

Known limits: a wrong name an older ldcli already pushed is accepted until someone edits it, because it's indistinguishable from a name the UI wrote. A file whose modelName isn't text stops every run, scoped or not, like the existing model.parameters must be an object check.

Review focus

  • The name check needs LaunchDarkly's copy, so canonicalizeLocalVariationModels now runs after the server reads in planVariationRows (state.go).
  • Every refusal is a sync Problem tied to the variation with .WithResource(id), like other plan-time refusals: invalid_reference for a wrong name, a missing model config or an out-of-range pin; invalid_source for an empty name. A missing model config wraps the API's 404 with WrapProblem, so IsNotFound still works; a failed versions lookup has its own message (LaunchDarkly did not return the versions of model config …) → model_config.go.
  • The "must be text" check runs only where local front matter is read (local/variation.go), not in Variation.Validate, so data from LaunchDarkly never trips it during fingerprinting.

Testing

go test ./... and golangci-lint pass. New acceptance tests cover each row above, plus in-sync files that keep a LaunchDarkly-written name.

Ticket: AIC-3647

🤖 Generated with Claude Code


Note

Overview
Prompt sync now validates model.modelName before any write, fixing cases where a mismatched name was pushed, empty/null modelName caused endless sync loops, and bad modelConfigKey + pinned version slipped through dry-run then partially created resources.

Parse time (local/variation.go): non-text or invalid model: shapes are rejected when the prompt file is read (model.modelName must be text, etc.). Fingerprints from LaunchDarkly are unaffected.

Plan time (canonicalizeLocalVariationModels in model_config.go): after server state is loaded (state.go reorder), each variation checks that modelName matches the model config key or the id of the pinned/latest version; empty names, missing keys, out-of-range pins, and version-list failures become invalid_reference / invalid_source problems tied to the variation. Unchanged names already held in LaunchDarkly under the same config/version are skipped so legacy UI values stay accepted.

API: adds paginated ModelConfigVersions on the catalog client for pinned older versions when a name check needs the version’s model id.

Reviewed by Cursor Bugbot for commit 3bb5ab5. Bugbot is set up for automated code reviews on this repo. Configure here.


Related Jira issue: AIC-3647: [blitz] Check the prompt model against the model-list endpoint

nkester-ld and others added 7 commits November 25, 2026 11:42
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…use pins above the latest version

- D7: a modelName equal to the model config's id or key is valid, and a
  name LaunchDarkly already holds for the variation is never refused. The
  check now runs after the server read in planVariationRows.
- A pinned modelConfigVersion above the latest version is refused at plan
  time with a not_found message naming the variation, key and version.
- S1 message now says "or remove modelName".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l config

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ersion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nkester-ld
nkester-ld marked this pull request as ready for review November 25, 2026 20:13
@nkester-ld
nkester-ld requested a review from a team as a code owner November 25, 2026 20:13
@nkester-ld
nkester-ld requested review from tiffanylphan and removed request for a team November 25, 2026 20:13

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bfdceef. Configure here.

Comment thread internal/sync/prompt/model_config.go Resolved
nkester-ld and others added 2 commits November 25, 2026 13:27
Sync checks the type of modelName only when it reads a local file.
A pinned variation that LaunchDarkly holds with the same model config key
and version does not need its model config. The held-name exemption now
also needs the same pinned version. A not-found error from the versions
lookup is an invalid reference that names the variation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unpinned file uses the latest model config version. A name that
LaunchDarkly holds under an older pin is now checked against the latest
version. A pin below 1 is refused at plan time. A versions lookup that
returns 404 has its own message.

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.

1 participant