fix: conversation lock, case-insensitive mentions, routing prefix strip#136
Merged
fix: conversation lock, case-insensitive mentions, routing prefix strip#136
Conversation
…s, multi-agent race condition Bug 1 (Response Drops): Channel clients had non-atomic send-then-ack flow causing random response loss. Added 'delivering' status to SQLite responses table, claim/unclaim API endpoints, and claim-before-send pattern in Telegram client with retry tracking (max 3 attempts). Bug 2 (Inter-Agent Mention Failures): Teammate mentions were silently dropped due to case sensitivity, typos, and missing validation logging. Added case-insensitive agent ID lookup, detailed logging in isTeammate() and extractTeammateMentions(), improved regex for bracket handling, and validateAgentResponse() helper. Bug 3 (Multi-Agent Reply Loss): Race condition on conv.pending counter when multiple agents complete simultaneously caused replies to never arrive. Added withConversationLock() promise-chain mutex, safe incrementPending/decrementPending operations, and automatic conversation state recovery. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The messages API route prepends [channel/sender]: to incoming messages, which caused parseAgentRouting() regex to fail since the message no longer starts with @agent_id. This made all messages fall back to the first agent regardless of @mentions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unnecessary files and bug 1 delivery infrastructure: - Remove CLAUDE.md, docs/bug-fixes/* - Revert telegram-client.ts to main (no claim/unclaim pattern) - Remove delivering status, claim/unclaim/recover from db.ts - Remove claim/unclaim API endpoints from queue routes - Remove validateAgentResponse dead code from routing.ts - Remove recoverConversation from queue-processor hot path Keep bugs 2-4: case-insensitive mentions, conversation lock, prefix strip for @agent routing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
closes #134 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cherry-picked from #134 with docs/CLAUDE.md and bug 1 (claim/unclaim delivery) stripped out.
isTeammate(): Mentions that fail validation now log the reason (team not found, self-mention, agent not in team, agent not in config) instead of failing silentlyextractTeammateMentions():\S+?→[^\]]+?for correct bracket boundary matchingconv.pending--was not atomic across concurrent promise chains. AddedwithConversationLock()mutex,incrementPending()/decrementPending()helpersparseAgentRouting()prefix handling: Messages API prepends[channel/sender]:which broke@agentrouting. Regex now optionally matches the prefix while preserving it in the messageRemoved from #134
validateAgentResponse()(dead code)recoverConversation()on every message (wasteful)Test plan
npm run buildcompiles cleanly🤖 Generated with Claude Code