Skip to content

docs: clarify prompt linking for Python generations - #3290

Merged
hassiebp merged 3 commits into
mainfrom
hassiebbot/docs-prompt-linking-propagation
Jul 11, 2026
Merged

docs: clarify prompt linking for Python generations#3290
hassiebp merged 3 commits into
mainfrom
hassiebbot/docs-prompt-linking-propagation

Conversation

@hassiebp

@hassiebp hassiebp commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • recommend passing prompt=prompt directly when creating or updating a Langfuse generation
  • document propagate_attributes(prompt=prompt) for multiple generations that intentionally share one prompt version
  • add a LiteLLM example for third-party OpenTelemetry instrumentation that creates generations outside the Langfuse SDK API
  • clarify support for OpenAI Agents SDK and OpenInference instrumentation, generation-only linking, explicit prompt precedence, and the Python SDK 4.14.0 requirement

Why

Python SDK 4.14.0 added prompt propagation for cases where users cannot pass a prompt directly to each generation, especially third-party instrumentation. Direct prompt assignment remains the preferred approach for individual Langfuse observations because it scopes the link to the intended generation.

Related SDK change: langfuse/langfuse-python#1750

Validation

  • pnpm run format
  • pnpm run format:check
  • node scripts/check-h1-headings.js
  • git diff --check
  • rendered /docs/prompt-management/features/link-to-traces locally (HTTP 200)

Greptile Summary

This PR updates components-mdx/prompt-linking.mdx to clarify prompt-linking behavior for the Langfuse Python SDK and document two new patterns introduced in SDK v4.14.0.

  • Direct prompt passing is now explicitly recommended as the preferred approach for individual generations, with updated introductory text and existing code examples preserved.
  • propagate_attributes(prompt=prompt) is documented for two scenarios: sharing a prompt across multiple generations within the same context, and third-party instrumentation libraries (e.g., LiteLLM, OpenAI Agents SDK, OpenInference) that create generations without exposing a Langfuse prompt argument.

Confidence Score: 5/5

This is a documentation-only change — no runtime code, API contracts, or build configurations are modified. Safe to merge.

The change adds two new documentation sections and refines the existing intro paragraph. All code examples are syntactically correct, imports appear at the top of each snippet, and the SDK version requirement (4.14.0+) is clearly stated. No broken links or structural MDX issues are introduced.

No files require special attention.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User fetches Langfuse prompt] --> B{How are generations created?}

    B -->|Langfuse SDK directly| C{Single or multiple generations?}
    B -->|Third-party instrumentation\ne.g. LiteLLM, OpenAI Agents SDK| D[propagate_attributes prompt=prompt]

    C -->|Single generation| E[Pass prompt= directly\nto generation / update_current_generation]
    C -->|Multiple generations\nsharing same prompt version| F[propagate_attributes prompt=prompt]

    E --> G[Generation linked to prompt]
    F --> H[All generation observations\nin context linked to prompt]
    D --> H

    H --> I{Does a generation set\nits own prompt explicitly?}
    I -->|Yes| J[Explicit prompt takes\nprecedence over propagated prompt]
    I -->|No| K[Propagated prompt is used]

    J --> L[Prompt linked in Langfuse UI]
    K --> L
    G --> L
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[User fetches Langfuse prompt] --> B{How are generations created?}

    B -->|Langfuse SDK directly| C{Single or multiple generations?}
    B -->|Third-party instrumentation\ne.g. LiteLLM, OpenAI Agents SDK| D[propagate_attributes prompt=prompt]

    C -->|Single generation| E[Pass prompt= directly\nto generation / update_current_generation]
    C -->|Multiple generations\nsharing same prompt version| F[propagate_attributes prompt=prompt]

    E --> G[Generation linked to prompt]
    F --> H[All generation observations\nin context linked to prompt]
    D --> H

    H --> I{Does a generation set\nits own prompt explicitly?}
    I -->|Yes| J[Explicit prompt takes\nprecedence over propagated prompt]
    I -->|No| K[Propagated prompt is used]

    J --> L[Prompt linked in Langfuse UI]
    K --> L
    G --> L
Loading

Reviews (1): Last reviewed commit: "Merge branch 'main' into hassiebbot/docs..." | Re-trigger Greptile

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
langfuse-docs Ready Ready Preview, Comment Jul 11, 2026 9:55am

Request Review

@hassiebp hassiebp changed the title docs: document propagated prompt linking docs: clarify prompt linking for Python generations Jul 11, 2026
@hassiebp
hassiebp marked this pull request as ready for review July 11, 2026 09:49
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 11, 2026
@github-actions

Copy link
Copy Markdown

@claude review

@dosubot dosubot Bot added the documentation Improvements or additions to documentation label Jul 11, 2026
@hassiebp
hassiebp merged commit 3e57180 into main Jul 11, 2026
13 of 14 checks passed
@hassiebp
hassiebp deleted the hassiebbot/docs-prompt-linking-propagation branch July 11, 2026 09:50

@claude claude 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.

LGTM, docs-only clarification of prompt linking for the Python SDK.

Extended reasoning...

Overview

The PR edits a single MDX include (components-mdx/prompt-linking.mdx) used on the prompt-management link-to-traces page. It reframes the Python tab to recommend passing prompt=prompt directly on each generation, and adds two new subsections documenting propagate_attributes(prompt=prompt) — one for grouping multiple Langfuse generations, and one for third-party OTel instrumentation (LiteLLM example) that cannot forward a Langfuse prompt argument.

Security risks

None. Content-only change with no executable code, no auth/permissions, no user input handling.

Level of scrutiny

Low. This is user-facing documentation with no runtime impact on the site beyond rendering the MDX. The internal link to /integrations/frameworks/litellm-sdk resolves to an existing page (content/integrations/frameworks/litellm-sdk.mdx), and no anchors are introduced that need explicit [#anchor] definitions.

Other factors

The bug hunting system found no issues. The author states pnpm run format, format:check, the H1 check, and git diff --check were all run locally, and the page was rendered via the dev server. Copy is clear, follows the existing tab structure, and correctly notes the SDK version requirement (4.14.0) and precedence semantics between propagated and explicit prompts.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59b05e9826

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

langfuse = get_client()
prompt = langfuse.get_prompt("movie-critic")

with propagate_attributes(prompt=prompt):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove unsupported prompt propagation example

For users copying this Python SDK example with the stated 4.14.0 release, propagate_attributes(prompt=prompt) raises TypeError: got an unexpected keyword argument 'prompt'; the released propagate_attributes API only accepts trace attributes such as user_id, session_id, metadata, version, tags, trace_name, environment, and as_baggage. This makes the new recommended path unusable, and the same unsupported call is repeated in the LiteLLM example below.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant