feat(discord): migrate to extmsg fabric for thread management#2
Open
julianknutsen wants to merge 6 commits intomainfrom
Open
feat(discord): migrate to extmsg fabric for thread management#2julianknutsen wants to merge 6 commits intomainfrom
julianknutsen wants to merge 6 commits intomainfrom
Conversation
Rewrite CLI scripts to use the Gas City extmsg fabric instead of pack-local JSON state files: - bind-dm/bind-room: POST /v0/extmsg/bindings + transcript membership - enable-room-launch: POST /v0/extmsg/groups - publish: POST /v0/extmsg/outbound (peer notification via transcript) - reply-current: GET transcript context + POST /v0/extmsg/outbound Update prompt template: - Add shared conversation etiquette (respond only when YOU have something to add; silence is fine) - Remove peer fanout instructions and @@handle syntax - Remove exit code 2 peer delivery semantics Remove retry-peer-fanout command from pack.toml (no longer needed — transcript is the shared state, peers read it directly). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add normalize_to_extmsg_message() helper that converts Discord MESSAGE_CREATE events to extmsg ExternalInboundMessage format. Add _fuzzy_match_handle() for natural language participant targeting (replaces @@handle syntax with word-boundary matching against known participant names). Add deliver_to_extmsg() helper for posting normalized messages to the extmsg inbound API. Gateway now records inbound messages in extmsg transcript (best-effort) alongside existing session delivery. This dual-path allows incremental migration — extmsg transcript gets populated while existing routing continues to work. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Delete discord_chat_retry_peer_fanout.py entirely - Remove retry-peer-fanout.sh command wrapper and help text - Remove _apply_peer_fanout() call from publish_binding_message() The ~900 lines of peer fanout engine code (budget tracking, target resolution, delivery state machine, retry logic) remain in discord_intake_common.py as unreachable code for now. These functions are no longer called from any code path. A follow-up cleanup pass can remove them once the extmsg transcript-based peer awareness model is validated in production. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Room messages with @mentions now launch new Discord threads:
1. Parse @mentions from message text
2. Resolve each against managed sessions (by alias) then agent
templates (by name)
3. Create Discord thread from the source message
4. Create extmsg group for the thread
5. For templates: create new session from template
6. Add each target as group participant with transcript membership
7. Deliver the original message into the thread transcript
Update prompt template:
- Template identity awareness ("you were created from the X template")
- Natural chat room judgment model (named = strong signal, unnamed
but relevant = still respond, irrelevant = listen)
- Agent-to-agent: use @name for clarity
- Remove all peer fanout and @@handle syntax references
Add resolve_at_mentions(), resolve_mention_targets(), and
launch_thread_for_mentions() to common library.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add resolve_nl_agent_mentions() for natural language agent matching (no @ prefix required) - Fix _create_session_from_template to use async API (non-blocking) - Fix resolve_mention_targets: template match takes priority over session alias (always create new session for template agents) - Add scope discovery cache (60s TTL) to avoid per-call HTTP lookup - Add error logging to launch_thread_for_mentions for Discord API and GC API failures - Fix GC_API_BASE_URL handling to skip scope prefix when explicit - Debug logging for extmsg routing in gateway Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e43e387 to
7763a74
Compare
…saging Replace pack-local state management with extmsg API calls for Discord thread creation, agent session spawning, and message delivery. Key changes: - Gateway normalizes MESSAGE_CREATE to extmsg inbound messages - Thread detection via Discord API channel type lookup (cached) - Room @mentions create threads + extmsg groups + agent sessions - Thread @mentions add new participants with dedup - NL agent name matching for explicit_target in threads - reply-current rewritten to post directly via Discord API - Scope discovery cache skips caching failures (port 9443 fallback fix) - Sequential session creation to avoid prompt resolution races - normalize_to_extmsg_message with correct parent_id for threads Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7763a74 to
54c886e
Compare
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
Companion PR: gastownhall/gascity#116
Test plan
🤖 Generated with Claude Code