Actions
Task #931
closedPE-1816: Add async persona generation with status webhook
Status:
Done
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
2026-05-16
Due date:
% Done:
100%
Estimated time:
Description
Problem¶
Persona generation is synchronous. User must poll for completion. No automatic notification when generation finishes.
Current Flow¶
- POST /api/v1/personas (sync request)
- If generation takes time, user must poll GET /api/v1/personas/{id}/status
- No automatic callback
Proposed Solution¶
- POST /api/v1/personas/generate-async - Returns job ID immediately
- GET /api/v1/personas/jobs/{id} - Check status
- Webhook sent when generation completes (PersonaReady event)
Async Job Flow¶
- User submits: POST /api/v1/personas/generate-async with {name, archetype, traits}
- Returns: {job_id: 'uuid', status: 'queued', poll_url: '/api/v1/personas/jobs/uuid'}
- Backend dispatches GeneratePersonaJob
- On complete: webhook sent to user's configured URL
- User can poll for status anytime
Benefits¶
- Non-blocking API
- Webhook notification on completion
- Better UX for long-running generations
- Support for bulk generation
Implementation¶
- Use Laravel Queue (already configured)
- Create GeneratePersonaJob
- Add personas_jobs table (id, user_id, status, progress, result, error)
- Modify WebhookService to dispatch on persona events
Files to Create/Modify¶
- app/Jobs/GeneratePersonaJob.php
- app/Http/Controllers/Api/PersonaJobController.php
- database/migrations/ (personas_jobs table)
- app/Services/PersonaService.php (event dispatch)
- routes/api_v1.php
Updated by Fredrick Amnehagen 41 minutes ago
- Status changed from To do to Done
- % Done changed from 0 to 100
Added persona_jobs table, PersonaJob model, AsyncPersonaGenerationJob, PersonaJobController. Added POST /personas/generate-async (returns job_id immediately), GET /personas/jobs/{id} (status), POST /personas/jobs/{id}/retry, POST /personas/jobs/{id}/cancel. Webhook dispatched on completion.
Actions