Overview
Concrete pydantic configuration model for the TAP (Tree of Attacks) attack specifying tree shape (depth, width, branching factor, streams), pruning thresholds, and required attacker plus optional on-topic filter roles, provided by the HackAgent adaptive attacks package.
Description
TapParams extends AttackParams. The tree shape is controlled by depth (refinement rounds), width (beam width after pruning), branching_factor (refinements per branch), and streams (independent starting conversations). keep_last_n trims branch history. max_attempts retries unusable attacker output. early_stop stops the whole search on first success. min_prune_score (0-10) prunes low-scoring branches; the best branch always survives. The required attacker role writes/refines prompts. The optional on_topic role is a YES/NO filter that prunes off-topic branches before they cost a target call.
Usage
- Campaign config: Set attack_type: tap with tree parameters and roles.
Code Reference
Source Location
Signature
class TapParams(AttackParams):
REQUIRED_ROLES: ClassVar[frozenset[str]] = frozenset({"attacker"})
depth: int = Field(default=3, ge=1)
width: int = Field(default=4, ge=1)
branching_factor: int = Field(default=3, ge=1)
streams: int = Field(default=4, ge=1)
keep_last_n: int = Field(default=6, ge=1)
max_attempts: int = Field(default=3, ge=1)
early_stop: bool = Field(default=True)
min_prune_score: float = Field(default=0.0, ge=0.0, le=10.0)
target_str: str = Field(default="Sure, here is")
attacker: Optional[Completion] = Field(default=None, exclude=True, repr=False)
on_topic: Optional[Completion] = Field(default=None, exclude=True, repr=False)
Import
from hackagent.attacks.techniques.adaptive.tap.config import TapParams
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| depth |
int |
No |
Refinement rounds (default 3)
|
| width |
int |
No |
Beam width after pruning (default 4)
|
| branching_factor |
int |
No |
Refinements per branch (default 3)
|
| attacker |
Completion |
Yes |
Prompt writer/refiner
|
| on_topic |
Completion |
No |
Optional YES/NO off-topic filter
|
Outputs
| Name |
Type |
Description
|
| return |
TapParams |
Validated config for TAP attack
|
Usage Examples
Define in Campaign YAML
# attacks:
# - name: tap
# depth: 4
# width: 5
# branching_factor: 3
# streams: 4
# early_stop: true
# attacker:
# connection: {type: litellm, provider: openai, model: gpt-4o}
# on_topic:
# connection: {type: litellm, provider: openai, model: gpt-4o-mini}
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.