Context-aware scanning with garak intents and policies

garak's context-aware scanning tests whether a deployed model behaves acceptably for its own use case, using intents from a trait typology. This page covers what the feature adds, how to select intents, and what to confirm before relying on it.

On this page

Why context-aware scanning with garak intents matters for your deployment

garak's Context-Aware Scanning uses intents, which are target behaviours drawn from a trait typology, to test whether a model behaves acceptably for the role it has in a system. The feature is experimental. The garak reference documentation describes it as experimental and incomplete as of July 2026, so treat it as an addition to your scanning programme rather than a replacement for the established probe families. Your situation is likely familiar: a model sits inside a product where some behaviours are required, some are acceptable and some are never acceptable. A generic probe run checks for the same undesirable outputs in every deployment. Context-aware scanning asks a narrower question: given what this deployment is for, which behaviours should it refuse, and does it?

Teams need this when the answer to what counts as a failure depends on the product. A retail assistant that discusses product keys is a different case from a general chatbot, and a generic probe run will not separate those cases. The first IntentProbe arrived in garak v0.16.0, released on 4 August 2026, which added technique and intent annotation. Before you commit scan time to intents, confirm in the release notes which version you run, because experimental features can change between releases. Ask your security team to decide which behaviours the product must block before you select any intent, so the scan result maps to a policy someone owns.

The practical decision is whether your risk is generic or specific to the deployment. If your model has broad exposure, start with the probe families that cover common weaknesses, then add intent-based runs for the behaviours that your own policy singles out. Record the garak version and the intents used with each result, since a later rerun on a newer release may test different behaviours. Plan for the fact that intent coverage is incomplete: a clean intent result shows only that the tested intents passed, not that the deployment is safe in every context.

How a context-aware scan moves from policy to per-intent report

The scan starts with a deployment policy that states which behaviours the application should allow. The intent selector in --spec picks the intents to exercise, and the IntentProbe sends them to the generator under test, which sits on the target endpoint side of the trust boundary. Detectors and evaluation then score each attempt, and the JSONL report records results per intent. Check that the selector matches the policy and that the endpoint you test is the one users reach.

Policy and intent selector drive probes across the trust boundary to a per-intent report.

Which --spec intent selectors fit which scan goal

This table compares running garak's intent probes with no selector against a narrowed selector such as probes.grandma.GrandmaIntent,intent:S003productkeys. Read each row as a question about scope, run time and fit, and use the narrowed option when one deployment risk is the focus.

Scan goalNo selector (whole Safety branch S)Narrowed selector (single intent)
Scope of intents exercisedEvery intent under the Safety branch S, so coverage is broad across the typologyOnly the intent named in the selector, such as S003productkeys, so coverage is limited to that behaviour
Run time driverNumber of intents in branch S multiplied by generations and prompts per intentScales with the single selected intent, so run time is shorter and easier to estimate
Best fit for a first baselineYes, when you want an inventory of which behaviours the model or application exhibitsLess suited, because untested intents remain unknown
Best fit for a known deployment riskLess suited, because most results fall outside the risk you are assessingYes, when a specific behaviour is in scope for a release or review
Comparing runs over timeWorkable, but a larger run makes it harder to isolate which change moved resultsStrong, because a narrow run with a fixed selector gives a stable point of comparison
Effect of deployment policyResults may flag behaviours your deployment allows, so review them against your policyEasier to align with an explicit policy for the one intent under test
Inference costHigher, since every intent in the branch adds prompts and generationsLower, so it suits repeated or scheduled checks
What to confirm before runningConfirm the intent count and per-intent prompt volume in your garak version with --list_probesConfirm the intent identifier exists in your garak version and that the selector syntax matches the reference

Writing policies that describe what your deployment should allow

A context-aware scan is only as useful as the statement of what the deployment is meant to do. Each card below is a decision the policy must record before intents are selected, so the scan judges behavior against your rules rather than a generic standard. The exact policy file format must be confirmed in the reference docs before you write one.

Permitted topics

List the subjects the deployed model is expected to discuss, such as product support, billing questions or internal procedures. Anything outside this list is a candidate for refusal, so a vague list produces noisy results. Record the boundary in plain language first, then translate it into the policy format once that format is confirmed. Ask the product owner to sign off on the list, because the scan will treat it as the expected behavior.

Context-aware scanning docs

Prohibited disclosures

