﻿# Exa Agent runs need a lifecycle beyond the first HTTP response

Build an Exa Agent consumer around a durable run identity, terminal status, and final grounding rather than treating the first accepted response as completion.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-exa-agent-run-lifecycle/
Language: en

## Acceptance starts a run

A research dashboard may ask Exa Agent to assemble a structured supplier list. The caller should distinguish acceptance of that work from availability of the list. Save the returned run identity with the local job before showing progress; losing that association can lead a reconnecting client to submit duplicate work instead of resuming observation.

## Preserve the original request

The [create-run reference](https://exa.ai/docs/reference/agent-api/create-a-run) includes the query, output schema, and budget fields. Store those choices with the job identity. They explain what the run was asked to produce and which limits applied, while the final output explains what was actually returned. Keep caller abandonment separate from any provider-side lifecycle action.

## Interpret status explicitly

The [get-run reference](https://exa.ai/docs/reference/agent-api/get-a-run) exposes `queued`, `running`, `completed`, `failed`, and `cancelled`. A worker should keep pending states pending and route terminal states to different handlers. Do not translate a failed run into an empty successful supplier list; that would conceal an execution error as a factual finding.

After a caller timeout, retain the run ID and query its state before deciding whether new research is needed. A local connection failure does not establish that remote execution stopped. This is particularly important when the research job has a meaningful budget or several waiting consumers.

## Correlate progress by identity

The [Agent guide](https://exa.ai/docs/agent/quickstart) documents streaming events and `callId` relationships. It warns that some descriptions arrive asynchronously. Group observations using their explicit identities rather than arrival order; otherwise a delayed explanation can be attached to the wrong source or tool call in the dashboard.

Treat live source additions as progress previews. The same guide identifies terminal `output.grounding` as the authoritative grounding output. Preserve previews for user visibility, but reconcile the final evidence view from the completed run instead of accumulating every preview into a presumed final citation list.

## Validate the terminal artifact

Check that the returned structured output fits the application's schema and that required findings have suitable grounding. Completed execution is not a guarantee that every supplier meets the caller's business criteria. Keep unknown criteria visible for review.

The existing guides to [task contracts](/journal/learn-codex-task-contract/) and [terminal stream handling](/journal/provider-sse-terminal-eof-contract/) supply complementary boundary checks. Exercise reconnects and delayed events with stored examples; this verifies the consumer without claiming a new live provider benchmark.
