mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-01 01:51:44 +00:00
fix(cron): accept list-form deliver values so deliver=['telegram'] works (#17456)
The cron schema contracts deliver as a string ("local", "origin",
"telegram", "telegram:chat_id[:thread_id]", or comma-separated combos),
but MCP clients and scripts sometimes pass an array like ['telegram'].
Before this change, the list was written to jobs.json verbatim, and
the scheduler's str(deliver).split(',') then tried to resolve the
literal string "['telegram']" as a platform — returning None and
logging 'no delivery target resolved for deliver=[\'telegram\']'.
Fix on both ends:
- tools/cronjob_tools.py: normalize deliver at the API boundary on
create and update, so storage is always a string.
- cron/scheduler.py: normalize deliver in _resolve_delivery_targets,
so existing jobs.json entries with list-form deliver are handled
gracefully without requiring users to edit the file.
Closes #17139
This commit is contained in:
parent
7141cda967
commit
398945e7b1
4 changed files with 140 additions and 4 deletions
|
|
@ -231,3 +231,60 @@ class TestUnifiedCronjobTool:
|
|||
assert updated["success"] is True
|
||||
assert updated["job"]["skills"] == []
|
||||
assert updated["job"]["skill"] is None
|
||||
|
||||
def test_create_normalizes_list_form_deliver(self):
|
||||
"""deliver=['telegram'] (list) is stored as the string 'telegram'.
|
||||
|
||||
Regression for #17139: MCP clients / scripts sometimes pass ``deliver``
|
||||
as an array. Prior to the fix, ``['telegram']`` was written verbatim
|
||||
to ``jobs.json`` and the scheduler then tried to resolve the literal
|
||||
string ``"['telegram']"`` as a platform, failing with
|
||||
"no delivery target resolved".
|
||||
"""
|
||||
from cron.jobs import get_job
|
||||
|
||||
created = json.loads(
|
||||
cronjob(
|
||||
action="create",
|
||||
prompt="Daily briefing",
|
||||
schedule="every 1h",
|
||||
deliver=["telegram"],
|
||||
)
|
||||
)
|
||||
assert created["success"] is True
|
||||
stored = get_job(created["job_id"])
|
||||
assert stored["deliver"] == "telegram"
|
||||
|
||||
def test_create_normalizes_multi_element_list_deliver(self):
|
||||
"""deliver=['telegram', 'discord'] is stored as 'telegram,discord'."""
|
||||
from cron.jobs import get_job
|
||||
|
||||
created = json.loads(
|
||||
cronjob(
|
||||
action="create",
|
||||
prompt="Daily briefing",
|
||||
schedule="every 1h",
|
||||
deliver=["telegram", "discord"],
|
||||
)
|
||||
)
|
||||
assert created["success"] is True
|
||||
stored = get_job(created["job_id"])
|
||||
assert stored["deliver"] == "telegram,discord"
|
||||
|
||||
def test_update_normalizes_list_form_deliver(self):
|
||||
"""update with deliver=['telegram'] stores the canonical string."""
|
||||
from cron.jobs import get_job
|
||||
|
||||
created = json.loads(
|
||||
cronjob(action="create", prompt="x", schedule="every 1h")
|
||||
)
|
||||
updated = json.loads(
|
||||
cronjob(
|
||||
action="update",
|
||||
job_id=created["job_id"],
|
||||
deliver=["telegram"],
|
||||
)
|
||||
)
|
||||
assert updated["success"] is True
|
||||
stored = get_job(created["job_id"])
|
||||
assert stored["deliver"] == "telegram"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue