fix(generator): don't double braces in a review prompt that never reaches format() - #935
Open
tend-agent wants to merge 1 commit into
Open
fix(generator): don't double braces in a review prompt that never reaches format()#935tend-agent wants to merge 1 commit into
tend-agent wants to merge 1 commit into
Conversation
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.
Problem
generate_reviewis the only generator that emits the prompt inside a GitHub Actions expression, and it escapes braces forformat()unconditionally — including on the path whereformat()is never used._escape_bracesdoubles every brace that isn't the{pr_number}placeholder. That is correct going intoformat(), which collapses each{{/}}pair back to a single brace. Butgenerate_reviewonly wraps the result informat()when the placeholder was actually found:An adopter whose
workflows.review.promptcontains braces but no{pr_number}gets the doubled pairs written straight into a bare string literal. Reproduced againstmain(fd23cd0) withprompt: "Review this PR. Use the {code-review} skill.":Nothing downstream collapses that pair —
format()is what does the collapsing and it isn't in the expression. So the agent receives{{code-review}}where the adopter wrote{code-review}, and the doubled}}also lands inside a${{ … }}expression, which is not a shape the generator should be emitting either way.Only
reviewis affected: every other workflow renders its prompt as a plain YAML block scalar (block_promptinmacros.yaml.j2, and the literal bodies inci-fix.yaml.j2/mention.yaml.j2), so no brace escaping is involved.Solution
Return the prompt untouched when the placeholder isn't present. Escaping is a
format()concern, so it now happens only on the branch that produces aformat()call.Testing
Two tests in
test_generate.pypin the two branches — braces preserved without the placeholder, braces doubled and{pr_number}→{0}with it. The first fails onmain:test_prompt_with_numbered_placeholdersintest_config_edge_cases.pypinned the old output and had to change — worth a look, since it's a test asserting the defect rather than an incidental snapshot. Its rationale was "escaped to preventformat()runtime errors", but its fixture ("Fix issue {1} and {2}") has no{pr_number}, so noformat()call is generated and there is no runtime error to prevent. It now asserts the prompt is emitted verbatim. The siblingtest_prompt_with_zero_placeholder, whose fixture does carry{pr_number}, is unchanged and still passes.Full generator suite: 387 passed.
ruff check/ruff format --checkat the pinnedv0.14.11are clean.Scope
No generated file in this repo changes — tend's own
.config/tend.yamlsets no custom review prompt, and the default (/tend-ci-runner:review {pr_number}) carries the placeholder, so it takes theformat()branch as before. The behavior change is visible only to an adopter with a brace-carrying custom review prompt, whose next regen will drop the spurious doubling.