Example: Automated Report Generation
The example below submits a “generate weekly sales report” mission, then streams the resulting events to collect the completed output. Notice thatcreateMission requires an idempotency key — if your worker restarts mid-flight and submits the same key again, Praxa returns the existing mission rather than creating a duplicate.
Example: Content Summarization
Summarization missions follow the same pattern. Pass the document content or a reference to it insidegoalSpec, and tune the resource budget to the expected length of the input.
Handling Results
Every mission streams a sequence of server-sent events throughmissionEvents(). To extract the final result, listen for mission.completed — its data field contains the agent’s output payload.
The event stream closes automatically once a terminal event (
mission.completed,
mission.failed, or mission.cancelled) is emitted. You do not need to
explicitly close the connection.Scheduling Missions
Praxa missions are a natural fit for cron jobs and queue workers becausecreateMission is idempotent — submitting the same idempotency key twice returns the original mission projection rather than starting a second execution.
1
Generate a stable idempotency key
Derive the key from the job’s logical identity (for example, a combination
of the task name and the time window) so that retries after worker failures
submit the same key.
2
Submit the mission in your cron handler
3
Store the runId for later retrieval
Persist
mission.runId in your database so you can fetch the mission status
later with getMission(runId) without re-streaming the event log.