Skip to content

feat: add missing queue handlers for batch operations and code improvements#820

Open
Husainbw786 wants to merge 1 commit intomainfrom
fix/log-queue-handlers-820
Open

feat: add missing queue handlers for batch operations and code improvements#820
Husainbw786 wants to merge 1 commit intomainfrom
fix/log-queue-handlers-820

Conversation

@Husainbw786
Copy link
Copy Markdown
Collaborator

Summary

This PR adds missing queue handlers that were identified in the code review of PR #819. Python is publishing message types that Node.js had no handlers for, causing data to be dropped.

Changes

New Queue Handlers

  • updateBatchHistory - Updates conversation_logs for batch processing results (writes to PostgreSQL)
  • saveBatchMetrics - Saves batch metrics to Timescale DB

Code Quality Improvements

  1. Moved inline Mongoose schema to proper model file

    • Created src/mongoModel/AgentMemory.model.js with proper schema definition
    • saveToAgentMemory.service.js now imports from the model file
  2. Added input validation guards

    • All service functions now validate input parameters before processing
    • Returns early with warning logs for invalid inputs
  3. Moved hardcoded prompt to config

    • Created src/configs/prompts.config.js for centralized prompt management
    • handleGptMemory.service.js now uses GPT_MEMORY_PROMPT constant
  4. Increased batchSize from 1 to 10

    • Better throughput for queue processing
    • Configurable via logQueueConsumerConfig

Files Created

  • src/consumers/logQueueConsumer.js - Main consumer with all handlers
  • src/services/logQueue/ - Service files for each handler type
  • src/mongoModel/AgentMemory.model.js - Extracted Mongoose model
  • src/configs/prompts.config.js - Centralized prompts config

Files Modified

  • src/consumers/index.js - Added log queue consumer registration
  • src/configs/constant.js - Added canonicalizer bridge_id

Environment Variables

To enable the log queue consumer, set:

LOG_QUEUE_CONSUMER_ENABLED=true

Reference

Related to PR #819 (this is a separate PR as requested)

…ements

- Add handlers for update_batch_history and save_batch_metrics (Python publishes these)
- Move inline Mongoose schema to AgentMemory.model.js
- Add input validation guards in all service functions
- Move hardcoded GPT memory prompt to prompts.config.js
- Increase batchSize from 1 to 10 for better throughput

Handlers added:
- saveSubThreadIdAndName.service.js
- validateResponse.service.js
- totalTokenCalculation.service.js
- chatbotSuggestions.service.js
- handleGptMemory.service.js (with config-based prompt)
- saveToAgentMemory.service.js (uses AgentMemory model)
- saveFilesToRedis.service.js
- sendApiHitEvent.service.js
- broadcastResponseWebhook.service.js
- updateBatchHistory.service.js (NEW - writes to PostgreSQL)
- saveBatchMetrics.service.js (NEW - writes to Timescale)

Ref: PR #819
@windsurf-bot
Copy link
Copy Markdown
Contributor

windsurf-bot bot commented Mar 16, 2026

PR review rate limit exceeded

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.

2 participants