langfuse icon indicating copy to clipboard operation
langfuse copied to clipboard

bug: impossible to remove prompt labels using Python SDK or API

Open igonro opened this issue 1 year ago • 9 comments

Describe the bug

I have one prompt with the labels: ["latest", "candidate"]. After a "competition" vs the productin prompt version, I want to promote it to production and remove the "candidate" label.

I've tried:

langfuse.update_prompt(
    name="my-prompt",
    version=3,
    new_labels=["production"],
)

And also:

response = langfuse.api.prompt_version._client_wrapper.httpx_client.request(
    "/api/public/v2/prompts/my-prompt/versions/3",
    method="PATCH",
    json={"newLabels": ["production"]},
)

But it doesn't work because of this: https://github.com/langfuse/langfuse/blob/44ce6ef58156bcf435412676134bfa88d00518f4/web/src/features/prompts/server/actions/updatePrompts.ts#L55

I understand that we won't be able to remove the "latest" label as it is managed internally, but for custom labels I think we should be able to do it. Maybe the default behaviour should stay like this, but give us a remove_labels: bool parameter or something to remove labels.

Steps to reproduce

  1. Set a prompt version with several labels, e.g. ["production", "candidate"].
  2. Try to remove the "candidate" label (without assigning it to any other version).

Langfuse Cloud or self-hosted?

Self-hosted

If self-hosted, what version are you running?

langfuse/langfuse:3@sha256:08ed9568b8d51825b15279e6d66809eece630d5035cfaa7f706d9a2dbdd097bc

SDK and integration versions

No response

Additional information

No response

Are you interested in contributing a fix for this bug?

No

igonro avatar Sep 21 '25 17:09 igonro

Hi @igonro! I'm Dosu and I’m helping the langfuse team.

You're correct—removing custom labels from a prompt version via the Python SDK or API isn't currently possible. The backend logic always merges the new labels you provide with the existing ones, so labels like "candidate" remain even if you omit them in your update call. This is enforced in the backend code, which creates a union of old and new labels and never actually removes any from the current prompt version, regardless of what you send in the PATCH request (source).

The "latest" label is managed internally and can't be removed or changed manually, but the same restriction currently applies to custom labels due to this logic. There is no hidden or undocumented way to remove custom labels via the API or SDK, and recent updates haven't changed this behavior.

A remove_labels parameter or similar feature would require a change to the backend logic. For now, the only way to remove a label is to wait for a feature update that supports this use case.

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about langfuse with Dosu Add Dosu to your team

dosubot[bot] avatar Sep 21 '25 17:09 dosubot[bot]

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Oct 24 '25 02:10 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale. Please reopen if the issue persists.

github-actions[bot] avatar Nov 07 '25 02:11 github-actions[bot]

Has there been any solution to this? I am happy to work on a solution if no one else is

rushabhvaria avatar Feb 28 '26 01:02 rushabhvaria

Has there been any solution to this? I am happy to work on a solution if no one else is

I think this problem still persists. Do you have any solution for it?

martinvalentine avatar Mar 17 '26 08:03 martinvalentine

Any news about this feature?

lsaint avatar Jul 13 '26 04:07 lsaint

Hello! Any news about this feature? Our team is trying to perform some automated prompt reviewing and we'd like to axe some outdated labels. If it's not planned, any suggestions on going around it?

ryanpapetti-studocu avatar Nov 12 '26 11:11 ryanpapetti-studocu

hi all, thank you for pushing on this. we will take a look

nimarb avatar Nov 12 '26 12:11 nimarb

@ryanpapetti-studocu you can now remove labels via api its live on could sdk and oss releases are following https://api.reference.langfuse.com/#tag/promptversion/PATCH/api/public/v2/prompts/{name}/versions/{version}

tobi12345 avatar Nov 12 '26 15:11 tobi12345