Repository navigation
FEAT: Prompt generation jobs in the backend (-5) #4134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Richard Lundeen (richlundeen)
merged 57 commits into
microsoft:main
from
richlundeen:richlundeen-assert-generation-backend
Nov 19, 2026
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
f1b607d
FEAT: Custom ASSERT judge dimensions, presets, and repeated samples
richlundeen 1b753ee
FIX: Keep non-default ASSERT judge settings in identity; restrict jud…
richlundeen 54b1aba
MAINT: Simplify ASSERT judge dimensions and samples; allow technique …
richlundeen fe1ff0e
FEAT: Run registered attack techniques in foundry.assert_policy
richlundeen fb0caff
FEAT: Support ASSERT not-applicable answers and graded judge dimensions
richlundeen aed1b20
FEAT: assert_package technique with ASSERT's tester prompt
richlundeen a99189d
FIX: address #4132 review feedback
richlundeen a18bc4f
MAINT: typed ASSERT judgment metadata and YAML dimension framing
richlundeen 3c26aec
FEAT: Trace-grounded ASSERT judging with OpenTelemetry execution evid…
richlundeen 053dd5c
FIX: Order ASSERT trace steps deterministically when start times tie
richlundeen 9780189
FIX: Address ASSERT trace evidence review feedback
richlundeen e2c965b
FIX: Version ASSERT trace rendering for cyclic steps
richlundeen 4bb2163
FIX: Render ASSERT dimension trace instructions through the prompt te…
richlundeen a24ce22
FEAT: ASSERT headline metrics for foundry.assert_policy runs
richlundeen 166de36
FIX: Address ASSERT metrics review feedback
richlundeen 265a2e6
DOC: Refresh ASSERT metrics notebook output for assert_package
richlundeen b70cb51
FIX: Read ASSERT judgment metadata through the typed models
richlundeen 20ceb2e
FEAT: Resumable ASSERT generation, generation estimates, and the ASSE…
richlundeen d199cba
FIX: Address ASSERT generation SDK review
richlundeen ba09380
FEAT: Run prompt generators as backend jobs
richlundeen 7875121
FIX: Address prompt generation backend review
richlundeen ee00756
MAINT: merge main 1dc1d5cda into ASSERT judge dimensions (-1)
richlundeen 9e697fd
MAINT: Merge refreshed ASSERT judge dimensions layer (main 1dc1d5cda)…
richlundeen 78f2477
Merge commit '9e697fddfef02c1c17fb1b851cb6285c5bbc704d' into richlund…
richlundeen f31407f
Merge refreshed ASSERT metrics (-3) with main into staged generation …
richlundeen 51f8472
Merge staged generation (-4) with main into generation jobs (-5)
richlundeen 0012d16
MAINT: merge main c3cff1831 into ASSERT judge dimensions (-1)
richlundeen 7bf65f3
MAINT: Merge refreshed ASSERT judge dimensions layer (main c3cff1831)…
richlundeen 4848f91
Merge commit '7bf65f3969fb6cd8b2c14be28456a848baf9c370' into richlund…
richlundeen da0f38c
Merge refreshed ASSERT metrics (-3) with main into staged generation …
richlundeen 0ebcd76
Merge staged generation (-4) with main into generation jobs (-5)
richlundeen 6932faa
FEAT: accept a supplied ASSERT objective scorer and use default scori…
richlundeen 2804b41
DOC: note default ASSERT scoring in the launch form and the supplied …
richlundeen 8859dea
FIX: resolve the ASSERT judge target with scoring_target and report i…
richlundeen f696a86
MAINT: make ASSERT judgment metadata helpers keyword-only
richlundeen 4c8ceda
MAINT: Rebuild ASSERT trace evidence layer on the supplied-scorer layer
richlundeen 06ccdf2
MAINT: Exempt the OpenTelemetry span processor callback from keyword-…
richlundeen b5e5931
Merge published ASSERT metrics layer onto the rebuilt trace evidence …
richlundeen cee992a
FIX: Identify ASSERT runs by registry name and keep supplied scorers …
richlundeen 880a61f
FIX: Use only proven ASSERT provenance for metrics policies and dimen…
richlundeen 145b788
FIX: Require built-in ASSERT judge evidence for metrics policies
richlundeen d0b7c2a
FIX: Stop attributing ASSERT violations to the mutable assigned category
richlundeen 1c0add0
Merge rebuilt ASSERT metrics (-3) into staged generation (-4)
richlundeen 22c7a75
Merge rebuilt staged generation (-4) into generation jobs (-5)
richlundeen 393112b
Merge main into generation jobs (-5)
richlundeen c9bdc44
MAINT: Make prompt generation parameters keyword-only
richlundeen 96cce74
Merge main into generation jobs (-5)
richlundeen 4066654
MAINT: Persist prompt generation jobs through memory
richlundeen 59f121f
FIX: Recover orphaned saving generations and let the database match n…
richlundeen 2b59341
Merge main into generation jobs (-5)
richlundeen 5bb8d6a
Merge main into generation jobs (-5)
richlundeen 7c315f3
Keep generation writes, requests, and batch order correct across back…
richlundeen 883bcc6
Merge main into generation jobs (-5)
richlundeen c5bd484
FIX: List a batch's generations in the order they were requested
richlundeen 20a8f4a
FIX: Say plainly when a generation can't resume under its dataset name
richlundeen 184f9af
Merge main into generation jobs (-5)
richlundeen 1db7362
MAINT: Trim the generation save status, bulk lookups, and duplicate r…
richlundeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| REST envelopes and views for prompt generation: running generator requests as background jobs, | ||
| reviewing intermediate output, and saving the result as a named seed dataset. | ||
|
|
||
| The stored job, its status, and its progress are ``pyrit.models`` types. Each generator defines the | ||
| shape of its ``request``, its review payload, and its result summary; ``GET /prompt-generators`` | ||
| describes the registered generators. | ||
| """ | ||
|
|
||
| from datetime import datetime | ||
| from typing import Annotated, Any | ||
|
|
||
| from pydantic import BaseModel, ConfigDict, Field, JsonValue, StringConstraints | ||
|
|
||
| from pyrit.backend.models.common import IdentifierStr | ||
| from pyrit.models import ( | ||
| PromptGenerationEstimate, | ||
| PromptGenerationProgress, | ||
| PromptGenerationStatus, | ||
| TargetObjectiveGenerationRequest, | ||
| ) | ||
| from pyrit.models.prompt_generation import DatasetNameStr, GeneratorNameStr, TargetRoleStr | ||
|
|
||
|
|
||
| class PromptGeneratorStage(BaseModel): | ||
| """One stage a generator runs, in order.""" | ||
|
|
||
| name: str | ||
| label: str | ||
| reviewable: bool = Field(False, description="Whether generation can pause after this stage for review") | ||
|
|
||
|
|
||
| class PromptGeneratorTargetRole(BaseModel): | ||
| """A target a generator uses, chosen from the target registry.""" | ||
|
|
||
| role: str | ||
| label: str | ||
| description: str | ||
| required: bool | ||
|
|
||
|
|
||
| class PromptGeneratorDescriptor(BaseModel): | ||
| """A registered generator and what it needs.""" | ||
|
|
||
| name: str = Field(..., description="Stable generator key, used as ``generator`` in requests") | ||
| display_name: str | ||
| description: str | ||
| stages: list[PromptGeneratorStage] | ||
| target_roles: list[PromptGeneratorTargetRole] | ||
| follow_up_scenario: str | None = Field( | ||
| None, description="A scenario that runs datasets from this generator, preselected after completion" | ||
| ) | ||
|
|
||
|
|
||
| class PromptGeneratorListResponse(BaseModel): | ||
| """The registered generators.""" | ||
|
|
||
| items: list[PromptGeneratorDescriptor] | ||
|
|
||
|
|
||
| class PromptGenerationSummary(BaseModel): | ||
| """A generation without its request and checkpoint, for listings.""" | ||
|
|
||
| id: str | ||
| generator: str | ||
| dataset_name: str | ||
| status: PromptGenerationStatus | ||
| pause_for_review: bool | ||
| group_id: str | None | ||
| group_label: str | None | ||
| progress: PromptGenerationProgress | ||
| error: str | None | ||
| created_by: str | None | ||
| created_at: datetime | ||
| updated_at: datetime | ||
| completed_at: datetime | None | ||
|
|
||
|
|
||
| class PromptGenerationDetail(PromptGenerationSummary): | ||
| """A generation with its request, targets, and result summary.""" | ||
|
|
||
| request: dict[str, JsonValue] | ||
| targets: dict[str, str] | ||
| review_completed: bool | ||
| summary: dict[str, JsonValue] | None | ||
| started_at: datetime | None | ||
|
|
||
|
|
||
| class PromptGenerationListResponse(BaseModel): | ||
| """Generations, newest first.""" | ||
|
|
||
| items: list[PromptGenerationSummary] | ||
|
|
||
|
|
||
| class PromptGenerationCreateRequest(BaseModel): | ||
| """A generation to queue.""" | ||
|
|
||
| model_config = ConfigDict(extra="forbid") | ||
|
|
||
| generator: GeneratorNameStr | ||
| dataset_name: DatasetNameStr = Field(..., description="Name of the dataset to create; it must not exist yet") | ||
| request: dict[str, Any] | ||
| targets: dict[TargetRoleStr, IdentifierStr] = Field(default_factory=dict) | ||
| pause_for_review: bool = Field(False, description="Pause after a reviewable stage so its output can be edited") | ||
|
|
||
|
|
||
| class TargetObjectiveCreateRequest(TargetObjectiveGenerationRequest): | ||
| """A ``target_objective`` request within the backend's size limits.""" | ||
|
|
||
| count: Annotated[int, Field(strict=True, ge=1, le=1_000)] | ||
| harm_categories: list[Annotated[str, StringConstraints(pattern=r"\S", max_length=100)]] = Field( | ||
| default_factory=list, max_length=50 | ||
| ) | ||
|
|
||
|
|
||
| class PromptGenerationPreflightResponse(BaseModel): | ||
| """Whether a request can start, and an estimate of its work. No target is called.""" | ||
|
|
||
| valid: bool | ||
| errors: list[str] = Field(default_factory=list) | ||
| dataset_name_available: bool | ||
| estimate: PromptGenerationEstimate | None = None | ||
|
|
||
|
|
||
| class PromptGenerationReview(BaseModel): | ||
| """Output awaiting review, in the generator's review shape.""" | ||
|
|
||
| generation_id: str | ||
| stage: str | ||
| payload: dict[str, JsonValue] | ||
|
|
||
|
|
||
| class PromptGenerationReviewUpdate(BaseModel): | ||
| """Edited review output.""" | ||
|
|
||
| model_config = ConfigDict(extra="forbid") | ||
|
|
||
| payload: dict[str, Any] | ||
|
|
||
|
|
||
| class PromptGenerationBatchItem(BaseModel): | ||
| """One generation within a batch.""" | ||
|
|
||
| model_config = ConfigDict(extra="forbid") | ||
|
|
||
| dataset_name: DatasetNameStr | ||
| request: dict[str, Any] | ||
|
|
||
|
|
||
| class PromptGenerationBatchCreateRequest(BaseModel): | ||
| """Several generations that share a generator, targets, and settings, such as an ASSERT suite.""" | ||
|
|
||
| model_config = ConfigDict(extra="forbid") | ||
|
|
||
| generator: GeneratorNameStr | ||
| label: Annotated[str, StringConstraints(min_length=1, max_length=200)] | ||
| items: list[PromptGenerationBatchItem] = Field(..., min_length=1, max_length=100) | ||
| targets: dict[TargetRoleStr, IdentifierStr] = Field(default_factory=dict) | ||
| pause_for_review: bool = False | ||
|
|
||
|
|
||
| class PromptGenerationRequestFromDataset(BaseModel): | ||
| """A generator request reconstructed from a stored dataset, to regenerate it under a new name.""" | ||
|
|
||
| generator: str | ||
| request: dict[str, JsonValue] | ||
| source_dataset_name: str | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.