Skip to content

Conversation

@wiesson
Copy link
Owner

@wiesson wiesson commented Feb 10, 2026

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

  • Enhanced instructions in 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.
  • Added example: Included a concrete example showing how to handle corrections/additional details from the user while creating the task immediately without asking for clarification.

Event Deduplication

  • Added deduplication checks in handleThreadReply and handleAssistantMessage: Both handlers now check if an event has already been processed before handling it, preventing duplicate task creation and responses.
  • New internal functions: isEventProcessed and markEventProcessed queries/mutations to track processed Slack events by timestamp.

Context Formatting Improvements

  • Restructured context format: Changed from inline "Context (use these values...)" to clearer markdown sections (## Tool parameters, ## User message, ## Thread context) for better agent comprehension.
  • Improved thread context header: Updated to explicitly guide the agent to use thread context for understanding user references.

Conversation Flow Enhancements

  • Thread reuse logic: Modified handleThreadReply to reuse active agent threads but create new ones if the conversation is inactive, improving continuity.
  • Unified fallback message: Extracted fallback response into getFallbackMessage() function for consistency across handlers.

Implementation Details

  • Event deduplication uses Slack event timestamps (eventTs) as the unique identifier
  • Thread context is now clearly separated from tool parameters in the agent prompt
  • The agent is explicitly instructed to create tasks immediately when thread references are detected, reducing unnecessary clarification requests

https://claude.ai/code/session_01PoZNuRCfnFnfqK9cCAg6fD

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
@vercel
Copy link

vercel bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
norbot Error Error Feb 10, 2026 0:28am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants