Writing the purpose and using target discovery in promptfoo

Learn why the purpose field drives attack quality and grading accuracy in promptfoo, what to describe about users, data and tools, and how target discovery profiles your application before generation.

On this page

Writing the purpose in promptfoo red teams: why it decides attack and grading quality

The purpose field tells promptfoo what your LLM application is for, and that context shapes both which attacks get generated and how each result is graded. A security or platform lead scoping a promptfoo red team should treat the purpose as the first control to write, not a comment to fill in later. A vague purpose such as "a customer assistant" produces generic probes and graders that do not know what a correct refusal looks like for your product, so findings can be false alarms or misses. A precise purpose names the job the application performs, who uses it, what data and tools it can reach, and what it must never do.

Target discovery is the step that profiles the application before generation. According to the promptfoo target discovery documentation, the Target Discovery Agent sends probing questions to the target until it has a profile of the target's purpose, limitations, tools and user, and that profile is then used to craft attacks and improve grading. Teams have three practical options. Write the purpose by hand when the application's scope is well documented and stable. Rely on discovery when the application is unfamiliar or the documentation is thin, then review the generated profile. Do both when a written purpose sets the business rules and discovery checks whether the live application behaves as described. Confirm in your own environment which discovery steps run against your target and what they send to it.

Before the first run, check the profile against three questions: does it name the tools the application can call, does it describe the data it may expose, and does it state the limits your policy owners expect. Any gap in those answers is a gap in attack coverage. Keep the written purpose under version control so changes in the application can be traced to changes in the test. Ask the team that owns the application to sign off on the final purpose, because that agreed text becomes the baseline for judging what counts as a finding.

What to describe about users, data and tools in the purpose

The purpose is the brief the grader and attack generator work from, so each component below narrows what counts as a legitimate request and what counts as a failure. Describe them in plain sentences a reviewer could check against the running application.

Intended users and permissions

Name who uses the application (anonymous visitors, customers, employees, administrators) and what each role may do. A request that asks for another customer's order is an attack against a customer role but an ordinary request for a support agent. Permissions decide whether a refusal is correct or a leak, so state the role boundaries explicitly and say whether the target authenticates users at all.

Data the application can read or write

List the data stores and records the application can reach, such as order history, account profiles, knowledge base articles or internal tickets, and mark which are read only. Disclosure tests depend on this list: the grader can only call a response a leak if it knows which data is sensitive and which account it belongs to. Check that the list matches what the target can actually retrieve in your environment, not what the design document says.

Tools and actions it can call

Describe each function, API or plugin the model can invoke, including what it changes (refunds, password resets, emails, file writes) and any confirmation step required before it runs. Tool misuse is often the highest-impact finding, and it is invisible to a grader that only reads text. Ask the team to confirm which tools are enabled in the test environment, since a tool missing from the purpose is rarely probed.

Limitations and out-of-scope topics

State what the application should decline or defer, such as medical advice, legal opinions, competitor comparisons or questions about other companies' products. Stated limits give the attack generator topics to press on and let the grader mark an answer as off-scope without a human rewriting the rule. Keep limits to behavior the product owner has agreed to, because a limit that is never written down cannot be tested.

Business rules that define a violation

Write the product, legal and brand rules that make a response a failure, for example a refund outside the return window or a promise of a delivery date. These rules are the core of policy testing and the main source of grading errors when left vague. Each rule should name the condition and the expected behavior, and it should be reviewed by the owner of the policy before the first run, so the team agrees what a finding is.

What to leave out

Omit marketing copy, feature wishlists, internal project names and anything that would make the purpose read like a sales brief. Do not paste secrets, API keys, customer records or credentials into the purpose, since the purpose is sent to generation and grading steps. Keep the text factual and short enough that a reviewer can verify each sentence against the application.

Purpose only, target discovery, or both: which to use when

This table compares three ways to define what a promptfoo red team knows about the target: a hand-written purpose, the target discovery agent, and a hand-written purpose that discovery checks. Read each row against your application's maturity, your documentation and how much live traffic you can afford to send before the scan starts.

