Skip to content

fix(prompts): use each non-dict placeholder item as message content in compile - #1972

Open
moneebullah25 wants to merge 2 commits into
langfuse:mainfrom
moneebullah25:fix/placeholder-non-dict-items
Open

moneebullah25 wants to merge 2 commits into
langfuse:mainfrom
moneebullah25:fix/placeholder-non-dict-items

Conversation

@moneebullah25

@moneebullah25 moneebullah25 commented Oct 9, 2026 •

Copy link
Copy Markdown

What does this PR do?

When a chat prompt placeholder is filled with a list containing non-dict items (for example ["a", "b"]), ChatPromptClient.compile appended one message per item but set every message's content to str(placeholder_value), the stringified whole list. It now uses str(msg), the current item, so each item becomes its own message.

Fixes #1971

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Documentation update
  • Tooling, CI, or repo maintenance

Verification

List the main commands you ran:

uv run --frozen pytest tests/unit/test_prompt.py tests/unit/test_prompt_compilation.py -q
uv run --frozen ruff check langfuse/model.py tests/unit
uv run --frozen ruff format --check langfuse/model.py tests/unit/test_prompt.py tests/unit/test_prompt_compilation.py
uv run --frozen mypy langfuse

Results: 41 passed. 18 errors in tests/unit/test_prompt.py, all AttributeError: Langfuse client is not initialized raised from fixture setup; they are in tests this change does not touch (the changed parametrized case and the new test pass). The same 18 errors occur on main (40 passed, 18 errors there, without the new test), so they are pre-existing. ruff check, ruff format and uv run --frozen mypy langfuse are clean. The e2e tests were not run.

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added or updated tests for behavior changes.
  • I updated docs, examples, or .env.template if needed.
  • I did not hand-edit generated files; if generated files changed, I used the upstream regeneration path.
  • I did not commit secrets or credentials.

RetriggerConfidence Score: 5/5

This PR appears safe to merge.

Summary

Fixes ChatPromptClient.compile so each non-dictionary placeholder item becomes its own message content, rather than repeating the whole list.

  • Updates the mixed-list expectation.
  • Adds a regression test for two string items.
  • No actionable issues found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "fix(prompts): use each non-dict placehol..." · Reviewed by Greptile

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

This branch has not been deployed

No deployments
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.

bug: ChatPromptClient.compile appends str(whole list) once per non-dict placeholder item

1 participant