cortex_run_job
Run evaluation, counterfactual, experiment, and attribution jobs by specifying job kind, target, and criteria; returns a job ID and status for tracking.
Instructions
Enqueue a generic Cortex job (evals, counterfactuals, experiments, attributions). The actor is resolved server-side from the API key (a key bound to an agent_id runs as that agent; otherwise as the api_key actor). The platform ACL-filters input_refs and target access before prompt construction. Returns {job_id, status} plus, when a synchronous MVP runner completes the job inline, the validated result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| options | No | JSON object of execution options. Keys: use_llm (boolean), create_surface_item (boolean), timeout_ms (number), dedupe_key (string). Example: {"use_llm":true,"create_surface_item":false} | |
| criteria | No | JSON object describing what the eval is optimizing for. Free-form per job_kind, but typical keys: optimize_for (string[]), constraints (string[]), pass_threshold (number 0..1). Example: {"optimize_for":["resolution_time"],"constraints":["do_not_expose_private_evidence"]} | |
| job_kind | Yes | What kind of Cortex job to run. workflow_eval = check workflow behavior against criteria. counterfactual_eval = estimate what would have happened under a changed assumption (HYPOTHESIS, not fact). workflow_experiment = compare variants. outcome_attribution = explain why something succeeded/failed. recommendation_impact_eval / prompt_variant_eval / policy_eval = specialized variants. | |
| question | No | Free-form question the job should answer. Required for counterfactual_eval (e.g. "What if Alice had owned this escalation earlier?"). Optional for workflow_eval where criteria suffice. | |
| input_refs | No | JSON object of evidence references the runner may use. Optional keys: run_ids (string[]), case_ids (string[]), node_ids (string[]), chunk_ids (string[]), surface_item_ids (string[]). The platform ACL-filters these before prompt construction; refs the caller cannot access are dropped or the job is denied. Example: {"run_ids":["run_1"],"case_ids":["case_123"]} | |
| project_id | Yes | Project ID. The platform uses this for target access checks and evidence filtering. | |
| target_ref | Yes | Stable reference to the target. For internal target_types this is the platform ID (e.g. "case_123"); for "external" it's the caller's ID for the object described in input_payload. | |
| target_type | Yes | Type of object being evaluated. Use "external" with input_payload when the target lives outside Invariance. | |
| input_payload | No | JSON object for inline target data. Required when target_type="external" (the target isn't a row in our DB). Example: {"workflow_name":"refund approval","steps":[]} |