mirror of
https://github.com/google/adk-go.git
synced 2026-10-28 16:44:38 +08:00
* fix(llminternal): leave ${var} and \{var} placeholders literal
InjectSessionState substituted every {name} in an instruction, so text
such as "${expression}" or "\{expression}" either failed the LLM call
with "state key does not exist" or was silently rewritten.
adk-python skips placeholders preceded by $, { or \ via the negative
lookbehind (?<![\$\{\\]). RE2 has no lookbehind, so check the preceding
byte for each match instead, and port adk-python's test cases.
Closes: #1681
* docs(llmagent): name only $ and \ as literal placeholder prefixes
Fix the Config.Instruction doc, which wrongly listed { as a prefix that
keeps a placeholder literal; {{key}} is still substituted. Add the rule
to the GlobalInstruction and instructionutil.InjectSessionState docs.
Drop { from literalPlaceholderPrefixes since {+ always starts a match
at the first brace of a run, and add tests for a leading placeholder
(covers the startIndex > 0 guard) and for {{key}} substitution.
---------
Co-authored-by: Sasha <39381081+jjsasha63@users.noreply.github.com>