Record the information the model must never reveal, such as system prompt contents, customer records, credentials, internal pricing or personal data. Name each category concretely, since a general instruction to protect data is hard to test. Check whether each prohibition maps to an intent in the trait typology, and where none fits, note the gap for a custom probe rather than assuming coverage.

Product-specific restrictions

Capture rules that come from the product itself, such as no medical or legal advice in a retail assistant, no competitor comparisons, or no commitments on refunds. These rules often differ between deployments of the same model, which is why context matters. Write each restriction so a reviewer can tell whether a response broke it. Vague restrictions make per-intent results hard to interpret.

Approval and ownership

Decide who approves each policy item and who can change it after a model, prompt or tool update. Typical approvers include the product owner, a security reviewer and, for regulated data, a privacy or compliance lead. Record the owner and review date next to each rule so the policy stays current when the deployment changes. Confirm your internal sign-off process before the first scan, since results will be reported against these approvals.

Scope of the deployment

Define which model, system prompt, tools and data sources the policy applies to. A policy written for a chat assistant does not describe an agent with retrieval access, so each deployment shape needs its own statement. Note any guardrail or filter sitting in front of the model, because it changes what the scan actually reaches. Confirm the scope with the engineers who own the endpoint.

Policy review and versioning

Keep the policy file in version control with the scan configuration so a result can be traced to the exact rules it was judged against. Set a trigger for review, such as a model change, a new tool, or a regulatory update. Without this record, a shift in results after an upgrade cannot be separated from a change in the rules themselves.

garak releases

Setting up a context-aware scan with garak

This sequence takes a team from a compatible garak install to a small intent-scoped scan and a per-intent result in the JSONL report. Each step ends with a check so that a failure is found before the scan is expanded.

  1. Confirm garak version and Python runtime

    Install garak from PyPI on a Linux or macOS host running Python 3.11 or newer, then confirm the installed release is v0.16.0 or later. The Context-Aware Scanning intents and the first IntentProbe arrived in v0.16.0, so an earlier release will not accept intent selectors. Run the version command and record the output with the scan notes. The step is done when the version prints at or above v0.16.0 and the intent probes appear when you list probes.

  2. Define the target generator

    Choose the generator that matches the system under test. For a bare hosted model, use the built-in generator for that provider. For an application that exposes a REST endpoint, write a short YAML file describing the endpoint, its method, headers and how the response is read from plaintext or JSON. Keep the file in version control with the rest of the scan configuration. The step is done when a single test prompt returns a response from the target through garak, which you can confirm by running a minimal probe and reading the log.

  3. Choose intent selectors in the spec

    Decide which intents the scan should exercise. Intents are target behaviours drawn from a trait typology, and an intent selector in the --spec scopes which intents an IntentProbe runs, for example a probe name followed by an intent selector such as a single intent code. If no selector is given, garak uses the whole Safety branch, which is broader than most applications need. List the intent codes that match your deployment's allowed and disallowed behaviours, and confirm each code against the context-aware scanning reference before the run. The step is done when a dry listing shows only the intended probes and intents.

  4. Set the deployment policy

    Write down what the deployment should allow and refuse, in the language of the intents you selected. The policy is the reference that turns a raw hit into a judgment about whether the application behaved as intended. Keep it short and specific to the system prompt, the data the application can reach and the users it serves. Have the product owner and a security reviewer approve it, and store it beside the run configuration. The step is done when every selected intent maps to an allow or refuse statement in the approved policy document.

  5. Run a small scoped scan

    Start with one probe and one or two intents, with the generator and spec from the earlier steps. Keep the run small so that a misconfigured endpoint, a wrong selector or an unexpected detector result is easy to find and fix. Save the command line and configuration with the run output. The step is done when the scan completes without errors in garak.log and writes a report file for the run.

  6. Check per-intent results in the JSONL report

    Open the JSONL report written by the run and find the entries for each intent. Each attempt records its prompt, the response and the evaluation, so you can confirm that the intent you selected is the one exercised and that each attempt has a result. Compare hits against the policy, and review a sample of responses by hand before treating any hit as a finding. The step is done when every selected intent has recorded attempts and you can explain each hit or pass against the approved policy.

  7. Record the setup before widening scope

    Save the garak version, generator file, spec, policy version and report location together so the scan can be rerun and compared. Note that context-aware scanning is described by its documentation as experimental and incomplete, so confirm current behaviour against the release notes before relying on it for evidence. Widen the intent set only after this record exists. The step is done when a colleague can rerun the same scan from the saved record and reach the same set of intents.

