Fix DUO_WORKFLOW_DEFINITION env var for custom flows

What does this MR do and why?

StartWorkflowService#resolved_workflow_definition builds the DUO_WORKFLOW_DEFINITION env var by concatenating flow_config_id and flow_config_schema_version. For foundational flows this works fine because FoundationalFlowStartParamsResolver always sets flow_config_id.

Custom (non-foundational) flows from AI Catalog don't go through that resolver, so flow_config_id is blank. That means DUO_WORKFLOW_DEFINITION ends up as "/v1" instead of something meaningful.

This MR adds a fallback: when flow_config_id is blank, we use the stable workflow_definition stored on the workflow record (e.g. ai_catalog_agent). Foundational flows are not affected since they always have flow_config_id set.

References

Screenshots or screen recordings

Before After

How to set up and validate locally

Verification steps

Setup

  1. Make sure you have a custom flow (non-foundational) set up in AI Catalog
  2. Trigger the custom flow from an issue comment via @mention (e.g. @ai-my-helpful-flow hi)
  3. Once the workflow starts, open the CI job page for the workflow run

Check the env var

  1. In the job log, find the echo $DUO_WORKFLOW_DEFINITION line
  2. Confirm it shows ai_catalog_agent (not /v1)
  3. The workflow should run and complete successfully

Run specs

bin/rspec ee/spec/services/ai/duo_workflows/start_workflow_service_spec.rb

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 Jaydip Pansuriya

Merge request reports

Loading