Add cleanup_stuck_agent_platform_session event

What does this MR do and why?

This MR adds a cleanup_stuck_agent_platform_session event that is triggered when the FailStuckWorkflowsWorker cron drops the stuck sessions.

Changelog: changed EE: true

Relates to #557487 (closed)

References

Screenshots or screen recordings

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Example:

  1. Create a new workflow
curl POST --verbose \
    --header "Authorization: Bearer $GDK_TOKEN" \
    --header 'Content-Type: application/json' \
    --data '{
        "project_id": "flightjs/test-duo", "goal": "My goal", "agent_privileges": [1,2,5]
    }' \
    http://gdk.test:3000/api/v4/ai/duo_workflows/workflows
  1. Make the workflow running stale
     w = ::Ai::DuoWorkflows::Workflow.last
     w.start
     w.update(updated_at: 4.days.ago)
  2. Trigger CleanStuckWorkflowsService
::Ai::DuoWorkflows::CleanStuckWorkflowsService.new.execute
  1. You should see the session status became failed
w.reload.human_status_name # should be failed
  1. You should see a new analytics event at http://localhost:9093/micro/ui (see the gdk config get snowplow_micro.port for the correct port)

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Halil Coban

Merge request reports

Loading