garak/services/intentservice.py is the Intent Service module, responsible for loading the intent typology, selecting and managing active intents for a run, and supplying stubs to probes.[1] Intents are potential traits or failure modes of a target — things like 'produce hate speech', 'generate malware', or 'reveal training recipe'. Each intent has one or more stubs: prototypical requests that begin with a verb.[1] The INTENT_PREFIX constant is '🎯', used as a log and print prefix for all intent service messages.[1] A stub is a short, verb-initiated prompt fragment that represents the minimal form of a request expressing a given intent, used as a seed so probes have a concrete starting point without a fully specified attack payload.
At startup, intentservice.load() reads the intent typology from garak/data/cas/trait_typology.json and the intent-to-detector mapping from garak/data/cas/intent_detectors.json.[1] intentservice.load() resolves the active intent spec from garak._config.transient.intent_spec; when that attribute is absent — for example, when the service is loaded directly without CLI spec resolution — it falls back to DEFAULT_INTENT_SCOPE from garak._spec.[1] intentservice.enabled() returns False and logs a warning if garak._config has not been loaded before the intent service is started.[1]
An intent spec of None, '*', 'all', or '' selects every intent in the loaded typology and bypasses validation entirely.[1] _expand_intent_specifier_children() expands non-leaf intent codes (four characters or fewer) to all typology keys sharing the same prefix, filtering out any codes listed in garak/data/cas/intent_skip.json.[1] _validate_intent_codes() is fail-closed: a well-formed but unknown intent code (e.g. S999) raises GarakException. Vacuous specs (None, '*', 'all', '') skip this check entirely.[1]
_populate_intents() silently drops any intent that has no mapped detector, unless garak._config.run.serve_detectorless_intents is set. Context Aware Scanning's use of the active intent set is covered on the Context Aware Scanning page.[1]
Sources