Skip to Content
SDK referenceWorkflows & Handoffs

Workflows and handoffs

Each govern() call records its own session, with its own decision, review, and sealed evidence. A workflow groups the sessions that belong to one piece of business work, such as the intake, assessment, and payout stages of a claim, or a planner agent handing a refund to a specialist. VeriProof verifies every link before the action runs, and the portal shows the whole workflow on each of its sessions.

A session ID you pass as sessionId must still be new. You link sessions with the options below, never by reusing a session ID.

There are two relations:

RelationUse it whenExample
parentThe new call is nested inside, or delegated from, an earlier sessionA planner hands a refund to a specialist; a framework run checks a tool
workflowThe new call is a later stage of the same transaction, with no parentAssessment and payout after intake

VeriProof accepts a link when:

  • Both sessions belong to the same application. The same credential owns both.
  • The sessions belong to different applications, and the relation is parent. The parent session’s handoff check must name the new session’s application and have let the handoff proceed: allowed, warned, narrowed, or escalated and then approved by a person.

Joining another application’s workflow as a later stage is refused. Stages owned by another application join through a handoff instead.

Nest calls automatically

While a governed action runs, the SDK remembers its session. A govern() call made inside it, through the same client, is linked to it as its parent with no extra code. Framework adapters that check tools inside a governed run get this for free, so each tool’s session shows under its run.

A call through a different application’s client inside the action isn’t linked automatically. Pass parent explicitly when that call is a handoff.

In Java, work handed to an executor doesn’t carry the running action. In Rust, a task started with tokio::spawn doesn’t either. Pass parent or workflow explicitly there. Go carries it in the context.Context your action receives, so pass that context to nested calls.

Open a workflow scope around sequential steps. The first governed call in the scope becomes the workflow’s root, and later calls join it:

await veriproof.withWorkflow(async (scope) => { await veriproof.govern('claims.intake', intake, runIntake, { facts: intakeFacts }); await claims.save(claim.id, { veriproofWorkflow: scope.workflowId }); await veriproof.govern('claims.assess', assessment, runAssessment, { facts: assessmentFacts }); });

When a later stage runs in another process or on another day, store the workflow ID with your business record and join it again:

const { veriproofWorkflow } = await claims.get(claim.id); await veriproof.withWorkflow(veriproofWorkflow, async () => { await veriproof.govern('claims.pay', payout, issuePayment, { facts: payoutFacts }); });

You can also pass workflow (or parent) on a single call. An explicit option always wins over the scope.

Hand work to another agent

Check the handoff itself with a delegation, then pass the handoff’s session to the specialist as its parent:

const handoff = await veriproof.govern( 'support.hand_off_refund', { ticketId, orderId }, ({ input, delegation }) => refundSpecialist.handle({ ...input, scope: delegation!.scope, tools: delegation!.tools, headers: veriproof.lineageHeaders(), }), { delegation: new Delegation({ calleeApplicationId: SPECIALIST_APPLICATION_ID, scope: ['read:orders', 'refund:orders'], tools: ['lookup_order', 'issue_refund'], callerScope: ['read:orders'], }), }, );

lineageHeaders() returns veriproof-parent with the running action’s session ID. On the specialist’s side, run the handler inside the incoming lineage so its governed calls link to the handoff:

app.post('/refunds', async (req, res) => { await specialistVeriproof.withIncomingLineage(req.headers, async () => { // governed calls here link to the planner's handoff }); });

The Express, Fastify, and Next.js adapters can do this for you per route with their incomingLineage option, which is off by default. Read incoming lineage only on endpoints that serve your own trusted services.

What rules can use

A linked session’s policy evaluations include input.lineage, recorded and verified by VeriProof:

FieldMeaning
relationparent or workflow
parent_session_id, parent_application_idThe parent, for parent links
chain, depthThe applications from the workflow’s root to the parent
authority_decision_idThe handoff decision that allowed a link across applications
granted_scope, granted_toolsWhat that handoff granted the callee
workflow_idThe workflow this session belongs to

A specialist’s rule can deny a tool or scope the handoff didn’t grant, so narrowing a delegation is enforced in the callee. The “Deny actions outside the delegated grant” template does this. It compares input.tool.name with granted_tools at the tool check, which the specialist gets when it passes the tool’s name to govern. With granted_tools of ["lookup_order"], a call governed with the tool name issue_refund is denied before it runs. A handoff check’s chain, depth, and cycle facts also come from this verified lineage. The Delegation type no longer accepts a caller-supplied chain. See policy evaluations.

A link that fails verification stops the call before its action runs. The result is failed, with execution not_started and one of these reasons:

ReasonWhat happenedWhat to do
runtime_error:lineage_session_not_foundNo session with that ID exists in your organizationCheck the ID you stored or passed
runtime_error:lineage_not_authorizedThe session belongs to another application, and no allowed handoff names yours, or the relation was workflowLink through a handoff check that names this application
runtime_error:lineage_workflow_stoppedSomeone stopped the workflowStart new work outside the stopped workflow
runtime_error:lineage_unverifiableAn Agent Gateway couldn’t verify the link while disconnected from VeriProofRetry once the gateway reconnects

Setting both parent and workflow on one call fails as invalid_governance_input before anything is sent.

In each language

LanguageOptionsWorkflow scopeHeader helpers
TypeScriptparent, workflowveriproof.withWorkflow(id?, fn)lineageHeaders(), withIncomingLineage(headers, fn)
Pythonparent=, workflow=async with vp.workflow(id) as scope:lineage_headers(), incoming_lineage(headers)
.NETParent, Workflowawait using var scope = veriproof.BeginWorkflow(id);LineageHeaders(), BeginIncomingLineage(headers)
Java.parent(...), .workflow(...)try (var scope = veriproof.workflow(id))lineageHeaders(), incomingLineage(headers)
GoParent, Workflowctx, scope := client.WithWorkflow(ctx, id)LineageHeaders(ctx), WithIncomingLineage(ctx, header)
Rustparent, workflowveriproof.with_workflow(id, future)lineage_headers(), with_incoming_lineage(headers, future)

Each SDK’s account-free test harness applies the same acceptance rules, so you can test nested, delegated, staged, and refused calls without an account.

Find a workflow in the portal

Open any session in a workflow. The Workflow panel lists every session in order, with its application, action, verdict, and relation to the session you’re viewing. The Timeline, Hierarchy, Swimlane, and Flow views can switch to Whole workflow. Sessions in applications you can’t open appear as placeholders, so the workflow’s shape stays accurate. See Time Machine.

Last updated on