Skip to content

Python: [Bug]: Mem0ContextProvider forwards unset user_id/agent_id as None to OSS client #9976

Closed

Description

@lisry-1

Observed Behavior

Mem0ContextProvider.after_run forwards user_id and agent_id to the OSS AsyncMemory client as unconditional direct kwargs, even though _validate_filters permits configuring only one of them. When only user_id is configured (agent_id is None), add() receives agent_id=None and the run crashes after the model has already produced a reply.

Expected Behavior

The OSS branch should be conditional, matching _build_filters: only include user_id/agent_id when non-empty.

Steps to Reproduce

  1. Configure Mem0ContextProvider with only user_id.
  2. Run an interaction that triggers after_run.
  3. Observe the crash after the reply is generated.

Minimal Reproduction

# user_id-only config is valid per _validate_filters,
# but OSS add() receives agent_id=None -> TypeError

Additional Context

Fix PR: #9911

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 2, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Nov 2, 2026
  3. github-actions commented on Nov 2, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    python/packages/mem0/agent_framework_mem0/_context_provider.py::Mem0ContextProvider.after_run at lines 268-270 forwards both identity kwargs when an OSS AsyncMemory client has only user_id or only agent_id configured. Minimal repro: construct the provider with a mocked OSS client and one identity, invoke after_run with a nonempty message, and assert the unset identity key is absent from add() kwargs.

    • Failing test: python/packages/mem0/tests/test_mem0_context_provider.py
    • Files examined: python/packages/mem0/agent_framework_mem0/_context_provider.py, python/packages/mem0/tests/test_mem0_context_provider.py, python/packages/mem0/pyproject.toml
    • Tests run: TestAfterRun::test_oss_stores_identity_fields_as_direct_kwargs, TestAfterRun::test_oss_storage_omits_unset_identity_fields
    • Current version: 1.0b261030
  4. added
    memoryUsage: [Issues, PRs], Target: memory related features
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

memoryUsage: [Issues, PRs], Target: memory related featurespythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions