gemini-cli - 💡(How to fix) Fix Bug: LLM prompt builders corrupt content containing $ sequences [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

What happened?

Several internal prompt builders interpolate user/file content into a template with String.prototype.replace('{placeholder}', value). The replacement argument honors special patterns ($$, $&, $`, $') even when the search is a plain string, so any value containing $ is silently corrupted before the prompt is sent to the model:

input fragmentbecomes
$&the placeholder name, e.g. {current_content}
$$a single $
$`everything in the prompt before the placeholder (dumps the template)
$'everything after the placeholder (truncates the content)

For example, a file containing echo $$ > pid.txt is sent to the edit-correction model as echo $ > pid.txt, and content containing $` leaks the prompt template into the <file_content> block.

Affected call sites:

  • packages/core/src/utils/llm-edit-fixer.ts (edit self-correction prompt)
  • packages/core/src/utils/summarizer.ts (tool-output summarizer)
  • packages/core/src/services/sessionSummaryService.ts (session summary)

These routinely receive file contents, shell output, and conversation text, all of which can contain $. The same code shape additionally has a sequential-interpolation issue: a placeholder token (e.g. {current_content}) appearing inside one input value can be re-substituted by a later replacement.

What did you expect to happen?

Content should be inserted into prompts verbatim, regardless of $ sequences or placeholder-looking substrings.

Additional context

A fix is proposed in #27552 (single-pass replacement using a replacer function).

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix Bug: LLM prompt builders corrupt content containing $ sequences [1 pull requests]