fix: channelId extraction, sender identification, and per-channel turn order #9
Reference in New Issue
Block a user
Delete Branch "fix/turn-gate-and-handoff"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes moderator bot silence and turn deadlocks. See commit message for details.
Turn system redesign: - Turn order auto-populated from config bindings (all bot accounts) - No manual turnOrder config needed - Humans (humanList) excluded from turn order automatically - Dormant state: when all agents NO_REPLY in a cycle, currentSpeaker=null - Reactivation: any new message wakes the system - Human message → start from first in order - Bot not in order → start from first - Bot in order → next after sender - Skip already-NO_REPLY'd agents when advancing Identity injection: - Group chat prompts now include agent identity - Format: '你是 {name}(Discord 账号: {accountId})' Other: - Remove turnOrder from ChannelPolicy (no longer configurable) - Add TURN-WAKEUP-PROBLEM.md documenting the NO_REPLY wake-up challenge - Update message_received to call onNewMessage with proper human detection - Update message_sent to call onSpeakerDone with NO_REPLY tracking- Fix channelId extraction: ctx.channelId is platform name ('discord'), not the Discord channel snowflake. Now extracts from conversation_label field ('channel id:123456') and sessionKey fallback (':channel:123456'). - Fix extractDiscordChannelId: support 'discord:channel:xxx' format in addition to 'channel:xxx' for conversationId/event.to fields. - Fix sender identification in message_received: event.from returns channel target, not sender ID. Now uses event.metadata.senderId for humanList matching so human messages correctly reset turn order. - Fix per-channel turn order: was using all server-wide bot accounts from bindings, causing deadlock when turn landed on bots not in the channel. Now dynamically tracks which bot accounts are seen per channel via message_received and only includes those in turn order. - Always save sessionChannelId/sessionAccountId mappings in before_model_resolve regardless of turn check result, so downstream hooks can use them. - Add comprehensive debug logging to message_sent hook.