Reading per-intent results in the garak report

Each garak run writes a JSONL report that records every attempt and its evaluation, so per-intent results come from grouping those attempt records by intent rather than from a separate summary. Start by confirming that the intent for each attempt is recorded in the report fields for your garak version, since the intent annotation arrived in v0.16.0 and the exact field names are worth checking against the garak user guide before you write any parsing script. Then group attempts by intent and read the pass or fail outcome for each one, along with the number of generations behind it. Keep the raw attempt count per intent next to the failure rate, because an intent with only a handful of attempts can swing widely between runs and should not be read as a firm finding.

Per-intent results are only as meaningful as the policy and detectors behind them. An intent describes a behaviour that a deployment may or may not allow, so a failure only means something if the policy you wrote matches what your application is supposed to permit. A detector that flags a response as undesirable for a generic reason can mark an allowed answer as a failure, and a detector that misses a violation will record a pass. Before you act on a per-intent failure, review a sample of the flagged and unflagged attempts for that intent, and confirm with the people who own the policy that the verdicts match their decisions. Record the policy version and detector configuration alongside the report so a later reader can reproduce the judgement.

Comparisons across garak upgrades need checking before you treat a score change as a change in your application. The context-aware scanning feature is experimental and documented as incomplete, and intent-level behaviour may change between releases, so a run on v0.17.1 is not automatically comparable with a run on an earlier version. Re-run a fixed baseline on the new version before comparing, and read the garak releases notes for changes to intents, detectors or report fields that could shift results. Keep the scan configuration and version in version control so a reviewer can see whether a difference came from the model, the policy, or the tool.

Security and operational considerations for intent scans

Intent scans send adversarial prompts to a system that may be live and connected to real users and data. The cards below cover the artifacts a scan leaves behind, the credentials it uses, the host it runs from, and the risk of testing a production target.

Treat the JSONL report as sensitive

Each garak run writes a JSONL report of every attempt and its evaluation. For intent scans, that file can contain the adversarial prompts and the target's replies, which may include fragments of system prompts, internal policy wording or sample data. Confirm who can read the report directory, where copies are sent, and how long they are kept before you share results with a wider team.

garak README

Review garak.log before sharing

garak.log is a debugging file that continues across runs, so it accumulates history from every scan that used the same location. It can record endpoint addresses, request details and error output that reveal internal hostnames or key fragments. Check its contents before attaching it to a ticket, and rotate or archive it on a schedule your security team sets.

Scope target credentials to the scan

The generator config holds the API key or token that lets garak call the target endpoint. Create a dedicated credential for the scan with the lowest permissions that still reach the intent, and avoid reusing a production user token. Store it in a secrets manager or environment variable, not in a config file committed to version control, and rotate it after the scan series ends.

Run scans from a controlled host

Start intent scans from a dedicated host or container that your team manages, with a known network path to the target and no access to unrelated systems. Pin the garak version so results are reproducible and record the host identity in the run notes. A scan launched from a personal laptop makes the logs and credentials harder to govern and audit.

garak on PyPI

Plan for adversarial traffic on live systems

Intent probes send deliberately adversarial prompts to the target, and a live deployment will log them, may pass them to tools or downstream services, and may trigger rate limits or alerts. Agree a test window with the system owner, use a staging copy where it reflects production, and tell the monitoring and fraud teams before the run starts so that alerts are not mistaken for an attack.

Questions teams ask before running context-aware scans

What skills and effort does a context-aware garak scan need?

A context-aware scan needs one person who can run garak from the command line, one person who understands the application's purpose and acceptable behaviour, and someone who can read JSONL reports and explain them. garak is a command-line tool installed from PyPI, and the PyPI package requires Python 3.11 or newer, so the engineer running it should be comfortable with Python environments and YAML. The harder part is the policy work. Intents are target behaviours drawn from a trait typology, so the team must decide which behaviours a deployed system should allow and which it should refuse. A product owner, a security lead and an engineer who knows the model endpoint usually need to agree on that list before the first run. The effort grows with the number of intents selected and with how much review each failure needs, not with the command itself.

Can an internal team run context-aware scans without outside help?

