Skip to content

Add channel context for new conversations #5

@alexknowshtml

Description

@alexknowshtml

Summary

When a new thread is created from an @mention, fetch the last 10 messages from the channel to give Claude context about what was being discussed.

How Andy Does It

In bot.ts lines 410-415:

const CONTEXT_MESSAGE_COUNT = 10;

const recentMessages = await message.channel.messages.fetch({ limit: CONTEXT_MESSAGE_COUNT });
const recentContext = recentMessages
    .filter(m => m.id !== message.id && m.id !== statusMessage.id)
    .map(m => `${m.author.username}: ${m.content}`)
    .reverse();

This is sent to Andy Core as recentContext in the payload.

Why This Matters

  • User @mentions bot in the middle of a conversation
  • Without context, Claude only sees the @mention
  • With context, Claude knows what people were discussing

Not Redundant With --resume

  • recentContext = channel history BEFORE the thread ("what was being discussed?")
  • --resume = thread history INSIDE the session ("continue our conversation")

Implementation for Cord

  1. Add CONTEXT_MESSAGE_COUNT = 10 constant
  2. In new mention handler, fetch recent messages
  3. Format as username: content array
  4. Pass to Claude as part of the prompt or prepended context

Priority

Medium - improves conversation quality for new threads

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions