Problem
Platform-specific behavioral notes (e.g. "you do NOT have access to Slack APIs") are currently hardcoded in gateway/session.py build_session_context_prompt() as an if/elif chain (lines 265-283). Only Slack and Discord have notes — all other platforms (Feishu, Mattermost, DingTalk, Matrix, WeCom, etc.) get nothing.
This approach does not scale: every new platform requires editing session.py, and third-party adapter authors cannot inject platform context without modifying core gateway code.
Proposed Solution
-
Add a platform_notes: Optional[str] = None field to SessionSource (dataclass in gateway/session.py)
-
Replace the hardcoded if/elif block in build_session_context_prompt() with a generic check:
# Replace lines 265-283 with:
if context.source.platform_notes:
lines.append("")
lines.append(f"**Platform notes:** {context.source.platform_notes}")
- Each adapter sets
platform_notes when constructing SessionSource:
# In gateway/platforms/slack.py
SessionSource(
platform=Platform.SLACK,
chat_id=...,
platform_notes=(
"You are running inside Slack. "
"You do NOT have access to Slack-specific APIs — you cannot search "
"channel history, pin/unpin messages, manage channels, or list users. "
"Do not promise to perform these actions."
),
)
This way adapters fully own their platform context — no core changes needed when adding a new platform.
Benefits
- Adapter authors can customize what the agent knows about their platform (capabilities, limitations, formatting rules, message length limits, etc.)
- Existing Slack/Discord notes are migrated to their respective adapters — zero behavior change
- New platforms (Feishu, Mattermost, DingTalk, etc.) can add context like:
- "Messages support Feishu rich text cards — use markdown for formatting"
- "Mattermost supports reactions and threads — prefer thread replies for long outputs"
- Minimal diff — one field addition, one block replacement, N adapter-side additions
Files to Change
| File |
Change |
gateway/session.py → SessionSource |
Add platform_notes: Optional[str] = None field + serialize/deserialize |
gateway/session.py → build_session_context_prompt() |
Replace hardcoded Slack/Discord block with generic platform_notes check |
gateway/platforms/slack.py |
Set platform_notes=... on SessionSource construction |
gateway/platforms/discord.py |
Set platform_notes=... on SessionSource construction |
| Other adapters (optional) |
Can now add their own platform notes |
Problem
Platform-specific behavioral notes (e.g. "you do NOT have access to Slack APIs") are currently hardcoded in
gateway/session.pybuild_session_context_prompt()as anif/elifchain (lines 265-283). Only Slack and Discord have notes — all other platforms (Feishu, Mattermost, DingTalk, Matrix, WeCom, etc.) get nothing.This approach does not scale: every new platform requires editing
session.py, and third-party adapter authors cannot inject platform context without modifying core gateway code.Proposed Solution
Add a
platform_notes: Optional[str] = Nonefield toSessionSource(dataclass ingateway/session.py)Replace the hardcoded
if/elifblock inbuild_session_context_prompt()with a generic check:platform_noteswhen constructingSessionSource:This way adapters fully own their platform context — no core changes needed when adding a new platform.
Benefits
Files to Change
gateway/session.py→SessionSourceplatform_notes: Optional[str] = Nonefield + serialize/deserializegateway/session.py→build_session_context_prompt()platform_notescheckgateway/platforms/slack.pyplatform_notes=...onSessionSourceconstructiongateway/platforms/discord.pyplatform_notes=...onSessionSourceconstruction