feat(gateway): include Discord channel topic in session context
Fixes #163 - Add chat_topic field to SessionSource dataclass - Update to_dict/from_dict for serialization support - Add chat_topic parameter to build_source helper - Extract channel.topic in Discord adapter for messages and slash commands - Display Channel Topic in system prompt when available - Normalize empty topics to None
This commit is contained in:
parent
4d6f380bd1
commit
54147474d3
3 changed files with 21 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue