diff --git a/gateway/config.py b/gateway/config.py index 33ca7fecd5..5e292d0c56 100644 --- a/gateway/config.py +++ b/gateway/config.py @@ -891,6 +891,15 @@ def _validate_gateway_config(config: "GatewayConfig") -> None: if not pconfig.enabled: continue env_name = _token_env_names.get(platform) + if not env_name: + # Check plugin registry for required_env + try: + from gateway.platform_registry import platform_registry + entry = platform_registry.get(platform.value) + if entry and entry.required_env: + env_name = entry.required_env[0] # primary env var + except Exception: + pass if env_name and pconfig.token is not None and not pconfig.token.strip(): logger.warning( "%s is enabled but %s is empty. " diff --git a/gateway/session.py b/gateway/session.py index 6f35b95865..3e8bebd9b2 100644 --- a/gateway/session.py +++ b/gateway/session.py @@ -234,7 +234,7 @@ def build_session_context_prompt( ) -> str: """ Build the dynamic system prompt section that tells the agent about its context. - + This is injected into the system prompt so the agent knows: - Where messages are coming from - What platforms are connected @@ -246,13 +246,23 @@ def build_session_context_prompt( Platforms like Discord are excluded because mentions need real IDs. Routing still uses the original values (they stay in SessionSource). """ - # Only apply redaction on platforms where IDs aren't needed for mentions - redact_pii = redact_pii and context.source.platform in _PII_SAFE_PLATFORMS + # Only apply redaction on platforms where IDs aren't needed for mentions. + # Check both the hardcoded set (builtins) and the plugin registry. + _is_pii_safe = context.source.platform in _PII_SAFE_PLATFORMS + if not _is_pii_safe: + try: + from gateway.platform_registry import platform_registry + entry = platform_registry.get(context.source.platform.value) + if entry and entry.pii_safe: + _is_pii_safe = True + except Exception: + pass + redact_pii = redact_pii and _is_pii_safe lines = [ "## Current Session Context", "", ] - + # Source info platform_name = context.source.platform.value.title() if context.source.platform == Platform.LOCAL: @@ -277,7 +287,7 @@ def build_session_context_prompt( else: desc = src.description lines.append(f"**Source:** {platform_name} ({desc})") - + # 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}") @@ -302,7 +312,7 @@ def build_session_context_prompt( if redact_pii: uid = _hash_sender_id(uid) lines.append(f"**User ID:** {uid}") - + # Platform-specific behavioral notes if context.source.platform == Platform.SLACK: lines.append("") @@ -368,9 +378,9 @@ def build_session_context_prompt( for p in context.connected_platforms: if p != Platform.LOCAL: platforms_list.append(f"{p.value}: Connected ✓") - + lines.append(f"**Connected Platforms:** {', '.join(platforms_list)}") - + # Home channels if context.home_channels: lines.append("") @@ -378,11 +388,11 @@ def build_session_context_prompt( for platform, home in context.home_channels.items(): hc_id = _hash_chat_id(home.chat_id) if redact_pii else home.chat_id lines.append(f" - {platform.value}: {home.name} (ID: {hc_id})") - + # Delivery options for scheduled tasks lines.append("") lines.append("**Delivery options for scheduled tasks:**") - + from hermes_constants import display_hermes_home # Origin delivery @@ -398,15 +408,15 @@ def build_session_context_prompt( lines.append( f"- `\"local\"` → Save to local files only ({display_hermes_home()}/cron/output/)" ) - + # Platform home channels for platform, home in context.home_channels.items(): lines.append(f"- `\"{platform.value}\"` → Home channel ({home.name})") - + # Note about explicit targeting lines.append("") lines.append("*For explicit targeting, use `\"platform:chat_id\"` format if the user provides a specific chat ID.*") - + return "\n".join(lines)