hermes - 💡(How to fix) Fix feat: let adapters provide platform-specific context notes for the system prompt [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#13309Fetched 2026-04-22 08:06:59
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Code Example

# Replace lines 265-283 with:
if context.source.platform_notes:
    lines.append("")
    lines.append(f"**Platform notes:** {context.source.platform_notes}")

---

# 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."
    ),
)
RAW_BUFFERClick to expand / collapse

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

  1. Add a platform_notes: Optional[str] = None field to SessionSource (dataclass in gateway/session.py)

  2. 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}")
  1. 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

FileChange
gateway/session.pySessionSourceAdd platform_notes: Optional[str] = None field + serialize/deserialize
gateway/session.pybuild_session_context_prompt()Replace hardcoded Slack/Discord block with generic platform_notes check
gateway/platforms/slack.pySet platform_notes=... on SessionSource construction
gateway/platforms/discord.pySet platform_notes=... on SessionSource construction
Other adapters (optional)Can now add their own platform notes

extent analysis

TL;DR

Add a platform_notes field to the SessionSource dataclass and replace the hardcoded if/elif block in build_session_context_prompt() to allow adapters to customize platform context.

Guidance

  • Identify the SessionSource dataclass in gateway/session.py and add a platform_notes: Optional[str] = None field to it.
  • Replace the hardcoded if/elif block in build_session_context_prompt() with a generic check for context.source.platform_notes.
  • Update each adapter (e.g., Slack, Discord) to set the platform_notes field when constructing SessionSource.
  • Consider adding platform notes for other adapters (e.g., Feishu, Mattermost, DingTalk) to provide customized context.

Example

# In gateway/session.py
@dataclass
class SessionSource:
    # ...
    platform_notes: Optional[str] = None

# In gateway/session.py
def build_session_context_prompt(context):
    # ...
    if context.source.platform_notes:
        lines.append("")
        lines.append(f"**Platform notes:** {context.source.platform_notes}")

# 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."
    ),
)

Notes

This solution assumes that the SessionSource dataclass and build_session_context_prompt() function are correctly implemented and that the adapters are properly constructed. Additionally, this solution may require serialization and deserialization of the platform_notes field.

Recommendation

Apply the proposed solution to add a platform_notes field to the SessionSource dataclass and replace the hardcoded if/elif block, as it allows adapters to customize platform context and scales better for new platforms.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING