test(redteam): cover RedTeamCase metadata sync and _build_system_prompt assembly - #301
Open
zeroshotmind wants to merge 1 commit into
Open
Conversation
zeroshotmind
had a problem deploying
to
manual-approval
July 7, 2026 21:46 — with
GitHub Actions
Failure
zeroshotmind
had a problem deploying
to
manual-approval
July 7, 2026 21:46 — with
GitHub Actions
Failure
…pt assembly
RedTeamCase._sync_metadata_from_config (case.py) and _build_system_prompt
(strategies/_common.py) had no direct unit tests — only incidental exercise
via fixture setup in other strategy test files. Neither behavior was
actually asserted:
- RedTeamCase: metadata=None population, setdefault-style preservation of
caller-provided keys over attack_goal values, partial backfill, and the
empty-dict (falsy but not None) branch.
- _build_system_prompt: that it includes and correctly orders all six
shared prompt blocks, joins them with a blank line, and leaves the
{actor_profile}/{max_turns} placeholders for callers to fill in later.
zeroshotmind
force-pushed
the
test/redteam-case-and-common-coverage
branch
from
July 7, 2026 21:49
bc2a2b6 to
0a53c80
Compare
zeroshotmind
had a problem deploying
to
manual-approval
July 7, 2026 21:49 — with
GitHub Actions
Failure
zeroshotmind
had a problem deploying
to
manual-approval
July 7, 2026 21:49 — with
GitHub Actions
Failure
pgrayy
reviewed
Jul 9, 2026
Member
There was a problem hiding this comment.
For consistency, I would recommend placing this under the directory redteam/strategies/. This also helps directly map the test module to its src module.
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.
Description
Two small pieces of
experimental/redteamlogic had no direct unit tests — only incidental exercise as fixture setup inside other strategy test files, which never asserted their actual behavior:RedTeamCase._sync_metadata_from_config(case.py): themodel_validatorthat mergesAttackGoalfields intometadata. Untested branches:metadata=Nonegets fully populated fromattack_goal; caller-provided keys are preserved (setdefaultsemantics — config never overwrites an existing key); partial metadata is backfilled for missing keys only; and an explicit empty dict (falsy but notNone) still takes the "existing metadata" branch rather than the "populate" branch._build_system_prompt(strategies/_common.py): the helper that assembles the six shared prompt blocks (ROLE_BLOCK,PROFILE_BLOCK, playbook,RULES_BLOCK,EXIT_BLOCK,FORMAT_BLOCK) used by every prompt-based strategy. Untested: that all blocks are present, in the correct order (block order is load-bearing for the{actor_profile}/{max_turns}placeholders filled in later via.format()), joined with a blank line, and that those placeholders survive assembly unconsumed.This is a test-only PR — no production code changes. Adds
tests/strands_evals/experimental/redteam/test_case.pyandtests/strands_evals/experimental/redteam/test_common.py.Related Issues
None — found via a review of test coverage gaps in
experimental/redteam/, not filed as an issue first since it's test-only and additive.Documentation PR
N/A
Type of Change
Tests only
Testing
python -m pytest tests/strands_evals/experimental/redteam/— 326 passed (previously 319; +7 new)ruff format --checkandruff checkclean on the new filesmypyclean on the new filesChecklist