fix(ai-red-teaming): import get_generator in generated agentic script#101
Merged
Conversation
Same missing-import bug as the ATLAS template (#100), in the separate `_build_agentic_imports`: generated agentic-attack scripts call get_generator (proxy-routing block) but never imported it, raising NameError at runtime. Add the import and a TestAgenticGeneration regression test (the agentic generator was previously untested).
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.
Summary
Same class of bug as #100, in a different code path. Generated agentic attack scripts (
generate_agentic_attack) callget_generator(...)in the proxy-routing block but_build_agentic_importsnever imported it, so every generated agentic script raisedNameError: get_generatorat runtime. This path was previously untested, so it went unnoticed.Fix
from dreadnode.generators.generator import get_generator, GenerateParamsto_build_agentic_imports.TestAgenticGenerationwith a static regression assertion (import + usage present) —compile()only checks syntax, not name resolution.Scope
Audited all six imports builders.
_build_imports,_build_atlas_imports(fixed in #100) and_build_multimodal_importsalready import it._build_image_imports/_build_tabular_importsomit it too, but their generators do NOT include the proxy-routing block (noget_generatorusage), so no runtime error — left unchanged to avoid an unused import.Validation
pytest -k "Agentic or Atlas"→ 11 passed.