mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
feat(session): inject Discord IDs block when discord tool is loaded
When DISCORD_BOT_TOKEN is set — meaning the discord tool actually loads — emit a dedicated IDs block in the session context prompt so the agent can call ``fetch_messages``, ``pin_message``, etc. with real identifiers instead of probing. Currently only ``thread_id`` was exposed as a raw ID (via the ``description`` string). The agent in a Discord thread had to guess that the thread ID doubles as a channel ID for the REST API (it does), and it had no way to reference the parent channel, the guild, or the triggering message at all. The block adapts to context: - Thread: guild / parent channel / thread / message - Channel: guild / channel / message - (DM has no guild/channel IDs worth listing; only message) Discord isn't in _PII_SAFE_PLATFORMS, so IDs ship unredacted.
This commit is contained in:
parent
0aa1269e56
commit
7efd91d4b4
1 changed files with 19 additions and 6 deletions
|
|
@ -285,13 +285,26 @@ def build_session_context_prompt(
|
||||||
"that you can only read messages sent directly to you and respond."
|
"that you can only read messages sent directly to you and respond."
|
||||||
)
|
)
|
||||||
elif context.source.platform == Platform.DISCORD:
|
elif context.source.platform == Platform.DISCORD:
|
||||||
# Only emit the "no Discord APIs" disclaimer when the discord tool
|
# The discord tool self-gates on DISCORD_BOT_TOKEN at registry
|
||||||
# can't load. The tool self-gates on DISCORD_BOT_TOKEN at registry
|
# check time. Match that condition so the prompt stays honest:
|
||||||
# check time, so matching that condition keeps the prompt honest:
|
|
||||||
# with a token the agent has fetch_messages/search_members/
|
# with a token the agent has fetch_messages/search_members/
|
||||||
# create_thread (and optionally discord_admin); without one it
|
# create_thread (and optionally discord_admin) and should know
|
||||||
# really is limited to reading/replying via the gateway.
|
# the IDs it can call them with; without one it really is
|
||||||
if not (os.environ.get("DISCORD_BOT_TOKEN") or "").strip():
|
# limited to reading/replying via the gateway.
|
||||||
|
if (os.environ.get("DISCORD_BOT_TOKEN") or "").strip():
|
||||||
|
src = context.source
|
||||||
|
id_lines = ["", "**Discord IDs (for the `discord` / `discord_admin` tools):**"]
|
||||||
|
if src.guild_id:
|
||||||
|
id_lines.append(f" - Guild: `{src.guild_id}`")
|
||||||
|
if src.thread_id and src.parent_chat_id:
|
||||||
|
id_lines.append(f" - Parent channel: `{src.parent_chat_id}`")
|
||||||
|
id_lines.append(f" - Thread: `{src.thread_id}` (use as `channel_id` for fetch_messages etc.)")
|
||||||
|
else:
|
||||||
|
id_lines.append(f" - Channel: `{src.chat_id}`")
|
||||||
|
if src.message_id:
|
||||||
|
id_lines.append(f" - Triggering message: `{src.message_id}`")
|
||||||
|
lines.extend(id_lines)
|
||||||
|
else:
|
||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append(
|
lines.append(
|
||||||
"**Platform notes:** You are running inside Discord. "
|
"**Platform notes:** You are running inside Discord. "
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue