Skip to content

fix(cli): match instruction state placeholder syntax in create_empty_state - #8410

Open
kingroyale537 wants to merge 1 commit into
google:mainfrom
kingroyale537:fix/create-empty-state-instruction-placeholders
Open

kingroyale537 wants to merge 1 commit into
google:mainfrom
kingroyale537:fix/create-empty-state-instruction-placeholders

Conversation

@kingroyale537

Copy link
Copy Markdown

Fixes #8409.

create_empty_state() previously matched placeholders with r'{([\w]+)}', which missed prefixed state keys ({user:x}, {app:x}, {temp:x}) and whitespace-padded placeholders ({ topic }) accepted by inject_session_state(), causing KeyError: Context variable not found when evaluating cases generated from sessions.

Reuse _TEMPLATE_VAR_PATTERN and _is_valid_state_name from flows/llm_flows/prompt/_instructions_utils.py so create_empty_state() seeds the exact same state keys that inject_session_state() requires.

@google-cla

google-cla Bot commented Nov 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

Eval cases created from a session fail with "Context variable not found" when the instruction uses {user:x}, {app:x} or { x }

1 participant