feat: cross-studio self-messaging support (by Wren)#267
Merged
conoremclaughlin merged 5 commits intomainfrom Mar 26, 2026
Merged
feat: cross-studio self-messaging support (by Wren)#267conoremclaughlin merged 5 commits intomainfrom
conoremclaughlin merged 5 commits intomainfrom
Conversation
Allow an agent to message themselves in a different studio (e.g., wren-omega sends a review request to wren-review). Changes: - resolveTriggeredAgents: add selfStudioTarget flag that keeps sender in trigger lists instead of excluding them - handleSendToInbox: detect cross-studio self-message when sender is in recipients AND recipientStudioId/recipientStudioHint is set - Skip auto-resolve from thread history for self-messages (would find sender's own session); pass studioId/studioHint through trigger payload - Channel plugin: self-filter now checks studioId, not just agentId — accepts messages from self when they came from a different studio - thread-handlers.test.ts: import resolveTriggeredAgents directly instead of duplicating the function; add 5 selfStudioTarget tests - 65 tests pass across 3 test files Co-Authored-By: Wren <noreply@anthropic.com>
Lumen's review: channelPoll filter rejected cross-studio self-threads because isThreadOwnedByStudio only checked sender.studioId. The target studio's channel plugin never saw the thread. Fix: - Stamp metadata.pcp.recipient.studioId on thread messages for cross- studio self-messages (when sender is in recipients + recipientStudioId set) - isThreadOwnedByStudio now also checks recipient.studioId — accepts threads where this studio is an explicit recipient - 2 regression tests: accept via recipient match, reject third-party Co-Authored-By: Wren <noreply@anthropic.com>
Lumen's review: the hint-only path (recipientStudioHint without recipientStudioId) left metadata.pcp.recipient.studioId empty, so the channelPoll filter couldn't match. Now resolves hints to studioIds via DB lookup (slug match or 'main' fallback) before stamping thread message metadata and trigger payload. Both explicit recipientStudioId and recipientStudioHint paths are now covered end-to-end. Co-Authored-By: Wren <noreply@anthropic.com>
Lumen's review: the hint-only path (recipientStudioHint without recipientStudioId) left metadata.pcp.recipient.studioId empty, so the channelPoll filter couldn't match. Now resolves 'main' hint using branch='main' match (same semantics as SessionService.resolveMainStudioId) instead of naive 'most recently updated studio'. Named hints resolve by slug match. Co-Authored-By: Wren <noreply@anthropic.com>
Lumen's review: the 'main' hint resolution was naive (branch match only) instead of matching SessionService.resolveMainStudioId semantics (worktree path → branch fallback). Extract resolveStudioHint() as a standalone exported function in session-service.ts — handles both 'main' (worktree path then branch) and named hints (slug match). Inbox handler now uses this shared function instead of inline resolution. Co-Authored-By: Wren <noreply@anthropic.com>
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
resolveTriggeredAgentsgainsselfStudioTargetflag — keeps sender in trigger lists when targeting a different studiohandleSendToInboxdetects cross-studio self-messages when sender is in recipients ANDrecipientStudioId/recipientStudioHintis setstudioId/studioHintfor routing; skips thread history auto-resolve for self (would find own session)resolveTriggeredAgentsin test file with direct importTest plan
🤖 Generated with Claude Code