Skip to content

Enforce soft_probe_prompt_cap in GCGCached probe#1665

Open
precognitivem0nk wants to merge 2 commits intoNVIDIA:mainfrom
precognitivem0nk:fix/gcgcached-prompt-cap-1562
Open

Enforce soft_probe_prompt_cap in GCGCached probe#1665
precognitivem0nk wants to merge 2 commits intoNVIDIA:mainfrom
precognitivem0nk:fix/gcgcached-prompt-cap-1562

Conversation

@precognitivem0nk
Copy link
Copy Markdown

Fixes #1562

GCGCached builds its full prompt list at class definition time (13 suffixes × 2 base prompts = 26 prompts) and never consults run.soft_probe_prompt_cap. This means setting a cap has no effect on how many prompts GCGCached issues.

This PR adds an __init__ method that calls self._prune_data(self.soft_probe_prompt_cap) after super().__init__(), following the same pattern used by DanInTheWild in dan.py. When the cap is set lower than the total prompt count, prompts are randomly sampled down to the cap.

Verified locally: with soft_probe_prompt_cap = 10, GCGCached now produces 10 prompts instead of 26. Added a test in tests/probes/test_probes_suffix.py to confirm the behavior.

Signed-off-by: precognitivem0nk <rextedgorman@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

DCO Assistant Lite bot All contributors have signed the DCO ✍️ ✅

@precognitivem0nk
Copy link
Copy Markdown
Author

I have read the DCO Document and I hereby sign the DCO

Copy link
Copy Markdown
Collaborator

@leondz leondz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor tweaks, but generally good, thanks

Comment thread garak/probes/suffix.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reasonable

Comment thread tests/probes/test_probes_suffix.py Outdated
Comment on lines +9 to +16
_config.run.soft_probe_prompt_cap = 10
try:
from garak.probes.suffix import GCGCached

probe = GCGCached()
assert (
len(probe.prompts) <= 10
), f"GCGCached has {len(probe.prompts)} prompts, expected at most 10"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 10 is used in the three places, recommend making it a var

@leondz
Copy link
Copy Markdown
Collaborator

leondz commented Apr 7, 2026

nb. @precognitivem0nk

You can retrigger this bot by commenting recheck in this Pull Request

@precognitivem0nk
Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Apr 21, 2026
@precognitivem0nk
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

precognitivem0nk added a commit to precognitivem0nk/garak that referenced this pull request Apr 21, 2026
Address leondz's review comment on NVIDIA#1665: the literal 10 was
duplicated across three places in the test (the cap setter, the
length assertion, and the assertion message). Factor it out into
a local variable named cap.

No behavior change.

Signed-off-by: precognitivem0nk <rextedgorman@gmail.com>
Address leondz's review comment on NVIDIA#1665: the literal 10 was
duplicated across three places in the test (the cap setter, the
length assertion, and the assertion message). Factor it out into
a local variable named cap.

No behavior change.

Signed-off-by: precognitivem0nk <rextedgorman@gmail.com>
@precognitivem0nk precognitivem0nk force-pushed the fix/gcgcached-prompt-cap-1562 branch from 570f2b5 to 450ca0d Compare April 21, 2026 04:20
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.

probe: probes should follow soft_probe_prompt_cap

2 participants