Substitute {placeholder} patterns in system message from env vars - #3
Open
MEllis-github wants to merge 3 commits into
Open
Conversation
The system message in configs can contain {placeholder} patterns
(e.g. {problem_statement}) but these were never substituted,
causing literal placeholder text to be sent to the LLM.
- Add _substitute_placeholders() resolving {name} from env var NAME
- Warn on first prompt build if unsubstituted placeholders remain
- Apply substitution in _get_system_message() after template lookup
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Format _KNOWN_TEMPLATE_VARS with black - Remove unused pytest import - Change _system_message_validated from class var to instance var so warnings fire per-instance rather than per-process Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
@MEllis-github One correctness issue: Minor: |
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
Bundled benchmark configs (e.g. benchmarks/frontier-cs-eval/config.yaml) use
{problem_statement} and {problem_constraints} placeholders in
prompt.system_message, but DefaultContextBuilder._get_system_message() returns the
raw string without substitution. The literal text {problem_statement} gets sent
to the LLM.
This is distinct from the known template variables ({current_program}, {metrics},
etc.) which are substituted in the user message via .format() — the system message
has no equivalent mechanism.
Fix
corresponding NAME environment variable (uppercase). Unresolved placeholders are
left as-is.
Includes tests for substitution, warning, and fallback behavior.
Alternative considered
Instead of env-var-based substitution, placeholders could be resolved via explicit
kwargs passed through build_prompt() (similar to how user message template vars
work). This would be more explicit and avoid potential collisions with shell
environment variables (e.g. {language} matching $LANGUAGE), but would require
changes to the Runner and config schema to thread values through. The env var
approach keeps the change contained to the context builder and matches how wrapper
scripts already inject problem-specific content.