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

fix(OpenAI Node): Limit chat history to context window when using memory #13137

Conversation

jeanpaul
Copy link
Contributor

@jeanpaul jeanpaul commented Feb 7, 2025

Summary

When using the OpenAI "message assistant" operation with memory, the full chat history would be sent to the assistant, instead of limiting to the context window configured in the memory node. This should now be fixed by leveraging the loadMemoryVariables method.

Related Linear tickets, Github issues, and Community forum posts

Fixes #12958

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Feb 7, 2025
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...dors/OpenAi/actions/assistant/message.operation.ts 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

cypress bot commented Feb 10, 2025

n8n    Run #9209

Run Properties:  status check passed Passed #9209  •  git commit 328a412144: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 jeanpaul 🗃️ e2e/*
Project n8n
Branch Review ai-656-community-issue-postgres-chat-memory-node-returns-full-table
Run status status check passed Passed #9209
Run duration 04m 32s
Commit git commit 328a412144: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 jeanpaul 🗃️ e2e/*
Committer JP van Oosten
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 5
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 434
View all changes introduced in this branch ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

@jeanpaul jeanpaul merged commit f057cfb into master Feb 10, 2025
37 checks passed
@jeanpaul jeanpaul deleted the ai-656-community-issue-postgres-chat-memory-node-returns-full-table branch February 10, 2025 14:41
@github-actions github-actions bot mentioned this pull request Feb 13, 2025
@janober
Copy link
Member

janober commented Feb 13, 2025

Got released with n8n@1.79.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postgres Chat Memory Node Returns Full Table Instead of Limited Context Window
3 participants