From 0aa1269e568993c4b5b06787b8a693b9626dfa64 Mon Sep 17 00:00:00 2001 From: alt-glitch Date: Sat, 25 Apr 2026 00:10:32 +0530 Subject: [PATCH] fix(session): gate stale "no Discord APIs" note on DISCORD_BOT_TOKEN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Discord platform note in the session context prompt claimed the agent has no server-management APIs — pre-dating the discord tool. With a bot token configured the agent actually has fetch_messages, search_members, create_thread, and optionally the discord_admin tool; telling the model otherwise causes it to refuse or apologise for calls it is fully able to make. Gate the disclaimer on DISCORD_BOT_TOKEN being unset, matching the tool's own ``check_fn``. Without a token the note still appears and remains accurate; with a token the model is no longer gaslit into refusing valid tool calls. --- gateway/session.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gateway/session.py b/gateway/session.py index 735378527..495c95d56 100644 --- a/gateway/session.py +++ b/gateway/session.py @@ -285,14 +285,21 @@ def build_session_context_prompt( "that you can only read messages sent directly to you and respond." ) elif context.source.platform == Platform.DISCORD: - lines.append("") - lines.append( - "**Platform notes:** You are running inside Discord. " - "You do NOT have access to Discord-specific APIs — you cannot search " - "channel history, pin messages, manage roles, or list server members. " - "Do not promise to perform these actions. If the user asks, explain " - "that you can only read messages sent directly to you and respond." - ) + # Only emit the "no Discord APIs" disclaimer when the discord tool + # can't load. The tool self-gates on DISCORD_BOT_TOKEN at registry + # check time, so matching that condition keeps the prompt honest: + # with a token the agent has fetch_messages/search_members/ + # create_thread (and optionally discord_admin); without one it + # really is limited to reading/replying via the gateway. + if not (os.environ.get("DISCORD_BOT_TOKEN") or "").strip(): + lines.append("") + lines.append( + "**Platform notes:** You are running inside Discord. " + "You do NOT have access to Discord-specific APIs — you cannot search " + "channel history, pin messages, manage roles, or list server members. " + "Do not promise to perform these actions. If the user asks, explain " + "that you can only read messages sent directly to you and respond." + ) # Connected platforms platforms_list = ["local (files on this machine)"]