ApproachBest whenWhat it requires from the teamMain risk to confirm
Hand-written purpose onlyDocumentation of users, data and tools is current and the team can state limits preciselyA reviewed purpose covering users, data access, tools and out-of-scope behavior, written by someone who knows the applicationGaps the author does not know about will shape attacks and grading without any check
Target discovery agent onlyLittle written documentation exists and the target can be queried by the teamEndpoint access during discovery, a reviewer to read the generated profile, and time to answer follow-up probesDiscovery questions reach the live target, so confirm whether they appear in application logs and count against rate limits
Hand-written purpose, checked by discoveryA purpose exists but may be stale, or the application has several user types and toolsA written purpose to start from, then a comparison of the discovered profile against it, with differences resolved by the ownerTeams may accept the discovered profile without reconciling it, so assign one owner to sign off the final purpose
Target access during profilingDiscovery needs the live target endpoint, which may sit behind authentication or a test tenantConfirm a test environment or a non-production tenant that matches production behavior closelyProduction data, customer records or real tool actions may be triggered by probing questions
Logging and audit trailThe security team needs to know which traffic came from the scanAgreement on how discovery and attack traffic are tagged, and retention rules for those logsUnlabeled probing traffic may be mistaken for an incident or mixed into production analytics
Rate limits and cost on the targetThe target has provider or gateway quotas that discovery and attacks shareLimits for the target, the number of profiling turns allowed and a schedule that avoids peak useProfiling can exhaust a quota before the attack scan starts, so confirm limits with the target owner first
Reviewing the final purposeAny approach is used, since the purpose sets attack quality and grading accuracyA named reviewer who checks users, data, tools and limits against the application's actual behaviorAn inaccurate purpose produces weak attacks and false positives or negatives in grading

How to run target discovery and review its profile

This sequence turns a draft purpose into a confirmed target profile that the red team uses to craft attacks and grade results. Each step leaves a checked artifact so generation starts from an accurate picture of the application.

  1. Confirm the target endpoint and test account

    The platform owner or the engineer who runs the application identifies the endpoint promptfoo will call and a dedicated test account with the same permissions a real user would have. Send a few harmless messages from the test account and confirm the target returns responses in the expected format and accepts automated traffic at the volume you plan to use. Record the endpoint, the account owner and any rate limits. The step is done when a manual test request succeeds and the owner has approved test traffic in writing.

  2. Draft the purpose from owner documents

    Gather the product specification, user guides, system prompt summary, data access rules and tool lists from the application owner, then write a first purpose statement. Cover who the users are, what the application is for, what it must refuse, which data sources and tools it can reach, and which actions need human approval. Mark any statement the owner cannot confirm. The draft is complete when the owner has reviewed it and every tool and data source named in the purpose appears in the design documents.

  3. Check the questions for real customer data

    Before running discovery, review the probing questions the agent will send and the messages it may generate from the draft. Confirm that the test account holds only synthetic or internal records and that no real customer names, account numbers or personal details appear in any prompt you supply. Ask the owner to confirm which data the test account can reach. The check passes when the owner signs off that the test environment contains no production customer data.

  4. Run target discovery against the endpoint

    Run the discovery step against the configured target so the Target Discovery Agent can send probing questions until it has a profile of the application's purpose, limitations, tools and user. Watch the first exchanges to confirm the target answers in a consistent way and that the agent is not repeating the same question. Save the resulting profile output alongside the run settings. The step is complete when the agent finishes and produces a profile covering all four areas.

  5. Compare the profile against the draft

    Place the discovered profile beside the draft purpose and mark each difference. Look for tools the profile lists that the draft omits, limitations the target admits that the draft does not mention, and users the profile describes differently from the owner. Treat a mismatch as a finding to resolve, since the grader uses the profile to judge what a safe answer looks like. The comparison is complete when every difference has a recorded explanation or a correction.

  6. Correct gaps in the purpose

    Update the purpose with the missing tools, data boundaries, refusal rules and user descriptions, using wording the owner has approved. Where the target behaves differently from the documentation, confirm with the owner which behavior is intended before you change the purpose to match it. Keep a dated copy of each revision. The step is done when the revised purpose has an owner approval and each correction traces to a source document or an owner decision.

  7. Confirm the profile before generation

    Rerun discovery if the purpose changed substantially, then have the application owner and the security reviewer approve the final profile in writing. Store the approved profile and purpose with the scan configuration so reviewers can see what the attacks were built from. Confirm the target is still reachable with the test account. The step is complete when both approvals are recorded and the team can state which profile version generation will use.

