Merge PR #248: feat(gateway): include Discord channel topic in session context

Authored by Bartok9. Fixes #163.

Surfaces Discord channel topics in the agent's session context prompt,
allowing the agent to adapt its behavior based on the channel's purpose.
This commit is contained in:
teknium1 2026-03-02 00:51:20 -08:00
commit 3a840a130c
3 changed files with 21 additions and 1 deletions

View file

@ -44,6 +44,7 @@ class SessionSource:
user_id: Optional[str] = None
user_name: Optional[str] = None
thread_id: Optional[str] = None # For forum topics, Discord threads, etc.
chat_topic: Optional[str] = None # Channel topic/description (Discord, Slack)
@property
def description(self) -> str:
@ -75,6 +76,7 @@ class SessionSource:
"user_id": self.user_id,
"user_name": self.user_name,
"thread_id": self.thread_id,
"chat_topic": self.chat_topic,
}
@classmethod
@ -87,6 +89,7 @@ class SessionSource:
user_id=data.get("user_id"),
user_name=data.get("user_name"),
thread_id=data.get("thread_id"),
chat_topic=data.get("chat_topic"),
)
@classmethod
@ -154,6 +157,10 @@ def build_session_context_prompt(context: SessionContext) -> str:
lines.append(f"**Source:** {platform_name} (the machine running this agent)")
else:
lines.append(f"**Source:** {platform_name} ({context.source.description})")
# Channel topic (if available - provides context about the channel's purpose)
if context.source.chat_topic:
lines.append(f"**Channel Topic:** {context.source.chat_topic}")
# User identity (especially useful for WhatsApp where multiple people DM)
if context.source.user_name: