The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: cron agents carry their delivery channel's platform hint
teknium13276af0957b5
diff --git a/agent/system_prompt.py b/agent/system_prompt.pyindex 414928a58c3..73e13d57465 100644--- a/agent/system_prompt.py+++ b/agent/system_prompt.py@@ -409,23 +409,49 @@ def _active_profile_line(agent: Any) -> str:)-def platform_hint(agent: Any) -> str:- """Built-in/plugin platform hint + Telegram rich-messages opt-in + config- override + desktop TUI clarifier."""- platform_key = (agent.platform or "").lower().strip()- _default_hint = PLATFORM_HINTS.get(platform_key, "")- if not _default_hint and platform_key:+def _default_platform_hint(platform_key: str) -> str:+ """Built-in hint, else the plugin adapter's ``platform_hint``, else ``""``."""+ hint = PLATFORM_HINTS.get(platform_key, "")+ if not hint and platform_key:try:from gateway.platform_registry import platform_registry_entry = platform_registry.get(platform_key)- _default_hint = (_entry and _entry.platform_hint) or ""+ hint = (_entry and _entry.platform_hint) or ""except Exception:pass- if platform_key == "telegram" and _default_hint and _telegram_rich_messages_enabled():- _default_hint = _default_hint.rstrip() + " " + TELEGRAM_RICH_MESSAGES_HINT- _effective_hint = _resolve_platform_hint(agent, platform_key, _default_hint)+ if platform_key == "telegram" and hint and _telegram_rich_messages_enabled():+ hint = hint.rstrip() + " " + TELEGRAM_RICH_MESSAGES_HINT+ return hint+++def _cron_delivery_hint(agent: Any) -> str:+ """The destination channel's hint (default + its ``platform_hints`` override) for a cron agent.++ A cron agent runs as platform ``cron`` but its final response lands on the job's ``deliver``+ channel, so without this the model never learns that MEDIA: tags become Slack/Telegram+ attachments or that tables do not render there — and a user's ``platform_hints.slack.append``+ never reached scheduled jobs at all. The scheduler publishes the primary auto-deliver target+ into the session ContextVar before the agent runs (same seam ``send_message`` routes by).+ """+ from gateway.session_context import get_session_env+ deliver_key = get_session_env("HERMES_CRON_AUTO_DELIVER_PLATFORM", "").lower().strip()+ if not deliver_key or deliver_key == "cron":+ return ""+ hint = _resolve_platform_hint(agent, deliver_key, _default_platform_hint(deliver_key))+ return f"Delivery destination ({deliver_key}): {hint}" if hint else ""+++def platform_hint(agent: Any) -> str:+ """Built-in/plugin platform hint + Telegram rich-messages opt-in + config+ override + desktop TUI clarifier; cron agents also carry their delivery channel's hint."""+ platform_key = (agent.platform or "").lower().strip()+ _effective_hint = _resolve_platform_hint(agent, platform_key, _default_platform_hint(platform_key))if platform_key == "tui" and _effective_hint:_effective_hint = _tui_embedded_pane_clarifier(_effective_hint)+ if platform_key == "cron":+ _delivery = _cron_delivery_hint(agent)+ if _delivery:+ _effective_hint = f"{_effective_hint}\n\n{_delivery}".strip()return _effective_hintdiff --git a/tests/agent/test_platform_hint_cron_delivery.py b/tests/agent/test_platform_hint_cron_delivery.pynew file mode 100644index 00000000000..1acaed09a1f--- /dev/null+++ b/tests/agent/test_platform_hint_cron_delivery.py@@ -0,0 +1,45 @@+"""A cron agent's system prompt carries its delivery channel's hint.++Cron agents run as platform ``cron`` but the final response lands on the job's ``deliver``+channel. Without the destination hint the model never learns that MEDIA: tags become native+attachments there, and ``platform_hints.<channel>.append`` never reached scheduled jobs+(community report: Slack-delivered cron jobs stopped sending attachments).+"""++import types++import pytest++from agent.prompt_builder import PLATFORM_HINTS+from agent.system_prompt import platform_hint+from gateway.session_context import _VAR_MAP++EXTRA = "Always attach the report as a .pdf."+++def _agent(platform, overrides=None):+ return types.SimpleNamespace(platform=platform, _platform_hint_overrides=overrides or {})+++def deliver_to(monkeypatch):+ var = _VAR_MAP["HERMES_CRON_AUTO_DELIVER_PLATFORM"]+ token = var.set("slack")+ monkeypatch.delenv("HERMES_DESKTOP_TERMINAL", raising=False)+ yield+ var.reset(token)+++def test_cron_agent_gets_delivery_channel_hint_with_its_override(deliver_to):+ hint = platform_hint(_agent("cron", {"slack": {"append": EXTRA}}))+ assert hint.startswith(PLATFORM_HINTS["cron"])+ assert PLATFORM_HINTS["slack"] in hint+ assert EXTRA in hint+ # The cron hint's own override channel is untouched by the destination's.+ assert platform_hint(_agent("cron", {"cron": {"replace": "X"}})).startswith("X\n\n")+++def test_delivery_target_only_applies_to_cron_agents(deliver_to):+ assert platform_hint(_agent("telegram")) == PLATFORM_HINTS["telegram"]+ _VAR_MAP["HERMES_CRON_AUTO_DELIVER_PLATFORM"].set("")+ assert platform_hint(_agent("cron")) == PLATFORM_HINTS["cron"]diff --git a/website/docs/developer-guide/prompt-assembly.md b/website/docs/developer-guide/prompt-assembly.mdindex 2b0b0b27b7c..a7482ad24e6 100644--- a/website/docs/developer-guide/prompt-assembly.md+++ b/website/docs/developer-guide/prompt-assembly.md@@ -163,6 +163,14 @@ platform_hints:unmodified default, so a bad config value can never break promptassembly or leak across platforms.+Cron jobs run as platform `cron`, but their final response lands on the+job's `deliver` channel, so a cron agent's prompt also carries that+channel's hint (built-in text plus its `platform_hints.<channel>`+override) under a `Delivery destination (<channel>):` line. A+`platform_hints.slack.append` therefore reaches Slack-delivered scheduled+jobs as well as live Slack chats; `platform_hints.cron` still governs the+cron paragraph itself.+The override is resolved when the system prompt is built (session start,and again on compaction since that rebuilds the prompt). It produces abyte-stable hint for a fixed config, so it lives in the **stable** tier