Record a quality payload on an agent instance
const url = 'https://app.prefactorai.com/api/v1/agent_instance/013xrzp12g3nqk8ns6jadrqmpgrjkeny/record_quality';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '"summary_quality"'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.prefactorai.com/api/v1/agent_instance/013xrzp12g3nqk8ns6jadrqmpgrjkeny/record_quality \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '"summary_quality"'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”A valid agent instance ID
Example
013xrzp12g3nqk8ns6jadrqmpgrjkenyRequest Body
Section titled “Request Body”Quality schema name (key in the agent schema version quality_schemas)
Example
summary_qualityResponses
Section titled “Responses”Success
object
object
A valid account ID
A valid agent deployment ID
A valid agent ID
A valid agent version ID
object
Total cache-read tokens across all models
Per-model breakdown
object
Total cache-read tokens for this model
Total input tokens for this model
Model identifier from span payloads
Total output tokens for this model
Total input tokens across all models
Total output tokens across all models
Null
A valid environment ID
A valid agent instance ID
When the agent instance was created
Why this instance ran: ‘live’ for an actual agent run, ‘smoke_test’ for a pipeline check, or ‘eval’ for an evaluation run
Map of quality schema name to evaluation payload for this instance
object
object
Map of quality schema name to rendered summary (only names whose template renders)
object
Human-readable quality summary rendered from the quality schema template using the matching quality payload
object
Unique included data categories across params and results of span types that ran, in canonical order
Actions allowed by at least one span type that ran in this instance, in canonical order
Whether the instance has at least one span type with scoreable data_risk
Critical threshold from the agent’s risk profile ruleset
Per-schema-type score breakdown
object
Number of span invocations for this schema type
Risk level bucket for this schema type’s per-invocation score
Span type schema name
Type_score multiplied by count
Risk score for a single invocation of this schema type
Total risk score across all span types for this instance
Null
object
Number of spans with status active (running)
Number of spans with status cancelled
Number of spans with status complete
Number of spans with status failed
Number of spans in a finished state (complete + failed + cancelled)
Number of spans with status pending
Total number of agent spans
object
Invocation count keyed by span schema name
object
Null
Status of the agent instance: ‘pending’ (not started yet), ‘active’ (started but not finished), ‘complete’ (finished successfully), ‘failed’ (ended with failure), ‘cancelled’ (never started, cancelled), or ‘terminated’ (externally terminated)
Type of resource (always ‘agent_instance’)
When the agent instance was last updated
Example
{ "details": { "account_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "agent_deployment_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "agent_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "agent_version_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "cost_breakdown": null, "environment_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "finished_at": "2024-01-01T00:00:00Z", "id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "inserted_at": "2024-01-01T00:00:00Z", "last_activity_span_at": "2024-01-01T00:00:00Z", "purpose": "live", "raised_alert_count": null, "risk_score": null, "span_counts": { "active": 2, "cancelled": 0, "complete": 5, "failed": 0, "finished": 5, "pending": 0, "total": 10 }, "span_schema_counts": null, "started_at": "2024-01-01T00:00:00Z", "status": "pending", "termination_reason": "User requested termination", "type": "agent_instance", "updated_at": "2024-01-01T00:00:00Z" }, "status": "success"}default
Section titled “default”Error