Loading

Agentforce : Control LLM response while rendering LWC component, avoiding dual responses

Fecha de publicación: Aug 17, 2026
Descripción

Issue : Here is one of a use case where we have observed an issue while trying to display the LWC alone it's been observed along with LLM response and followed by LWC getting rendered giving rise to dual response.

Steps to replicate (example usecase):

  • Open Experience site (as Guest user or Admin user)
  • Pass input prompt to the agent
  • You can see the LLM also responds along with the LWC component's response making it appear twice.
Solución

Make sure the below prerequisites are verified when LWC is configured:

1) "additional_parameter__disable_streaming" should be set to "True"

By default, Agentforce uses Server-Sent Events (SSE) to stream responses in real time. While this creates a fast, responsive feel, the LLM may revise or reformat content mid-stream, causing the displayed output to differ from the final result.
Streaming in NGA is disabled at the script level.

2)"adaptive_response_allowed" should be set to "True"

Adaptive Response — the feature that controls output format richness — is not enabled by default in all agent configurations. It must be explicitly allowed in the Agent Script

In order to make sure, the responses from LLM are controlled, please make a note of important configuration :

The dual response = caption text + LWC component, both from a single "__show_tool_results__ call".In the usecase, the conflicting instruction in the GeneralFAQ topic prompt also contributed towards the issue.


In AgentBuilder, edit/add the Topic instructions as below:

" If @variables.<action> is not None, do NOT add any text or caption "
"Only render the Custom UI component using __show_tool_results__ with an empty string as the caption."
"Do not ask follow-up questions after the response"

NOTE: 

You can find the value field __show_tool_results__ call by querying like the below in the query editor to observe if the captions appear and then modify the instructions mentioned.

 

[ WITH
    -- Keep session ID in temp table for easier reference
    params AS (
        SELECT
            '<SESSION_ID>' AS session_id
    ),
    -- Retrieve the agent interactions and agent interaction messages to see each turn and input/output messages per turn
    interactionsWithMessages AS (
        SELECT
            S.ssot__RelatedMessagingSessionId__c AS RelatedMessagingSessionId,
            S.ssot__VariableText__c AS InitialVariables,
            S.ssot__RelatedVoiceCallId__c AS RelatedVoiceCallId,
            S.ssot__AiAgentChannelType__c AS AiAgentChannelType,
            I.ssot__AiAgentInteractionType__c AS InteractionType,
            I.ssot__StartTimestamp__c AS InteractionStartTime,
            I.ssot__EndTimestamp__c AS InteractionEndTime,
            I.ssot__TopicApiName__c AS TopicName,
            M.ssot__MessageSentTimestamp__c AS MessageSentTime,
            M.ssot__ContentText__c AS ContextText,
            M.ssot__AiAgentInteractionMessageType__c AS InteractionMessageType
        FROM
            ssot__AiAgentSession__dlm AS S
            JOIN ssot__AiAgentInteraction__dlm AS I ON S.ssot__id__c = I.ssot__aiAgentSessionId__c
            JOIN ssot__AiAgentInteractionMessage__dlm AS M ON I.ssot__id__c = M.ssot__aiAgentInteractionId__c
            JOIN params AS p ON S.ssot__Id__c = p.session_id
    ),
    -- Retrieve the agent interactions and agent interaction steps performed on each turn by the agent to generate its output
    interactionsWithSteps AS (
        SELECT
            S.ssot__RelatedMessagingSessionId__c AS RelatedMessagingSessionId,
            S.ssot__VariableText__c AS InitialVariables,
            S.ssot__RelatedVoiceCallId__c AS RelatedVoiceCallId,
            S.ssot__AiAgentChannelType__c AS AiAgentChannelType,
            I.ssot__AiAgentInteractionType__c AS InteractionType,
            I.ssot__StartTimestamp__c AS InteractionStartTime,
            I.ssot__EndTimestamp__c AS InteractionEndTime,
            I.ssot__TopicApiName__c AS TopicName,
            St.ssot__AiAgentInteractionStepType__c AS InteractionStepType,
            St.ssot__Name__c AS Name,
            St.ssot__InputValueText__c AS InputValueText,
            St.ssot__OutputValueText__c AS OutputValueText,
            St.ssot__StartTimestamp__c AS InteractionStepStartTime,
            St.ssot__PreStepVariableText__c AS PreStepVariableText,
            St.ssot__PostStepVariableText__c AS PostStepVariableText
        FROM
            ssot__AiAgentSession__dlm AS S
            JOIN ssot__AiAgentInteraction__dlm AS I ON S.ssot__id__c = I.ssot__aiAgentSessionId__c
            JOIN ssot__AiAgentInteractionStep__dlm AS St ON I.ssot__id__c = St.ssot__aiAgentInteractionId__c
            JOIN params AS p ON S.ssot__Id__c = p.session_id
    ),
    -- Join both data sets
    interactionsWithMessagesAndSteps AS (
        SELECT
            *,
            CAST(NULL AS VARCHAR) AS InteractionStepType,
            CAST(NULL AS VARCHAR) AS Name,
            CAST(NULL AS VARCHAR) AS InputValueText,
            CAST(NULL AS VARCHAR) AS OutputValueText,
            CAST(NULL AS VARCHAR) AS PreStepVariableText,
            CAST(NULL AS VARCHAR) AS PostStepVariableText
        FROM
            interactionsWithMessages
        UNION ALL
        SELECT
            RelatedMessagingSessionId,
            InitialVariables,
            RelatedVoiceCallId,
            AiAgentChannelType,
            InteractionType,
            InteractionStartTime,
            InteractionEndTime,
            TopicName,
            -- Use InteractionStepStartTime as MessageSentTime to sort unified records
            InteractionStepStartTime AS MessageSentTime,
            CAST(NULL AS VARCHAR) AS ContextText,
            CAST(NULL AS VARCHAR) AS InteractionMessageType,
            InteractionStepType,
            Name,
            InputValueText,
            OutputValueText,
            PreStepVariableText,
            PostStepVariableText
        FROM
            interactionsWithSteps
    ),
    -- Add row numbers to identify the first row
    rankedData AS (
        SELECT
            *,
            ROW_NUMBER() OVER (ORDER BY MessageSentTime ASC) AS row_num
        FROM
            interactionsWithMessagesAndSteps
    )
-- Reorder fields and sort them by MessageSentTime
-- Show InitialVariables only on the first row
SELECT
    TopicName,
    MessageSentTime,
    InteractionMessageType,
    ContextText,
    InteractionStepType,
    Name,
    InputValueText,
    OutputValueText,
    CASE WHEN row_num = 1 THEN InitialVariables ELSE NULL END AS InitialVariables,
    PreStepVariableText,
    PostStepVariableText,
    AiAgentChannelType
FROM
    rankedData
ORDER BY
    MessageSentTime ASC; ]

 

Número del artículo de conocimiento

005391020

 
Cargando
Salesforce Help | Article