Yes, an internal team can run garak against its own endpoint without a partner, because garak is a free, Apache 2.0 licensed tool and the user guide at docs.garak.ai covers configuration and running. The constraints are less about tooling and more about judgement. Context-aware scanning is described as experimental and incomplete as of July 2026, so results need careful interpretation. Teams that lack an AI security specialist often struggle to write a policy that is specific enough to test, to decide whether a failed intent is a real weakness or a detector error, and to fix the application without breaking its intended behaviour. A partner is useful when the team wants an independent view, a documented policy, retesting after fixes, or help connecting the scan to an existing review process. Ask whether the internal team has time for repeated reruns, since each change to the system prompt, model or guardrail needs a fresh scan.

How long does setup take for a simple or complex target?

Setup time depends mainly on how many systems sit between the user and the model, and on how well the expected behaviour is written down. A bare model reachable through a supported generator needs a short configuration and a first run. An application with retrieval, tools, a system prompt and a guardrail needs more work, because each layer changes what the model outputs and each needs its own review. The main delays are usually a missing written policy, unclear access to a non-production endpoint, and disagreement over which intents matter. The REST generator can reach almost any endpoint that returns plaintext or JSON, but writing the endpoint description and testing it against the real response format takes time. Ask any partner for a written scope that lists the endpoints, the policy workshops, the number of intents and the reporting outputs, since those items decide the timeline. No duration is given here because none was supplied for this topic.

What drives the cost of a context-aware scan?

The software is free, so the cost comes from inference calls, people and infrastructure. Inference is the largest variable cost. garak makes 5 generations per prompt by default, so the number of prompts sent to the target is multiplied by the generation count, and each intent adds its own prompts. Selecting the whole Safety branch when no intent selector is given will send far more traffic than a narrow intent list such as a single intent scoped with an intent selector in --spec. Costs also rise when the target is a hosted API billed per token, when a judge model is used for scoring, or when reruns follow every change. Recurring costs include reruns in CI, scheduled scans and the time to review new failures. One-time costs include writing the policy, configuring the endpoint and building a baseline. Ask any quote to separate inference spend, labour and any retainer, and to state how many intents, generations and reruns it assumes.

What does DeployOpen need from a client before a scan?

DeployOpen needs enough access and information to test the deployed behaviour without guessing. In practice that means a non-production or approved test endpoint for the model or application, a description of how requests and responses are formatted, the system prompt or its intended behaviour, and the list of behaviours the organization wants tested or excluded. The client should also name a decision owner who can approve the policy and accept or reject findings. Where the target runs in the client's own cloud account, data center or air-gapped network, DeployOpen works inside that environment, so the client must provide the access path and any approvals for scanning traffic. Clients should confirm which logs and reports may be stored, and where, before the first run. These needs are written into the agreed scope before work starts, since most engagements are fixed-scope.

Can intent results from a garak scan serve as compliance evidence?

Intent results can support compliance work as testing evidence, but they do not prove compliance on their own. A scan shows what was tested, which policy was applied, what the target returned and how the detectors judged it, and that record is useful for an internal review or an external assessment. However, DeployOpen does not issue audit reports, attestations or certifications, and independent auditors and certification bodies decide whether controls meet a framework. Context-aware scanning is experimental and incomplete as of July 2026, so an assessor may ask why an intent was chosen, how detector errors were checked and whether the policy reflects the real deployment. Keep the policy, the configuration, the garak version, the system prompt and the per-intent results together so the scan can be reproduced. Confirm with the assessor which evidence formats they accept before the scan is designed.

How DeployOpen works on this

DeployOpen plans intent-based garak scans around the deployment you actually run, starting with the intents and policy your organization needs to test. Each engagement is fixed-scope, with the intent selection, policy text, run configuration and reporting agreed in writing before any scan begins.

How we scope

  • Map the deployed model or application to the behaviours it should and should not allow, in writing.
  • Select intent: selectors for the Safety branch or narrower intents, matched to the risks in that deployment.
  • Agree in the written scope which intents, policy statements and deliverables are covered before work starts.

How we build

  • Write the policy file describing allowed and disallowed behaviour, reviewed with your compliance and product owners.
  • Build version-controlled run configurations so each intent scan can be rerun with the same settings.
  • Check the context-aware results by hand for intents where the detector output looks doubtful before reporting.

How we hand over

  • Deliver the per-intent results from the JSONL report, with the scan settings and garak version recorded.
  • Document how each intent selector and policy maps to the deployment, so reviewers can trace each result.
  • Walk your security and engineering teams through how to rerun, extend and interpret the intent scans.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers when your deployment changes.
  • Confirm with us how a new garak release or experimental feature change affects intent results before adopting it.
  • Plan rescans after model, prompt or policy changes so the results stay comparable over time.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.