Veryfront runs are durable executions of agents, tasks, and workflows. An eval runs through the built-in eval task.
- An agent run executes an
agent:<agent-id>target. - A task run executes a
task:<task-id>target. - A workflow run executes a
workflow:<workflow-id>target. - An eval run executes the built-in
task:evaltarget with itseval:<eval-id>definition ID inconfig.eval_id. - A target names the capability being executed, for example
task:knowledge-ingest,workflow:content-pipeline, ortask:eval. - events are the canonical user-visible output stream.
- The run that
runs.getRun()returns groups its execution details:targetis{ type, id },input,config,output,errorandartifactssit at the top level, andexecutionholdslogs,duration_ms,exit_codeandtimeout_seconds. The deprecatedget()returns the older flat shape, with those fields at the top level. - Runtime adapters such as process execution are implementation details.
Prerequisites
- A Veryfront Cloud project and a
VERYFRONT_API_TOKEN. SetVERYFRONT_PROJECT_IDorVERYFRONT_PROJECT_SLUGto identify the project (see Configuration). - A task, workflow, or eval definition the run should execute.
Setup
Use the runs SDK for one-off task, workflow, and eval execution:
import { createRunsClient } from "veryfront/runs"; const runs = createRunsClient({ authToken: process.env.VERYFRONT_API_TOKEN, projectReference: "dreamy-haven",});If you are already running inside a Veryfront request context, the client can also pick up request-scoped auth and project context automatically.
Create a task run
const accepted = await runs.createTaskRun({ projectId: "22222222-2222-4222-8222-222222222222", name: "Sync data", target: "task:sync-data", config: { batchSize: 100 },}); console.log(accepted.run.run_id);console.log(accepted.run.status);Run input and output
input on task, workflow and eval runs is any JSON value: an object, an
array, a string, a number, a boolean or null. A task reads it as
ctx.input and its execution settings as ctx.config.
A task run created
without input, or with input: null, gives the task ctx.input equal to
ctx.config, so tasks that read business data from config keep working. A
task that needs a nullable input should wrap it, for example
{ "value": null }.
import { createRunsClient } from "veryfront/runs"; const runs = createRunsClient({ authToken: process.env.VERYFRONT_API_TOKEN, projectReference: "dreamy-haven",}); await runs.createTaskRun({ projectId: "22222222-2222-4222-8222-222222222222", target: "task:classify-ticket", input: ["INV-7731", "Harbor Office"], config: { urgent: true },});A run's input and output read back as the same JSON values. When the
target declares an input or output schema, the run from runs.getRun() also
carries schemas.input and schemas.output, each with the canonical JSON
Schema the run was admitted against and its sha256. Each is null when the
target declares no schema, and schemas is absent on API versions that
predate it. The deprecated get() exposes the digests as
input_schema_sha256 and output_schema_sha256.
See Run input and output for what each run kind
stores, declared schemas, rejected input, null output, and JSON
serialization.
Create a workflow run
await runs.createWorkflowRun({ projectId: "22222222-2222-4222-8222-222222222222", workflowId: "content-pipeline", target: "workflow:content-pipeline", input: { topic: "AI agents" },});Create an eval run
await runs.createEvalRun({ projectId: "22222222-2222-4222-8222-222222222222", target: "eval:deep-research", input: { dataset: "smoke" }, config: { repetitions: 2 },});The deprecated startMode option remains accepted for source compatibility,
but task-based eval runs ignore it.
createEvalRun() sends target: { type: "task", id: "eval" } and places the
provided eval target in config.eval_id. Historical eval executions read back
as task resources through the canonical API.
Observe a run
Prefer events() for progress and user-visible activity:
const events = await runs.events(accepted.run.run_id); for (const entry of events.data) { console.log(entry.event_id, entry.event_type, entry.payload);}Read the current run:
const run = await runs.getRun(accepted.run.run_id);console.log(run.status);console.log(run.output);getRun() requires the canonical run UUID and returns the grouped run
resource: its id is the UUID, target is an object, labels stay available,
and execution diagnostics live in execution. The older get() is deprecated:
it reads the same resource and adapts it to the flat shape existing framework
callers use. Retain the ETag when preparing a metadata update:
let etag: string | null = null;const resource = await runs.getRun("11111111-1111-4111-8111-111111111111", { onHeaders: (headers) => { etag = headers.get("etag"); },});console.log(resource.id, resource.labels, etag);This method requires an API version serving the canonical UUID resource. Use
the full veryfront/runs/target SDK below for other canonical operations.
Cancel a non-terminal run:
await runs.cancel(accepted.run.run_id);Output size limit
A run's final output is capped at 1,048,576 bytes (1 MiB), measured as the
UTF-8 byte length of its JSON serialization. Exactly 1 MiB is stored unchanged.
A successful task, workflow, or agent result over the limit is never truncated.
The run ends failed with output: null and this error:
{ "code": "OUTPUT_TOO_LARGE", "message": "Run output is 1048577 bytes, over the limit of 1048576 bytes", "detail": { "size_bytes": 1048577, "limit_bytes": 1048576 }}If execution has already failed, its original error is preserved and any oversized result attached to that failure is discarded.
The runtime checks task and workflow results before it sends them, so an oversized result never leaves the runtime. The Veryfront API applies the same limit when it stores any run's final output, including agent runs.
A delegating agent still receives a compact summary of a child run's result,
not the child's full output. The summary and structured modes limit returned
text to 64,000 characters, including the truncation marker. To return more data, write it somewhere durable
and return a reference to it.
List project runs
const page = await runs.list({ limit: 50 });console.log(page.data.map((run) => run.run_id));Hosted context compaction
Hosted agents can compact a long active turn by retaining its exact latest user request and a recent tail of messages. Retained tool calls and results stay together. Compaction changes the model context without deleting the durable conversation history.
Hosted services protect two recent turns by default. With only one user turn,
compaction can shorten its tool loop while preserving the exact request. With
two turns, their protected suffix stays complete. If that suffix cannot fit,
compaction raises ContextCompactionError before generating a summary.
Trusted replay preserves completed tool-call occurrences across messages when their source identities distinguish them. Pending duplicates and reuse within one message are rejected. Older or untrusted replay retains its existing snapshot behavior.
Deploy compatible API and runtime versions before enabling this compaction path. Replay fails when the stored evidence cannot verify the retained request or edited messages. Bounded replay may omit older turns; this path does not guarantee complete two-turn replay from the full durable history.
Typed Runs contract SDK
veryfront/runs/target publishes the typed SDK for the Runs target contract that
the npm package pins. It has one method per contract operation, and its request
and response types come from that pinned contract. The SDK sends every request
through the canonical Veryfront API transport from createRunsApiTransport,
which owns the origin, credentials, retries, body limits and telemetry. Set
authMode: "api-key" to send a project API key as X-API-Key. Until the
hosted API switches to the target contract, set baseUrl to an origin that
serves it. The legacy client at
veryfront/runs uses the canonical wire contract and adapts the grouped Run
resource for existing framework callers. Creation returns either this full
resource or a compact receipt with only run_id and status. Both variants
use run_id as the canonical UUID. Narrow with "output" in accepted.run
before reading full-resource fields, or call runs.getRun(accepted.run.run_id)
to read the current run.
Caller-selected aliases and workflow startMode are rejected; retries use
Idempotency-Key. Use the target SDK for the complete grouped resource.
import { createRunsApiTransport, createRunsSdk, type RunsContractComponents, type RunsOutput,} from "veryfront/runs/target"; const sdk = createRunsSdk({ transport: createRunsApiTransport({ baseUrl: "<RUNS_API_ORIGIN>", getToken: () => process.env.VERYFRONT_API_TOKEN!, }),}); const run: RunsOutput<"getRun"> = await sdk.getRun({ path: { run_id: "11111111-1111-4111-8111-111111111111" },});const children = await sdk.listRunChildRuns({ path: { run_id: run.id } });for await (const frame of sdk.streamRunEvents({ path: { run_id: run.id } })) { console.log(frame.id, frame.event);} type Run = RunsContractComponents["schemas"]["Run"];Executors accept a detached dispatch once through the HTTP heartbeat endpoint. Configure the SDK transport to use the issued execution renewal credential, and disable retries for this one-shot request:
const executionRenewalToken = process.env.EXECUTION_RENEWAL_TOKEN!;const executorSdk = createRunsSdk({ transport: createRunsApiTransport({ baseUrl: "<RUNS_API_ORIGIN>", getToken: () => executionRenewalToken, retry: { maxRetries: 0, initialDelay: 0, maxDelay: 0 }, }),}); await executorSdk.createRunHeartbeat({ path: { run_id: "11111111-1111-4111-8111-111111111111" }, headers: { "x-veryfront-run-dispatch-acceptance": "true" }, body: { lease_duration_seconds: 60 },});A lost response leaves acceptance uncertain. Do not retry the acceptance request. A duplicate acceptance returns 409. Ordinary heartbeats omit this header. User tokens and project API keys do not grant heartbeat execution authority. Dispatch acceptance is HTTP bootstrap metadata; GraphQL and MCP retain ordinary heartbeat behavior.
The package ships the pinned contract as TypeScript types, not runtime
validators. An app that consumes the SDK at its own boundary uses these types
instead of copying the contract, for example RunsOutput<"getRun"> or
RunsContractComponents["schemas"]["Run"]. If it also validates responses at
runtime, it types each validator against them. Then a contract change that
removes or retypes a field fails to compile. A new optional field still
compiles, so update the validator when the pinned contract changes. Error
responses reject with a VeryfrontError, and runsProblemOf(error) returns the
RFC 9457 problem body.
Error codes
The Runs service normalizes its failures to uppercase RUN_* codes. Each maps
to one shared error kind, and REST, GraphQL and MCP report the same code for the same failure:
HTTP 413 and 429 responses map to limit_exceeded as well.
Read the code from runsProblemOf(error)?.code. The table lists the
normalized RUN_* codes. A valid Problem may also carry another server code,
such as IDEMPOTENCY_KEY_REUSED or FORBIDDEN, which the SDK passes through
unchanged. Match the codes you handle and fall back to the Problem status for
any other code. When an error response has no Problem body (empty, HTML,
truncated or malformed JSON), the target SDK builds one from the HTTP status
with the code UNEXPECTED_RESPONSE. Treat it by its status, not as a Runs
Problem.
A RUN_CONFLICT may include an optional cause:
schedule_concurrency_forbidden means the schedule forbids a new run while an
earlier fire is active; schedule_fire_in_progress means the same fire is
already being processed. Other conflicts may omit cause.
Scheduling
Schedules are definitions that create runs later. One-time and cron-style schedules belong to the platform scheduling API, not to task or workflow definitions. Scheduler and runtime-adapter details stay behind the platform API.
Verify it worked
After creating a run, watch its status and event stream:
const accepted = await runs.createTaskRun({ projectId: "22222222-2222-4222-8222-222222222222", name: "Test run", target: "task:sync-data",});console.log("created", accepted.run.run_id); // Poll status until terminalwhile (true) { const { status } = await runs.getRun(accepted.run.run_id); if (status === "completed" || status === "failed" || status === "cancelled") { break; } await new Promise((r) => setTimeout(r, 2000));} // Read the canonical event streamconst events = await runs.events(accepted.run.run_id);for (const entry of events.data) { console.log(entry);}A working setup ends with status: "completed" and an event log whose entries
describe the run.
When a Task or Workflow consumes a nested agent stream that fails, the owned
run keeps the failure as a RUNTIME_EVENT_RECORDED event with
runtime: "veryfront" and kind: "agent_error". Its value retains the streamed
error message, code when present, and timing. This observation does not terminate
the parent run: the Task or Workflow can handle the failure and complete with its
own result.
Runs target CLI reference
Use veryfront project runs <command> with an API that serves the Runs 0.8.9
contract. The CLI calls the typed Runs SDK. Target deployment and live parity
are tracked separately from the fixture tests for these commands.
Set VERYFRONT_API_URL to your API origin in your process environment. Use your
normal CLI login, or supply --credential-file <TOKEN_FILE> for an execution
or event-writer token. Add --credential-mode api-key for a project API key.
A repository-supplied API origin cannot receive a credential from that file.
Without --credential-file, the credential mode applies to your configured CLI
credential. Select api-key only when that credential is a project API key.
Supply request bodies with --body '<JSON>'. Supply filters and paging arguments
with --query '<JSON>', preserving the contract's snake_case keys and JSON types.
Use --idempotency-key for idempotent mutations and --if-match for update.
create, resume, update, create-input, respond, finalize, succeed,
fail, and heartbeat require --body. create, cancel, resume,
create-input, respond, cancel-input, pause, finalize, succeed, and
fail require --idempotency-key. update
requires --if-match. The table lists route flags only.
The service validates the shared contract. The CLI adds no lifecycle policy.
For executor bootstrap, accept the dispatch once before starting work:
veryfront project runs heartbeat --run-id <RUN_ID> --accept-dispatch --credential-file <EXECUTION_RENEWAL_TOKEN_FILE> --body '{"lease_duration_seconds":60}' --jsonUse the issued execution renewal credential. A duplicate returns 409; omit
--accept-dispatch for ordinary renewal. Ordinary login and API keys cannot
replace this execution credential.
Use --all on list commands to follow SDK pagination. Use get --follow or
create --follow to stream after the initial response. stream --last-event-id
resumes after a durable event ID. The event-token success response intentionally
returns a scoped credential. Save that result securely; do not include it in logs
or shared evidence. --json returns the normal success or error
envelope; streams emit one envelope per line (NDJSON). Stream output uses stdout
and does not accept --output.
veryfront project runs project-list --project-reference <PROJECT_ID> --json \ --query '{"limit":20,"root_only":true}' --allveryfront project runs get --run-id <RUN_ID> --jsonveryfront project runs create --idempotency-key <REQUEST_KEY> --json \ --body '{"project_id":"<PROJECT_ID>","target":{"type":"task","id":"health-check"}}'veryfront project runs create --idempotency-key <REQUEST_KEY> --json \ --body '{"project_id":"<PROJECT_ID>","source":{"type":"schedule","id":"<SCHEDULE_ID>"}}'veryfront project runs stream --run-id <RUN_ID> --last-event-id <EVENT_ID> --jsonveryfront project runs succeed --run-id <RUN_ID> --idempotency-key <REQUEST_KEY> \ --json --body '{"output":null}'veryfront project runs fail --run-id <RUN_ID> --idempotency-key <REQUEST_KEY> \ --json --body '{"error":{"code":"TASK_FAILED","message":"Task failed"}}'veryfront project runs finalize --run-id <RUN_ID> --idempotency-key <REQUEST_KEY> \ --json --body '{"status":"completed","output":null}'To run a webhook manually, use create with source.type set to webhook.
The body requires project_id, source.id with the webhook ID, and input
with the payload as a JSON value:
veryfront project runs create --idempotency-key <REQUEST_KEY> --json \ --body '{"project_id":"<PROJECT_ID>","source":{"type":"webhook","id":"<WEBHOOK_ID>"},"input":{}}'See Webhooks for webhooks and webhook events.
Use --ndjson on a paginated list command to receive items as they arrive:
veryfront project runs list --query '{"limit":20}' --ndjsonveryfront project runs events --run-id <RUN_ID> --ndjson--ndjson follows the same SDK iterator as --all. Each stdout line is a
success envelope with one item in data, regardless of --json:
{ "success": true, "command": "project runs", "data": { "id": "<RUN_ID>" } }The mode retains one SDK page and one encoded output line, and awaits stdout
writes before consuming another item. Cursor cycle detection uses constant
memory; malformed cursor loops can require additional requests before detection. --output is not supported. An empty collection emits no lines.
Without --ndjson, a list returns its single-page envelope; --all --json
continues to return one envelope with the complete item array.
A request or iterator failure after partial output emits a final error envelope and exits with code 1 (code 2 for validation Problems). Earlier lines remain valid but the collection is incomplete. Output failures terminate consumption; a closed stdout cannot receive a final error envelope. Ctrl+C aborts the active request, closes the iterator, and exits with code 130 without a completion line. An interrupted or failed write can leave an incomplete final line; discard it. There is no completion envelope; consumers must check the exit code.
Validation Problems (HTTP 400 or 422) exit with code 2. Other Problems exit with code 1. JSON errors retain the server's Problem code. Local syntax errors use the CLI's normal usage-error envelope.
The target CLI includes children, individual events, event types, all input
request actions, finalization, heartbeats, and event-writer credentials.
Complete a run with succeed and {"output":<JSON>}, or fail it with fail
and {"error":{"code":"<CODE>","message":"<MESSAGE>"}}. Supply explicit null
when there is no output. finalize remains for compatibility: it selects
completion or failure through its status field.
For these terminal actions, your user token or API key requires project run write
permission and editor access to any bound conversation. Execution credentials
require matching current-run terminal authority; an unrelated or stale execution
credential cannot finalize the run. Supply that authority through
--terminal-token-file <TERMINAL_TOKEN_FILE> when you use an execution credential.
The CLI reads the file without printing its token. A terminal token is not required for ordinary
user or API-key requests. The API enforces the same rules for agent, workflow and
task runs.
Remote direct and saved
schedule creation both use create. Existing local task, workflow, eval,
and schedule execution commands retain their local behavior. The existing
schedule run --remote legacy source-name resolver stays until the coordinated
consumer cutover; use the target create invocation with a saved schedule UUID
for the 0.8.9 contract. These tests do not prove deployed parity.
Process attribution
Hosted task and workflow executions report the same process identity as agent
executions through x-veryfront-runtime-id, x-veryfront-runtime-name and
x-veryfront-runtime-mode. Use these headers to distinguish processes behind a
shared URL. Recording the identity requires compatible API and runtime versions;
older runtimes still execute but omit it.