Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The text in the chatbox changes after switching panels #12238

Open
xhzkp opened this issue Dec 16, 2024 · 3 comments
Open

The text in the chatbox changes after switching panels #12238

xhzkp opened this issue Dec 16, 2024 · 3 comments
Labels
in linear Issue or PR has been created in Linear for internal review

Comments

@xhzkp
Copy link

xhzkp commented Dec 16, 2024

Bug Description

Watching the video makes it easier to understand what happened.

BUG3.mp4

workflow code:

{
  "nodes": [
    {
      "parameters": {},
      "id": "34b64747-2660-425f-9e6c-b0e2711105b6",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.2,
      "position": [
        0,
        160
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=chatInput: {{ $json.chatInput }}\nsessionId: {{ $json.sessionId }}",
        "options": {
          "systemMessage": "You are a helpful assistant"
        }
      },
      "id": "dcfe6993-6dd4-45ec-8c76-f9175bf401fd",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.6,
      "position": [
        20,
        -100
      ]
    },
    {
      "parameters": {
        "options": {
          "baseURL": "https://oneapi.6868ai.com/v1"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        -180,
        160
      ],
      "id": "e5743849-084a-4880-b09a-98bc4e14aef7",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "p7mW3eJvUccvdSiC",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "public": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        -260,
        -100
      ],
      "id": "0dcc1f30-5bb9-47ec-a95e-c49351587ed4",
      "name": "When chat message received",
      "webhookId": "093f9196-1af3-4b19-b92d-b730bd8a83a9"
    }
  ],
  "connections": {
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}

To Reproduce

  1. copy workflow code
  2. run

Expected behavior

Keep the original message text.

Operating System

n8n cloud

n8n Version

1.72.1

Node.js Version

18.16.0

Database

SQLite (default)

Execution mode

main (default)

@Joffcom
Copy link
Member

Joffcom commented Dec 16, 2024

Hey @xhzkp,

We have created an internal ticket to look into this which we will be tracking as "N8N-7973"

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Dec 16, 2024
@OlegIvaniv
Copy link
Contributor

Hi @xhzkp, this a peculiar behaviour but not necessarily a bug. It's happening because you're passing text to agent as: "=chatInput: {{ $json.chatInput }}\nsessionId: {{ $json.sessionId }} and have memory connected. After navigating to Executions tab, we unmount the chat component. After navigating back to the canvas, we remount it and re-render the messages from the memory buffer execution. And since the actual message that went into the buffer was chatInput: ... \n sessionId: ... that gets mapped as the user message you see in the chat

@xhzkp
Copy link
Author

xhzkp commented Dec 18, 2024

Hi @xhzkp, this a peculiar behaviour but not necessarily a bug. It's happening because you're passing text to agent as: "=chatInput: {{ $json.chatInput }}\nsessionId: {{ $json.sessionId }} and have memory connected. After navigating to Executions tab, we unmount the chat component. After navigating back to the canvas, we remount it and re-render the messages from the memory buffer execution. And since the actual message that went into the buffer was chatInput: ... \n sessionId: ... that gets mapped as the user message you see in the chat

I think this is a bug. This issue occurs whenever the Text field is custom text. Every time, I have to click the reset button and then click confirm again...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

No branches or pull requests

3 participants