fix: surface human thread replies to MCP agents#6
Merged
alexgorbatchev merged 1 commit intomainfrom Mar 10, 2026
Merged
Conversation
The MCP server's `agentation_watch_annotations` tool only watched for `annotation.created` SSE events, ignoring `thread.message` events entirely. Additionally, `agentation_get_pending` filtered by status='pending', making human replies to acknowledged/resolved annotations invisible to the agent. Changes: - Add `thread.message` event handling to `watchForAnnotations` so agents are notified when a human replies to a thread (agent replies are correctly filtered out) - Add `getAnnotationsNeedingAttention` store method that returns both pending annotations AND non-pending annotations where the last thread message is from a human - Update `/pending` HTTP endpoints and SSE initial sync to use the new method - Add `ThreadMessage` and `thread` to the local Annotation type in mcp.ts for type safety - Add integration tests covering all scenarios: acknowledged annotations with human replies, resolved annotations with human replies, agent replies not resurfacing, and SSE watcher detecting thread.message events Co-Authored-By: Claude Opus 4.6 <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
agentation_watch_annotationsto detectthread.messageSSE events from humans, not justannotation.createdevents. Agent replies are correctly filtered out so they don't trigger false wakeups.getAnnotationsNeedingAttentionstore method that returns both pending annotations AND non-pending annotations where the last thread message is from a human (unread reply). Updated the/pendingHTTP endpoints and SSE initial sync to use this broader check.thread.messageevents.Problem
When a human replied to an annotation thread, the agent could not see it because:
annotation.createdevents, ignoringthread.messageentirelyget_pendingfiltered bystatus='pending', so once acknowledged, any human reply was invisibleTest plan
get_pendingwatch_annotationsdetectsthread.messageevents from humansget_sessionresponse🤖 Generated with Claude Code