The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(prompt): remove the ~1.2K-token Nous Subscription block from the system prompt (#95005)
Teknium4032a15ad0d5
diff --git a/agent/prompt_builder.py b/agent/prompt_builder.pyindex af274f5e0f9..91bff527298 100644--- a/agent/prompt_builder.py+++ b/agent/prompt_builder.py@@ -2279,72 +2279,6 @@ def _build_skills_system_prompt_inner(return result-def build_nous_subscription_prompt(valid_tool_names: "set[str] | None" = None) -> str:- """Build a compact Nous subscription capability block for the system prompt."""- try:- from hermes_cli.nous_subscription import get_nous_subscription_features- from tools.tool_backend_helpers import managed_nous_tools_enabled- except Exception as exc:- logger.debug("Failed to import Nous subscription helper: %s", exc)- return ""-- if not managed_nous_tools_enabled():- return ""-- valid_names = set(valid_tool_names or set())- relevant_tool_names = {- "web_search",- "web_extract",- "browser_navigate",- "browser_snapshot",- "browser_click",- "browser_type",- "browser_scroll",- "browser_console",- "browser_press",- "browser_get_images",- "browser_vision",- "image_generate",- "text_to_speech",- "terminal",- "process",- "execute_code",- }-- if valid_names and not (valid_names & relevant_tool_names):- return ""-- features = get_nous_subscription_features()-- def _status_line(feature) -> str:- if feature.managed_by_nous:- return f"- {feature.label}: active via Nous subscription"- if feature.active:- current = feature.current_provider or "configured provider"- return f"- {feature.label}: currently using {current}"- if feature.included_by_default and features.nous_auth_present:- return f"- {feature.label}: included with Nous subscription, not currently selected"- if feature.key == "modal" and features.nous_auth_present:- return f"- {feature.label}: optional via Nous subscription"- return f"- {feature.label}: not currently available"-- lines = [- "# Nous Subscription",- "Nous subscription includes managed web tools (Firecrawl), image generation (FAL), OpenAI TTS, OpenAI Whisper STT, and browser automation (Browser Use) by default. Modal execution is optional.",- "Current capability status:",- ]- lines.extend(_status_line(feature) for feature in features.items())- lines.extend(- [- "When a Nous-managed feature is active, do not ask the user for Firecrawl, FAL, OpenAI TTS, OpenAI Whisper, or Browser-Use API keys.",- "If the user is not subscribed and asks for a capability that Nous subscription would unlock or simplify, suggest Nous subscription as one option alongside direct setup or local alternatives.",- "Do not mention subscription unless the user asks about it or it directly solves the current missing capability.",- "Useful commands: hermes setup, hermes setup tools, hermes setup terminal, hermes status.",- ]- )- return "\n".join(lines)--# =========================================================================# Context files (SOUL.md, AGENTS.md, .cursorrules)# =========================================================================diff --git a/agent/system_prompt.py b/agent/system_prompt.pyindex 90d6003672b..0a5d40c2e78 100644--- a/agent/system_prompt.py+++ b/agent/system_prompt.py@@ -69,7 +69,7 @@ def _ra():"""Lazy reference to the ``run_agent`` module.Helpers like ``load_soul_md``, ``build_environment_hints``,- ``build_context_files_prompt``, ``build_nous_subscription_prompt``,+ ``build_context_files_prompt``,``build_skills_system_prompt`` and ``get_toolset_for_tool`` areimported into ``run_agent``'s namespace. Many tests``patch("run_agent.load_soul_md", ...)``; if we imported them@@ -469,9 +469,6 @@ def build_system_prompt_parts(agent: Any, system_message: Optional[str] = None)from agent.prompt_builder import computer_use_guidancestable_parts.append(computer_use_guidance())- nous_subscription_prompt = _r.build_nous_subscription_prompt(agent.valid_tool_names)- if nous_subscription_prompt:- stable_parts.append(nous_subscription_prompt)# Tool-use enforcement: tells the model to actually call tools instead# of describing intended actions. Controlled by config.yaml# agent.tool_use_enforcement:diff --git a/run_agent.py b/run_agent.pyindex 90e273f7484..c6638b6cacd 100644--- a/run_agent.py+++ b/run_agent.py@@ -170,7 +170,6 @@ from agent.prompt_builder import ( # noqa: F401 # re-exported via _ra() / mockbuild_skills_system_prompt,build_context_files_prompt,build_environment_hints,- build_nous_subscription_prompt,load_soul_md,)from agent.process_bootstrap import _get_proxy_from_env # noqa: F401diff --git a/tests/agent/test_platform_hint_desktop.py b/tests/agent/test_platform_hint_desktop.pyindex 9f39936c7cf..4d004b11f7c 100644--- a/tests/agent/test_platform_hint_desktop.py+++ b/tests/agent/test_platform_hint_desktop.py@@ -27,7 +27,6 @@ from agent.system_prompt import (def _stable_prompt(agent):with (patch("run_agent.load_soul_md", return_value=""),- patch("run_agent.build_nous_subscription_prompt", return_value=""),patch("run_agent.build_environment_hints", return_value=""),patch("run_agent.build_context_files_prompt", return_value=""),):diff --git a/tests/agent/test_profile_home_override_precedence.py b/tests/agent/test_profile_home_override_precedence.pyindex 2fff959689d..40da1fd804c 100644--- a/tests/agent/test_profile_home_override_precedence.py+++ b/tests/agent/test_profile_home_override_precedence.py@@ -133,7 +133,6 @@ def test_full_prompt_scoped_to_bot_on_bare_thread(tmp_path, monkeypatch):def build():with (- patch("run_agent.build_nous_subscription_prompt", return_value=""),patch("run_agent.build_environment_hints", return_value=""),):result["prompt"] = build_system_prompt(agent)diff --git a/tests/agent/test_prompt_builder.py b/tests/agent/test_prompt_builder.pyindex fe28afa2f6a..48d64626360 100644--- a/tests/agent/test_prompt_builder.py+++ b/tests/agent/test_prompt_builder.py@@ -17,7 +17,6 @@ from agent.prompt_builder import (_find_git_root,_strip_yaml_frontmatter,build_skills_system_prompt,- build_nous_subscription_prompt,build_context_files_prompt,CONTEXT_FILE_MAX_CHARS,_dynamic_context_file_max_chars,@@ -35,7 +34,6 @@ from agent.prompt_builder import (PLATFORM_HINTS,WSL_ENVIRONMENT_HINT,)-from hermes_cli.nous_subscription import NousFeatureState, NousSubscriptionFeatures@pytest.fixture(autouse=True)@@ -382,69 +380,6 @@ class TestBuildSkillsSystemPrompt:assert "cached-skill" not in second----class TestBuildNousSubscriptionPrompt:- def test_includes_active_subscription_features(self, monkeypatch):- monkeypatch.setattr("tools.tool_backend_helpers.managed_nous_tools_enabled", lambda: True)- monkeypatch.setattr(- "hermes_cli.nous_subscription.get_nous_subscription_features",- lambda config=None: NousSubscriptionFeatures(- subscribed=True,- nous_auth_present=True,- provider_is_nous=True,- features={- "web": NousFeatureState("web", "Web tools", True, True, True, True, False, True, "firecrawl"),- "image_gen": NousFeatureState("image_gen", "Image generation", True, True, True, True, False, True, "Nous Subscription"),- "video_gen": NousFeatureState("video_gen", "Video generation", False, False, False, False, False, False, ""),- "tts": NousFeatureState("tts", "OpenAI TTS", True, True, True, True, False, True, "OpenAI TTS"),- "stt": NousFeatureState("stt", "Speech-to-text", True, True, True, True, False, True, "OpenAI Whisper"),- "browser": NousFeatureState("browser", "Browser automation", True, True, True, True, False, True, "Browser Use"),- "modal": NousFeatureState("modal", "Modal execution", False, True, False, False, False, True, "local"),- },- ),- )-- prompt = build_nous_subscription_prompt({"web_search", "browser_navigate"})-- assert "Browser Use" in prompt- assert "Modal execution is optional" in prompt- assert "do not ask the user for Firecrawl, FAL, OpenAI TTS, OpenAI Whisper, or Browser-Use API keys" in prompt-- def test_non_subscriber_prompt_includes_relevant_upgrade_guidance(self, monkeypatch):- monkeypatch.setattr("tools.tool_backend_helpers.managed_nous_tools_enabled", lambda: True)- monkeypatch.setattr(- "hermes_cli.nous_subscription.get_nous_subscription_features",- lambda config=None: NousSubscriptionFeatures(- subscribed=False,- nous_auth_present=False,- provider_is_nous=False,- features={- "web": NousFeatureState("web", "Web tools", True, False, False, False, False, True, ""),- "image_gen": NousFeatureState("image_gen", "Image generation", True, False, False, False, False, True, ""),- "video_gen": NousFeatureState("video_gen", "Video generation", False, False, False, False, False, False, ""),- "tts": NousFeatureState("tts", "OpenAI TTS", True, False, False, False, False, True, ""),- "stt": NousFeatureState("stt", "Speech-to-text", True, False, False, False, False, True, ""),- "browser": NousFeatureState("browser", "Browser automation", True, False, False, False, False, True, ""),- "modal": NousFeatureState("modal", "Modal execution", False, False, False, False, False, True, ""),- },- ),- )-- prompt = build_nous_subscription_prompt({"image_generate"})-- assert "suggest Nous subscription as one option" in prompt- assert "Do not mention subscription unless" in prompt-- def test_feature_flag_off_returns_empty_prompt(self, monkeypatch):- monkeypatch.setattr("tools.tool_backend_helpers.managed_nous_tools_enabled", lambda: False)-- prompt = build_nous_subscription_prompt({"web_search"})-- assert prompt == ""--# =========================================================================# Context files prompt builder# =========================================================================diff --git a/tests/agent/test_system_prompt.py b/tests/agent/test_system_prompt.pyindex 76a1c4749e6..43e7297bc33 100644--- a/tests/agent/test_system_prompt.py+++ b/tests/agent/test_system_prompt.py@@ -47,7 +47,6 @@ def _captured_context_cwd(agent):with (patch("run_agent.load_soul_md", return_value=""),- patch("run_agent.build_nous_subscription_prompt", return_value=""),patch("run_agent.build_environment_hints", return_value=""),patch("run_agent.build_context_files_prompt", side_effect=fake_context_files),):@@ -70,7 +69,6 @@ class TestContextFileCwd:def _stable_prompt(agent):with (patch("run_agent.load_soul_md", return_value=""),- patch("run_agent.build_nous_subscription_prompt", return_value=""),patch("run_agent.build_environment_hints", return_value=""),patch("run_agent.build_context_files_prompt", return_value=""),):@@ -80,7 +78,6 @@ def _stable_prompt(agent):def _prompt_parts(agent):with (patch("run_agent.load_soul_md", return_value=""),- patch("run_agent.build_nous_subscription_prompt", return_value=""),patch("run_agent.build_environment_hints", return_value=""),patch("run_agent.build_context_files_prompt", return_value=""),):@@ -270,7 +267,6 @@ def test_build_system_prompt_records_stable_prefix():agent = _make_agent()with (patch("run_agent.load_soul_md", return_value=""),- patch("run_agent.build_nous_subscription_prompt", return_value=""),patch("run_agent.build_environment_hints", return_value=""),patch("run_agent.build_context_files_prompt", return_value="context"),):@@ -316,7 +312,6 @@ def test_coding_prompt_preserves_legacy_workspace_order(monkeypatch):with (patch("run_agent.load_soul_md", return_value=""),- patch("run_agent.build_nous_subscription_prompt", return_value=""),patch("run_agent.build_environment_hints", return_value=""),patch("run_agent.build_context_files_prompt", return_value="CONTEXT_FILES"),patch(@@ -461,7 +456,6 @@ def _build(builder, **overrides):agent = _make_agent(valid_tool_names=["skills_list"], **overrides)with (patch("run_agent.load_soul_md", return_value=""),- patch("run_agent.build_nous_subscription_prompt", return_value=""),patch("run_agent.build_environment_hints", return_value=""),patch("run_agent.build_context_files_prompt", return_value=_CONTEXT),patch("run_agent.get_toolset_for_tool", return_value=None),diff --git a/tests/run_agent/test_run_agent.py b/tests/run_agent/test_run_agent.pyindex 236d3994c08..1e7b7d0f5ab 100644--- a/tests/run_agent/test_run_agent.py+++ b/tests/run_agent/test_run_agent.py@@ -1039,11 +1039,6 @@ class TestBuildSystemPrompt:if ln.startswith("Conversation started:"))assert _line(agent._build_system_prompt()) == _line(agent._build_system_prompt())- def test_includes_nous_subscription_prompt(self, agent, monkeypatch):- monkeypatch.setattr(run_agent, "build_nous_subscription_prompt", lambda tool_names: "NOUS SUBSCRIPTION BLOCK")- prompt = agent._build_system_prompt()- assert "NOUS SUBSCRIPTION BLOCK" in prompt-def test_skills_prompt_derives_available_toolsets_from_loaded_tools(self):tools = _make_tool_defs("web_search", "skills_list", "skill_view", "skill_manage")toolset_map = {