Skip to content

Conversation

@Amnah199
Copy link
Contributor

@Amnah199 Amnah199 commented Oct 28, 2025

Related Issues

  • partially fixes - #219

Proposed Changes:

  • This PR integrates mem0 as a memory store in Haystack, supporting basic add, retrieve, and delete operations.
  • It updates the memory_agents.Agent class to enable retrieving and persisting long-term conversational context.

Key Changes

  • Added memory support to memory_agents.Agent.
  • Before each execution, relevant memories are fetched from Mem0MemoryStore using the latest user message as the query.
  • Retrieved memories are injected into the conversation as [MEMORY #n] ChatMessage objects.
  • When memories exist, the system prompt is updated to tell the LLM that [MEMORY] messages represent long-term context.
  • After each run, new user and assistant messages are saved to the memory store.
  • Memory is optional; agents behave normally when memory_store=None.

How did you test it?

  • Unit and Integration Tests
  • Tested locally with examples

Notes for the reviewer

Support for Memory.from_config will be revised in a separate PR as it has a slightly different implementation than mem0 MemoryClient.
https://docs.mem0.ai/platform/platform-vs-oss

Checklist

@coveralls
Copy link

coveralls commented Oct 28, 2025

Pull Request Test Coverage Report for Build 21253212844

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 106 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-3.3%) to 64.843%

Files with Coverage Reduction New Missed Lines %
components/agents/agent.py 106 53.15%
Totals Coverage Status
Change from base Build 21230795241: -3.3%
Covered Lines: 972
Relevant Lines: 1499

💛 - Coveralls

@Amnah199 Amnah199 marked this pull request as ready for review December 3, 2025 11:54
@Amnah199 Amnah199 requested a review from a team as a code owner December 3, 2025 11:54
@Amnah199 Amnah199 requested review from mpangrazzi and sjrl and removed request for a team and mpangrazzi December 3, 2025 11:54
@Amnah199 Amnah199 requested a review from a team as a code owner January 21, 2026 11:13
@sjrl
Copy link
Contributor

sjrl commented Jan 22, 2026

@Amnah199 I noticed that the tests are failing for AWS since it's not set up for this repo. I'd check how it's done in our core integrations repo. Also I noticed a lot of tests for Mem0 are being skipped could you see why that's the case?

OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
MEM0_API_KEY: ${{ secrets.MEM0_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
AWS_REGION: "us-east-1"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And right before integration-tests: add this block

      # Do not authenticate on PRs from forks and on PRs created by dependabot
      - name: AWS authentication
        id: aws-auth
        if: github.event_name == 'schedule' || (github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.event.pull_request.head.ref, 'dependabot/'))
        uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708
        with:
          aws-region: ${{ env.AWS_REGION }}
          role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }}

aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }}

- name: Run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we also have this in the bedrock integration tests

Suggested change
- name: Run
- name: Run
if: success() && steps.aws-auth.outcome == 'success'

@sjrl
Copy link
Contributor

sjrl commented Jan 22, 2026

@anakin87 could we ask for your help on what might be going wrong with the AWS auth setup in tests?

@anakin87
Copy link
Member

anakin87 commented Jan 22, 2026

@sjrl try adding

permissions:
  id-token: write
  contents: read

on the test workflow, on top level
as in https://github.com/deepset-ai/haystack-core-integrations/blob/943ad7f0e7633dd43a0331602ec41c6074fca5c3/.github/workflows/amazon_bedrock.yml#L22-L24

It seems it also worked on this repo in the past

Copy link
Contributor

@sjrl sjrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all of the work on this!

Let's make sure to add a pydoc for this in a follow up PR

@Amnah199 Amnah199 merged commit eb937c7 into main Jan 22, 2026
8 checks passed
@Amnah199 Amnah199 deleted the mem0-integration branch January 22, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants