Skip to content

[Bug]: Durable agent workers continue querying MongoDB when queues are empty #16293

Description

@LaurensNiesten261

What happened?

The queued-turn recovery pass runs every 30 seconds and performs multiple reads even when there is no work to recover. The trigger-delivery worker also checks for work while idle, and a separate maintenance pass runs every 30 seconds. These background reads continue without agent activity.

An empty queue is a normal state, but it still generates persistent database traffic. The cost accumulates over time and scales with the number of server processes or replicas, even when no users are invoking agents.

Reduce database reads during long idle periods while preserving prompt delivery and recovery after crashes. A bounded idle backoff or another wake-up mechanism may help, provided new work still wakes workers promptly and multi-replica recovery remains reliable.

Queued-turn recovery: https://github.com/LibreChat-AI/LibreChat/blob/v0.8.8-rc2/packages/api/src/agents/queuedTurns.ts
Queued-turn persistence: https://github.com/LibreChat-AI/LibreChat/blob/v0.8.8-rc2/packages/data-schemas/src/methods/queuedTurn.ts
Trigger-delivery engine: https://github.com/LibreChat-AI/LibreChat/blob/v0.8.8-rc2/packages/api/src/agents/triggers/engine.ts
Trigger-delivery maintenance: https://github.com/LibreChat-AI/LibreChat/blob/v0.8.8-rc2/packages/api/src/agents/triggers/service.ts
Trigger-delivery persistence: https://github.com/LibreChat-AI/LibreChat/blob/v0.8.8-rc2/packages/data-schemas/src/methods/triggerDelivery.ts

Version Information

LibreChat version: v0.8.8-rc2
Commit: f9f1b2f
Branch: v0.8.8-rc2
Build date: 2026-09-03 02:28:46 UTC
User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 Edg/153.0.0.0

Steps to Reproduce

  1. Start LibreChat with durable agent trigger delivery enabled.
  2. Leave the instance running with no queued turns or pending trigger deliveries.
  3. Observe MongoDB reads against the queued-turn and trigger-delivery collections while the instance is otherwise idle.

What browsers are you seeing the problem on?

Microsoft Edge

Relevant log output

N/A

Screenshots

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions