mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

fix: close posthog clients and only create clients if telemtry is ena…

Open hrisp opened this issue 1 month ago • 1 comments

Description

Every call to memory/telemetry.py:capture_event creates a new PostHog client, which internally creates a new thread to handle an internal message queue. This can lead to massive thread counts from idle PostHog clients.

The environment flag MEM0_TELEMETRY=False does not prevent this as it just pauses the PostHog client's internal queue processing.

This PR:

  • adds an explicit call to AnonymousTelemetry.close shutdown the PostHog client
  • honors the MEM0_TELEMETRY flag more conistently by not even creating a PostHog client.

See #3376

Type of change

Please delete options that are not relevant.

  • [x] Bug fix (non-breaking change which fixes an issue)

Maintainer Checklist

  • [ ] closes #xxxx (Replace xxxx with the GitHub issue number)
  • [ ] Made sure Checks passed

hrisp avatar Oct 16 '25 11:10 hrisp

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 16 '25 11:10 CLAassistant