Draft: Add engine_owned_chat_environment feature flag for Duo Workflow

What does this MR do and why?

Adds the engine_owned_chat_environment flag and pushes it into the Duo Workflow Service request metadata. This is the Rails half of the chat engine work in the AI gateway:

The flag gates gateway behavior only. Rails defines it and pushes it per request. It is evaluated per user before it is pushed, so the standard percentage and actor rollout controls apply to the gateway behavior with no client changes in any Duo client (Web, IDE extensions, CLI).

The flag gates exactly one gateway behavior: routing the plain chat workflow definition to agentic_chat/2.0.0. In the gateway, engine selection is a registry table of engine-owned config versions keyed by config_id and version. A listed version runs on the chat engine (ChatFlow), every other chat-partial version stays on legacy chat.Workflow, and no shipped version is listed at launch, so existing configs are unchanged by construction. The engine itself ships flagless, and agentic_chat/2.0.0 is reachable by explicit pin before any flag flips.

Enablement preconditions live on gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#2780 (closed):

  • Per-session pin (below).
  • Both IDE webviews template /explain, /fix, /refactor and /tests client side, because the engine renders no command macros (gitlab-lsp#3063).

Not in this MR: the session pin

The cutover needs Rails to store the resolved flow config_id and version at session creation and send them on every resume, so the gateway routes by the pin and a session started on legacy chat finishes there after the flag flips. Today every start request re-resolves from the client's workflowDefinition, so a session would switch engines mid-life. Ai::FoundationalChatAgent already stores reference/version for the foundational agents; plain chat sessions store the bare string. The pin is a sibling change (a column or flow_metadata_json, plus the value on the gateway token claim or the start request), owner pending, tracked under cutover preconditions on gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#2780 (closed). Whether old threads become read-only after the cutover or get a converter is a product decision and does not block the pin.

Merge-order note: neither this MR nor the gateway MRs depend on each other to merge. The flag defaults off. This MR must land before the flag can be enabled anywhere.

The flag is type: wip with the rollout issue pointing at gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#2780 (closed), which carries the enablement preconditions.

Evidence from the POC spike (ai-assist#2706): end-to-end demo through the unmodified production VS Code extension, https://www.youtube.com/watch?v=WzbxtbsoOt0.

How to set up and validate locally

  1. Check out this branch. Enable the flag: Feature.enable(:engine_owned_chat_environment).
  2. With the flag disabled, chat behaves exactly as before.
  3. Before the gateway routing-cutover rung lands, the enabled flag also changes nothing: it selects no behavior yet, and it appears in the Duo Workflow Service logs' feature-flag context.
  4. Once the cutover rung lands in gitlab-ai-gateway, an enabled flag routes a plain chat session to agentic_chat/2.0.0.
Edited by John Slaughter

Merge request reports

Loading
Loading