Quick Fix agent selection bug in duo agentic chat

meant to fix: https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/issues/1457#note_2779387121

Fix agent selection bug where cached flow configuration was reused when switching between agents in Duo Agentic Chat.

What does this MR do?

  • Clears cached flowConfig when switching agents to ensure fresh agent configuration is fetched
  • Adds test coverage for flowConfig cache management

Why was this change made?

Previously, when users switched between agents (e.g., from "software developer" to "Talk like a Pirate"), the flowConfig from the previous agent remained cached. This caused the wrong agent configuration (system prompts, model settings, etc.) to be sent to the backend, resulting in incorrect agent behavior.

The root cause was in the onSendChatPrompt method's condition:

 if (this.aiCatalogItemVersionId && !this.flowConfig) {
   // Only fetches if flowConfig is empty
 }

When switching agents, flowConfig wasn't cleared, so the condition evaluated to false and no fresh configuration was fetched.

How to set up and validate locally

  1. Open Duo Agentic Chat
  2. Select an agent (e.g., "software developer") and send a message
  3. Switch to a different agent (e.g., "Talk like a Pirate")
  4. Send another message
  5. Verify the agent responds with the correct personality/behavior
Edited by Jannik Lehmann

Merge request reports

Loading