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

[Bug] User memory imported to session memory #2057

Open
jeffbryner opened this issue Feb 9, 2025 · 0 comments
Open

[Bug] User memory imported to session memory #2057

jeffbryner opened this issue Feb 9, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@jeffbryner
Copy link

Description

There is the concept of storage and the concept of memory. There appears to be an unintended overlap between them which pulls user memories into session storage even if the conversation or tasks are unrelated.

Steps to Reproduce

Create an agent using storage and memory with multiple chat sessions.
If a session results in 'user' memory being updated that update will be pulled into sessions as 'session memory'.

Agent Configuration (if applicable)

agent = Agent(
    telemetry=False,
    user_id="[email protected]",
    model=Gemini(
        id=model,
        generation_config=generation_config,
        safety_settings=safety_settings,
        system_prompt=system_prompt,
    ),
    storage=FirestoreAgentStorage(
        collection_name="agent_sessions",
    ),
    # Store memories in Firestore, options off
    memory=AgentMemory(
        db=FirestoreMemoryDb(),
        create_user_memories=True,
        create_session_summary=True,
        update_user_memories_after_run=True,
        update_session_summary_after_run=True,
        classifier=MemoryClassifier(model=Gemini(id="gemini-1.5-pro")),
        summarizer=MemorySummarizer(model=Gemini(id="gemini-1.5-pro")),
        manager=MemoryManager(model=Gemini(id="gemini-1.5-pro")),
    ),
    # Set add_history_to_messages=true to add the previous chat history to the messages sent to the Model.
    add_history_to_messages=True,
    # Number of historical responses to add to the messages.
    num_history_responses=10,
    create_default_user_message=False,
    retries=3,
    instructions=system_prompt,
    markdown=True,
)

Expected Behavior

I expected the user memory store to updated with key facts about the user (name, interests, etc) and the session memory store to remain relevant to the session.

Actual Behavior

The user memory store was updated according to a conversation in a session. That session included the memories.
When starting another conversation in a different session, the memories from the user were imported into this session but we not relevant.

Screenshots or Logs (if applicable)

User memory after a conversation about beer:

User memory storing facts

Session data object after the same conversation:

Session data object for a conversation about beer

Session data after a subsequent conversation about whiskey:

Session data object for a conversation about whiskey

Environment

Possible Solutions (optional)

I believe this is happening due to the agent.get_agent_session pulling in memories from the user memory store
https://github.com/agno-agi/agno/blob/main/libs/agno/agno/agent/agent.py#L1453

'Memory' is stored and retrieved by user id. https://github.com/agno-agi/agno/blob/main/libs/agno/agno/memory/db/mongodb.py#L71
'Session' storage is by session ID and user idbut due to the call above in get_agent_session it imports user memories. https://github.com/agno-agi/agno/blob/main/libs/agno/agno/storage/agent/mongodb.py#L61

Later when the agent saves it's information to storage, this is used as 'memories' in the session data object.

Could there be a flag to not store user memory in the session? This would make it clear that they are only related to the user and not the session.
Could there be a better prompt for user memory such that it is less about the conversation and more about the facts (name, likes, etc)? This way it would be less likely to influence the session conversation.

Additional Context

This could lead to confusing inferences from the model if it stores data in one context, but uses it in another session inappropriately.

@jeffbryner jeffbryner added the bug Something isn't working label Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant