Improve task creation from thread context and add event deduplication#6
Open
Improve task creation from thread context and add event deduplication#6
Conversation
The bot failed to understand messages like "füge diesen task hinzu" (add this task) when users referenced thread context. Two changes: 1. Agent instructions: Added explicit guidance and example for thread-reference task creation — when a user says "add this task" in a thread, the agent now knows to extract the task content from the thread context and incorporate any corrections from the user's message. 2. Fallback messages: Made language-aware so German users get a German fallback instead of the hardcoded English "I didn't quite understand that" message. https://claude.ai/code/session_01PoZNuRCfnFnfqK9cCAg6fD
Language detection should be handled by the LLM itself via the agent instructions, not by regex pattern matching. https://claude.ai/code/session_01PoZNuRCfnFnfqK9cCAg6fD
The thread context was buried inside a "Context (use these values when calling tools)" block, mixed with JSON metadata like source and projectsMapping. The LLM treated it as tool parameter data and missed the actual conversation content. Now uses clear markdown sections: "Tool parameters", "Thread context", and "User message" so the LLM can distinguish between metadata and conversation. https://claude.ai/code/session_01PoZNuRCfnFnfqK9cCAg6fD
- handleThreadReply: Add event deduplication (was missing, could cause duplicate agent calls and double usage counting) - handleThreadReply: Continue agent conversation even when status is not "active" — previously a non-active conversation caused the bot to silently drop the message, losing all thread context - handleAssistantMessage: Add event deduplication (same issue) https://claude.ai/code/session_01PoZNuRCfnFnfqK9cCAg6fD
…stence 1. Dual-fire: Revert delay hack — the existing event deduplication (markEventProcessed) is atomic and sufficient to prevent both handleAppMention and handleThreadReply from processing the same message. 2. Thread context: Remove .slice(-15) and 2000-char truncation from formatThreadForContext. The Slack API already limits to 50 messages — that's enough of a natural limit. Better to give the agent full context than risk losing the parent message (original problem statement). 3. Conversation persistence: Save conversation BEFORE the agent call instead of after. If the agent crashes, the conversation record still exists so follow-up messages are properly routed to the agent. https://claude.ai/code/session_01PoZNuRCfnFnfqK9cCAg6fD
Users can now say "@norbot stop" (or "stopp", "halt") to make the bot stop following a thread. The conversation status is set to "stopped" and handleThreadReply skips stopped conversations. To resume, simply @mention the bot again with a new message — handleAppMention creates a fresh agent thread and sets the conversation back to "active". https://claude.ai/code/session_01PoZNuRCfnFnfqK9cCAg6fD
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
This PR enhances the task extraction agent's ability to create tasks from thread context and adds event deduplication to prevent duplicate processing of Slack messages.
Key Changes
Task Creation from Thread Context
taskExtractor.ts: Added detailed guidance for "thread-reference task creation" where users reference previous messages (e.g., "add this task", "create a task for this"). The agent now correctly extracts task content from thread history rather than the user's current message.Event Deduplication
handleThreadReplyandhandleAssistantMessage: Both handlers now check if an event has already been processed before handling it, preventing duplicate task creation and responses.isEventProcessedandmarkEventProcessedqueries/mutations to track processed Slack events by timestamp.Context Formatting Improvements
## Tool parameters,## User message,## Thread context) for better agent comprehension.Conversation Flow Enhancements
handleThreadReplyto reuse active agent threads but create new ones if the conversation is inactive, improving continuity.getFallbackMessage()function for consistency across handlers.Implementation Details
eventTs) as the unique identifierhttps://claude.ai/code/session_01PoZNuRCfnFnfqK9cCAg6fD