How the discovery profile feeds generation and grading

The team starts with its purpose draft and the target endpoint, and the target discovery agent sends probing questions across the trust boundary to the application. The agent returns a profile of purpose, limitations, tools and user, which feeds attack generation and grading. The team reviews that profile inside its own environment before any scan runs, because a wrong profile produces wrong attacks and wrong verdicts.

Purpose and discovery feed a reviewed profile into generation and grading, with the trust boundary at the target.

Security and privacy considerations when profiling a live application

Does target discovery send questions to my application?

Yes. The Target Discovery Agent sends probing questions to the target until it has a profile of the target's purpose, limitations, tools and users. That means the target receives traffic during profiling, not only during the later attack run. Treat discovery as testing: point it at a test environment or an endpoint your security team has approved in writing, and confirm that the target's logs, rate limits and alerting are ready for the extra requests before you start.

Should the purpose text be handled like system documentation?

Yes. A purpose field often names internal tools, data sources, business rules and customer segments, which is exactly what an attacker would want to learn. Give it the same handling as your system documentation: restrict who can edit it, review it before it is shared outside the testing team, and remove anything that describes production credentials, hostnames or internal network layout. Describe capabilities in functional terms where you can, for example "answers order status questions" rather than naming a backend service.

Where should the generated target profile be kept?

Keep the profile in a controlled repository with the same access rules as your other test configuration, such as version control with restricted branches. The profile can describe what the application can do with customer data, which tools it can call and where its limits are. Do not paste it into shared chat channels, tickets open to the wider company or vendor support requests. Confirm with your own setup where the profile is written and which systems can read it, because that depends on how you run promptfoo.

What access should the test accounts have during profiling?

Use test accounts with least privilege. The discovery questions and later attacks should run as a user who can reach only the functions the test needs, with no access to real customer records, production admin consoles or payment actions. If the application has role tiers, test each tier separately with its own account so the profile reflects what each role can really do. Remove or rotate these accounts when the engagement ends, and record which account was used for each run.

What should I document about the profiling run for sign-off?

Record the target endpoint and environment, the date and time window, the account or accounts used, the promptfoo version, the purpose text version and the generated profile version. Note who approved the run and which data sources and tools the application was allowed to touch during testing. This record lets a reviewer tell which findings came from which configuration and lets you rerun the same profile later. Keep it with your red team evidence rather than in a personal notes file.

Can I confirm where discovery data is stored and who can see it?

Confirm it for your own setup. The documented behavior is that promptfoo runs locally and talks directly to the LLM, so evals run on your machine. Beyond that documented behavior, do not assume where profiling data, generated questions or responses are stored, or whether any part of generation or grading goes to a hosted service. Check the data flow for your configuration, including any hosted generation settings, and get the security team's sign-off before the first run against a live endpoint.

What should I check before profiling a live application?

Check four things in order: that the endpoint is approved for testing, that the purpose text has been reviewed for sensitive detail, that the test accounts are least privilege, and that the run is documented. The promptfoo red teaming documentation sets out the broader testing approach, and the target discovery documentation explains the profiling step itself. Have the owner of the target confirm monitoring is in place and agree a stop condition if the application behaves unexpectedly.

Limits to confirm before relying on target discovery

Target discovery shapes the attacks and the grading, so a profile that is wrong produces a red team that tests the wrong things. The cards below cover the points to verify against current promptfoo documentation and your own tests before you rely on the agent's output.

