SDK reference · Python SDK
prov.trace.assessments.flush_unassessed
prov.trace.assessments.flush_unassessed in Python SDK. Post every unchecked run as unassessed (idempotent by each record's key); stops at the first that fails.
Signature
prov.trace.assessments.flush_unassessed() -> intParameters
No parameters.
Request fields
Idempotency-Keystringheader- Retry a create safely: the same key + request returns the stored response (24 h, per caller).
stageenumaction: before a tool call. One ofaction.trace_idstring- The trace of the model call that produced the tool call.
agent_idstring- The registered agent.
agent_session_idstring- The agent's session (a rule's lock names it).
run_idstring- The run the action belongs to.
actionobjectRequired- The action the agent is about to take.
Show child attributes
toolstringRequired- The tool's name, such as
payments.send. riskenum- The risk class; read from the tool's name when left out. One of
read,write,send,delete,pay. amountinteger- The amount in minor units.
currencystring- ISO 4217.
payeestring- A payee ID or domain.
descriptionstring- What the action does, in words.
argsany- The tool's arguments: hashed (
args_hash), never kept.
contextobject- What was in the model's context.
Show child attributes
untrusted_sourcesarray of enums- Kinds of untrusted content in the model's context.
findingsarray of objects- What your own guards reported. An unknown category is refused (
finding_category_unknown).Show child attributes
reporterenumRequired- Who reported it. One of
lakera,bedrock_guardrails,prompt_shields,nemo_guardrails,own. categoryenum- The finding's category. One of
prompt_injection,indirect_injection,jailbreak,unsafe_output,pii_leak,malicious_link,credential_exfiltration,off_task. confidencenumber- The reporter's confidence.
unansweredboolean- The guard ran and didn't answer (its
finding.*facts are unavailable).
unassessedboolean- An SDK's record of a tool that ran while Provenance couldn't be reached.
unassessed_attimestamp- When the tool ran.
unassessed_reasonenum- Why it ran unchecked. One of
unreachable,timeout,server_error. droppedinteger- Records the SDK dropped before this one could be posted.
waitobject- Wait for a person to decide a challenge before answering.
Show child attributes
approval_sinteger- Seconds to wait (at most 25); the answer is still
challengeif nobody decided.
Returns
int The assessment.
HTTP operation
POST /v1/trace/assessments: Assess an action
Errors
- authentication_required
- finding_category_unknown
- idempotency_key_reused
- invalid_json
- parameter_invalid
- parameter_missing
- policy_account_required
- rate_limit_exceeded
- resource_missing
- trace_rules_unavailable
- trial_ended
Example
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/trace/policies`, {
method: "PUT",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({
"note": "ask before paying after an injected email; never delete",
"document": {
"rules": [
{
"id": "injected-email-payments",
"label": "Payments after an injected email",
"when": [
{
"fact": "action.risk",
"op": "eq",
"value": "pay"
},
{
"fact": "context.untrusted_sources",
"op": "contains",
"value": "email"
},
{
"fact": "finding.categories",
"op": "contains",
"value": "indirect_injection"
}
],
"require": {
"approval": true
}
},
{
"id": "no-deletes",
"label": "Deletes",
"when": [
{
"fact": "action.risk",
"op": "eq",
"value": "delete"
}
],
"require": {
"deny": true,
"lock": true
}
}
]
}
}),
})).json();
const tracePolicyVersion = step1.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/trace/assessments`, {
method: "POST",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json", "Idempotency-Key": "tsa-reference-1" },
body: JSON.stringify({
"agent_session_id": "ses_reference_trace",
"action": {
"tool": "payments.send",
"amount": 185000,
"currency": "USD",
"payee": "acct_brindlecote_supplies",
"description": "Pay invoice INV-2041"
},
"context": {
"untrusted_sources": [
"email"
]
},
"findings": [
{
"reporter": "own",
"category": "indirect_injection",
"confidence": 0.91
}
]
}),
})).json();import os
import httpx
api = os.environ["PROVENANCE_API"]
step1 = httpx.put(f"{api}/v1/trace/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"note": "ask before paying after an injected email; never delete",
"document": {
"rules": [
{
"id": "injected-email-payments",
"label": "Payments after an injected email",
"when": [
{
"fact": "action.risk",
"op": "eq",
"value": "pay"
},
{
"fact": "context.untrusted_sources",
"op": "contains",
"value": "email"
},
{
"fact": "finding.categories",
"op": "contains",
"value": "indirect_injection"
}
],
"require": {
"approval": True
}
},
{
"id": "no-deletes",
"label": "Deletes",
"when": [
{
"fact": "action.risk",
"op": "eq",
"value": "delete"
}
],
"require": {
"deny": True,
"lock": True
}
}
]
}
}).json()
trace_policy_version = step1["version"]
data = httpx.post(f"{api}/v1/trace/assessments", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Idempotency-Key": "tsa-reference-1"}, json={
"agent_session_id": "ses_reference_trace",
"action": {
"tool": "payments.send",
"amount": 185000,
"currency": "USD",
"payee": "acct_brindlecote_supplies",
"description": "Pay invoice INV-2041"
},
"context": {
"untrusted_sources": [
"email"
]
},
"findings": [
{
"reporter": "own",
"category": "indirect_injection",
"confidence": 0.91
}
]
}).json()