Repository navigation
fix(prompts): preserve literal values in LangChain prompt conversion - #2060
Open
remote-controlled-man wants to merge 4 commits into
Open
remote-controlled-man wants to merge 4 commits into
remote-controlled-man wants to merge 4 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Precompiled prompt values can contain braces, such as
Use {name}or{{question}}.get_langchain_prompt(context=...)currently turns those values into LangChain variables, causing missing-key errors or changing the supplied text during formatting.Keep supplied braces opaque while converting the template, then escape them for LangChain. Preserve the existing JSON conversion order and evaluate only referenced values. Apply this to text prompts, chat prompts and resolved message history. Unfilled variables still belong to LangChain; ordinary
compile()behavior is unchanged.Type of change
Verification
59 prompt-compilation tests pass, including literal-brace regressions through real LangChain templates. The initial regression run failed 8 cases on unchanged source. Backend e2e and live-provider tests were not run: this conversion is covered locally without a server or model requests.
Checklist
code_review.md.AI disclosure: OpenAI Codex found this during a source audit and prepared the patch, tests and description.


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
The PR keeps braces in supplied values literal when converting text and chat prompts for LangChain.
No actionable issues were found.
Reviews (1) · Last reviewed commit: "fix(prompts): avoid evaluating unused co..." · Reviewed by Greptile