Skip to content

fix: exclude expanded tools from prompt diffs - #957

Open
ctawiah wants to merge 2 commits into
mainfrom
ctawiah/fix-prompt-tool-diff-5b1c
Open

ctawiah wants to merge 2 commits into
mainfrom
ctawiah/fix-prompt-tool-diff-5b1c

Conversation

@ctawiah

@ctawiah ctawiah commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Context

LaunchDarkly can return one attached tool in two forms. The response has a top-level tools reference and an expanded model.parameters.tools value.

ldcli treated the expanded copy as a model setting. The plan reported a model change and a pull wrote the expanded tool into the local file.

What changes

  • Normalize response models before planning or applying changes.
  • Reuse the same model canonicalization for fingerprints and rendered diffs.
  • Keep real model parameter changes visible.
  • Add API, fingerprint, plan, output, and apply regression coverage.

The review output now changes as follows:

Before: pull production/support/default  instructions, model changed in LaunchDarkly
After:  pull production/support/default  instructions changed in LaunchDarkly

Design notes

  • Top-level tool and skill references own attachment links and versions.
  • CanonicalModel removes only the API-expanded model.parameters.tools value, and only when the variation has tool references. A legitimate model.parameters.skills value remains.
  • A tools model parameter remains unchanged when the variation has no tool attachment.
  • API decoding normalizes before apply. Fingerprints and diffs call the same helper as a safety measure.

Review focus

  • Can canonicalization hide a real model parameter change?
  • Does a pull keep attachment references and never write expanded tool definitions?

Verification

  • go test ./...
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0 run
  • make build
  • TestPromptDiffExcludesExpandedToolsFromModelParameters failed on main and passes with this change.
  • TestCatalogClientConfigRemovesExpandedToolsFromModelParameters and TestFingerprintVariationExcludesExpandedToolParameters make sure that a model.parameters.skills value stays in the decoded model and changes the fingerprint.

Related changes

This stack builds on #937 to #941, which are merged.

  1. This PR: exclude expanded tools from prompt diffs (ctawiah/fix-prompt-tool-diff-5b1c)
  2. fix: plan a tool or skill row when a variation newly references it #945: Plan a tool or skill row when a variation newly references it (ctawiah/plan-referenced-attachments-1e8a)
  3. feat: keep unused tools and skills, and detach any resource kind #946: Keep unused tools and skills, and detach any resource kind (ctawiah/keep-unused-attachments-1e8a)
  4. feat: add tools and skills from LaunchDarkly #947: Add tools and skills from LaunchDarkly (ctawiah/add-attachments-1e8a)
  5. feat: route sync, add, and detach by scope #948: Route sync, add, and detach by scope (ctawiah/route-scopes-1e8a)
  6. feat: add the sync all, sync tools, and sync skills commands #949: Add the sync all, sync tools, and sync skills commands (ctawiah/scope-commands-1e8a)
  7. feat: create a tool or a skill from the content of an add #950: Create a tool or a skill from the content of an add (ctawiah/create-attachments-1e8a)
  8. feat: add the create flags of sync tools add and sync skills add #951: Add the create flags of sync tools add and sync skills add (ctawiah/create-attachment-flags-1e8a)
  9. refactor: share the selection of a new variation, and check any kind before an add #952: Share the selection of a new variation, and check any kind before an add (ctawiah/share-variation-selection-1e8a)
  10. feat: create a prompt variation from the content of an add #953: Create a prompt variation from the content of an add (ctawiah/create-variations-1e8a)
  11. feat: add the create flags of sync prompts add #954: Add the create flags of sync prompts add (ctawiah/create-variation-flags-1e8a)

Note

Overview
LaunchDarkly can echo attached tools both as top-level tools refs and as expanded model.parameters.tools. ldcli was treating that duplicate as a real model change, so sync plans, diffs, fingerprints, and pulls could show or persist bogus model updates.

This PR introduces shared CanonicalModel normalization that drops API-expanded parameters.tools when the variation has tool references (while keeping other parameters, including parameters.skills, and still stripping empty custom / parameters maps). It runs when decoding catalog config responses, when computing variation fingerprints, and when building prompt diff JSON—so planning, review output, and apply paths agree.

User-visible effect: a pull/diff that only differs in instructions no longer reports “model changed” just because the server returned expanded tool definitions; real parameter changes (e.g. temperature) still surface. Regression tests cover API decode, fingerprints, plan diffs, and end-to-end prompt sync/apply.

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

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