Rate-limited and stateful endpoints

Discovery sends a series of probing questions to the target, so it adds requests before any attack runs. Confirm how the agent behaves when your endpoint enforces rate limits, returns errors under load, or keeps conversation state through cookies or session IDs. A profile built from a session that was cut off or reset mid-conversation may describe the wrong application. Run discovery against a staging endpoint first and read the transcript before the profile is used.

Target discovery docs

Tools that perform actions

Discovery learns which tools the application uses, but it does not establish what those tools can do to real systems. Confirm whether the agent can reach tools that write data, send messages, move money or change accounts, and whether it would trigger those actions while probing. Use a sandboxed build with stubbed tools for discovery where the application can take actions. Record exactly which tools the profile lists, because missing tools mean missing attacks.

Applications with many personas

An application that serves customers, agents, administrators and partners may need a different profile for each role. Confirm how the agent handles several user types, whether the profile merges them, and which role it describes when probes reach different permission levels. A single merged user description can hide authorization gaps, because attacks are then written for an average user rather than for the role that holds more access. Compare the profile against the actual user roles your team documents.

Re-running discovery after changes

A profile describes the application as it was when discovery ran. A prompt edit, a new tool, a changed knowledge base or a swapped model can make the profile stale, and attacks written from it may miss new behavior. Decide who triggers discovery again and when, such as after each release that touches prompts or tool definitions. Keep each profile version next to the red team run it produced so reviewers can see which application state was tested.

Grading model and version

The profile is used to improve grading, so the grader's model and version determine how results are judged. Confirm which model performs discovery, which model grades the outputs, and whether either is hosted or local. Record the exact versions in your run notes, because a grader change can shift results without any change to the application. Test a known safe and a known unsafe response against the configured grader before you accept a report.

Red teaming docs

Profile accuracy against your own tests

The agent's description of purpose, limitations and users is an inference from its questions, not a verified specification. Check each field of the generated profile against your product documentation and the application's actual behavior. Write a small set of questions with known answers, such as an out-of-scope request the application must refuse, and confirm the profile reflects that refusal. Correct the purpose text where the profile is wrong before generation starts.

Questions buyers ask about purpose writing and target discovery

How much effort does writing a promptfoo red team purpose take?

Writing a usable purpose is usually a short working session, but the effort rises with how many user groups, data types and tools the application has. The purpose should describe who uses the application, what it is allowed to do, what data it can see and which tools it can call. Each of those areas needs a source: product documentation, the system prompt, the tool definitions and the access rules. The more of those sources that exist and are current, the less time is spent reconstructing them from memory. Ask your team to list the open questions before the session starts, because unresolved answers about permissions are what stretch the work.

Can our internal team write the purpose without a partner?

Yes, most teams can write the purpose themselves, provided the people who know the product and its data are in the room. The writing itself is not specialized, but the judgment about what the application must never do is. Engineers usually know the tools and endpoints, product owners know the intended users and limits, and security staff know which data and actions carry risk. A partner can help by running the session, challenging vague statements and checking that the purpose matches what the target actually does. Ask whether an outside reviewer will test the purpose against real behavior before the first scan.

How long does target discovery take?

Target discovery takes as long as the target needs to answer its probing questions, so the duration depends on two things: how fast the endpoint responds and how many questions the agent sends before it has a profile. A slow model or a rate-limited gateway stretches the run, and a complex application with many tools may need more questions. Check your endpoint latency and any rate limits before you start, because these set the upper bound on the run. Ask the team running the work to report the number of questions sent and the time per response, so you can plan the next run with real numbers from your own environment.

What does the product owner and security team need to provide?

The product owner needs to supply the intended users, the business purpose, the allowed and prohibited behaviors, and any domain rules that the application must follow. The security team needs to supply the data classes the application can access, the tools and actions it can perform, the authorization model and the risks they want tested first. Both groups should review the resulting profile, since errors in it lead to attacks that miss real weaknesses or grade correct answers as failures. Agree on who signs off the purpose before the scan, and record that approval with the scan configuration.

