Derive foundational flow context category from flow reference

What does this MR do and why?

Each foundational flow picks its own name for the context category it sends to the AI Gateway. So the names do not match. Code Review sends code_review_context, and the other flows send agent_platform_<flow>_context. Someone writing a new flow config must look up the name, and nothing stops a new flow from picking yet another one.

With this MR, the flow resolvers return only the content. Rails names the category from the flow reference, always agent_platform_<flow>_context. Recommend Reviewers and Risk Classification already use that name, so nothing changes for them.

Code Review moves to agent_platform_code_review_context. Its flow configs still read code_review_context, so the flow also sends the same content under that old name with the new context_category_alias attribute. When the flow configs read the new name, we can remove the alias.

References

Screenshots or screen recordings

Not applicable. There is no UI change.

How to set up and validate locally

Use the gitlab-duo/test project with Duo Agent Platform enabled for its group.

Code Review sends both categories

  1. On a merge request in gitlab-duo/test, request a review from the Duo Code Review bot.

  2. Make sure the bot posts its review, the same as on master.

  3. Open the agent session for the review and go to its CI job. In a Rails console, look at the additional context the job got:

    build = Ci::Build.find(<job_id>)
    context = Gitlab::Json.parse(build.variables.to_hash['DUO_WORKFLOW_ADDITIONAL_CONTEXT_CONTENT'])
    context.pluck('Category')

    The list has both agent_platform_code_review_context and code_review_context, with the same Content.

Recommend Reviewers keeps its category

  1. Turn on the Recommend Reviewers flow for the group, and add an approval rule with two or more eligible approvers to gitlab-duo/test.
  2. Create a merge request. Make sure the agent session finishes and recommends reviewers, the same as on master.
  3. Check the session's CI job the same way as above. The list has agent_platform_recommend_reviewers_context only once.

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.

Merge request reports

Loading
Loading