docs: clarify prompt linking for Python generations - #3290
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@claude review |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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): |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
prompt=promptdirectly when creating or updating a Langfuse generationpropagate_attributes(prompt=prompt)for multiple generations that intentionally share one prompt versionWhy
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 formatpnpm run format:checknode scripts/check-h1-headings.jsgit diff --check/docs/prompt-management/features/link-to-traceslocally (HTTP 200)Greptile Summary
This PR updates
components-mdx/prompt-linking.mdxto clarify prompt-linking behavior for the Langfuse Python SDK and document two new patterns introduced in SDK v4.14.0.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 Langfusepromptargument.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%%{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 --> LReviews (1): Last reviewed commit: "Merge branch 'main' into hassiebbot/docs..." | Re-trigger Greptile