Does target discovery cost extra on the Community edition?

The promptfoo Community edition is free and includes red teaming with 10k probes per month, so discovery questions are not priced separately in the published Community description. Discovery sends probes to your target, so its activity counts toward your overall usage, and that usage should be checked against the probe limit. Paid tiers are priced on a custom basis, and the Enterprise and On-Premise scope is set in the commercial conversation. Confirm current terms on the promptfoo pricing page before you plan the work, because limits and inclusions can change.

How do I know when a purpose is good enough to start?

A purpose is ready when someone outside the writing group can read it and predict what the application will refuse, what data it may reveal and which tools it may call. It should name the user groups, the data in scope, the tools and the explicit limits, with no vague phrases such as helpful or secure. Compare the written purpose with the discovery profile: if the profile reveals a capability or user group the purpose omits, the purpose is not finished. A good test is to run a small sample first and check whether the findings reflect the rules your team actually cares about.

Why does the purpose affect grading accuracy?

The grader decides whether a response is a failure by comparing it with the purpose, so a vague purpose produces inconsistent verdicts. If the purpose does not say that a refund outside the return window is disallowed, the grader may accept a harmful answer or flag a correct one. Detailed purposes that name permitted behaviors and forbidden disclosures give the grader a reference point. Engineers should check a sample of verdicts after the first run and adjust the purpose where the grader disagrees with the team's own judgment.

What DeployOpen delivers for a purpose and discovery review

DeployOpen runs the purpose and target discovery review as a fixed-scope piece of work, agreed in writing before any testing starts. The review covers drafting the purpose with your product, security and compliance owners, running the target discovery step against the application in an environment you approve, and checking the resulting profile against what your team knows about the application. Pricing follows from that written scope, so the quote reflects the number of target environments, the number of tools and data sources to describe, and how many review rounds your owners need. DeployOpen does not publish a price list.

The work starts with a short working session to collect what the purpose must say: who the users are, which data the application can read or write, which tools and actions it can call, and which behaviors are out of bounds. DeployOpen then drafts the purpose and reviews it with you line by line, flagging vague statements that would weaken attack generation or grading. Discovery runs only against the endpoint and account you name in the scope, from a network location you approve, so probing questions and responses stay inside your environment. You should confirm in advance which test credentials and logging rules apply.

The handover is a written package: the final purpose text, the discovery profile with its limitations, tools and user description, a list of points where the profile disagrees with your records, and the open decisions that the owners must close before a red team run. The package states what was reviewed, by whom, and against which version of the target, so a later scan can be traced back to the profile it used. Ongoing reviews after application changes can be added as a retainer if your team wants the profile kept current.

How DeployOpen scopes, delivers and supports promptfoo red team setup

DeployOpen approaches the purpose field and target discovery as scoping work that comes before any attack is generated. We agree the application boundary, the user profile, the data and tool limits and the grading rules in writing, then set up and document the red team so your security and engineering teams can review it. Each engagement is fixed-scope, with deliverables agreed before work starts.

How we scope

  • We confirm which application, endpoint and user groups the purpose statement covers.
  • We list the data sources, tools and actions the target can reach, so attacks match real permissions.
  • We agree in writing which discovery answers and purpose sections your team must sign off before generation.

How we build

  • We write the purpose field from your product documentation, system prompt and access model, then review it with your owners.
  • We run target discovery against a non-production endpoint and compare the generated profile with what your team expects.
  • We correct profile gaps and record each change so the grading basis stays traceable.

How we hand over

  • You receive the final purpose text, discovery profile and plugin configuration as versioned files in your repository.
  • A written note explains each purpose section, which assumptions came from your team and which need confirmation.
  • We walk your engineers through rerunning discovery after prompt, tool or policy changes.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, scoped separately from the first setup.
  • When the application changes, we review whether the purpose and discovery profile still describe it accurately.
  • We retest after fixes so your team can confirm that the updated purpose produces the intended attacks and grading.

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.