Follow-up from "Gating external triggers execution based on Duo add-on"

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

The following discussion from !215104 (merged) should be addressed:

  • @jannik_lehmann started a discussion: (+1 comment)

    @jfypk I just took this MR for a spin with a focus on the duplicated error message you mentioned:

    duplicated error message screenshot
    Screenshot_2025-12-10_at_14.50.33

    Currently the error is reaching the Frontend twice, I teamed up with Duo so this is what I think is going on:

    In ee/lib/gitlab/llm/chain/tools/tool.rb line 112, the not_in_current_plan method has is_final: false when it creates the error. From what I can tell, when that's false, the ReactExecutor keeps going instead of stopping and returning the error right away. It adds the error to some kind of scratchpad thing and the loop continues, which I think is why we're seeing it twice in the UI.

    I changed it to is_final: true (which is what the other error methods use) and added a test. Ran the backend tests and they pass now. Let me know if this makes sense or if I'm missing something!

    diff --git a/ee/lib/gitlab/llm/chain/tools/tool.rb b/ee/lib/gitlab/llm/chain/tools/tool.rb
    index 383480ac076c..588ea1ef8274 100644
    --- a/ee/lib/gitlab/llm/chain/tools/tool.rb
    +++ b/ee/lib/gitlab/llm/chain/tools/tool.rb
    @@ -109,7 +109,7 @@ def not_in_current_plan
                   "Alternatively, I can help with other questions."
     
                 Answer.new(status: :error, context: context, content: content,
    -              is_final: false, tool: nil, error_code: "G3001")
    +              is_final: true, tool: nil, error_code: "G3001")
               end
     
               def not_found
    diff --git a/ee/spec/lib/gitlab/llm/chain/tools/tool_spec.rb b/ee/spec/lib/gitlab/llm/chain/tools/tool_spec.rb
    index 60e6bdde354f..bb0999b642c6 100644
    --- a/ee/spec/lib/gitlab/llm/chain/tools/tool_spec.rb
    +++ b/ee/spec/lib/gitlab/llm/chain/tools/tool_spec.rb
    @@ -89,6 +89,11 @@
     
               subject.execute
             end
    +
    +        it 'returns a final answer' do
    +          answer = subject.execute
    +          expect(answer.is_final?).to eq(true)
    +        end
           end
         end
     
    
  • !215104 (comment 2944883425)

  • !215104 (comment 2944883411)

Edited by 🤖 GitLab Bot 🤖