JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(tui): 优化定时任务结果推送显示
kdgmpw2e43c8cd8178
diff --git a/docs/en/ScheduledTasks.md b/docs/en/ScheduledTasks.mdindex 7305ee582d..5d8d9f57b3 100644--- a/docs/en/ScheduledTasks.md+++ b/docs/en/ScheduledTasks.md@@ -127,8 +127,8 @@ All `targets` channels (`web`, `tui`, Feishu, DingTalk, WeCom, etc.) share the s| Scenario | Push body format ||---|---|-| **Successful completion** | `{job name} result:\n\n{agent output}` (no `[cron]` prefix) |-| **Failure / timeout / no valid report** | Status text starting with `[cron]` (e.g. `[cron] 任务执行失败: …`), not wrapped as `{job name} result:` |+| **Successful completion** | `{agent output}` (no job-name prefix, no `[cron]` prefix) |+| **Failure / timeout / no valid report** | Status text starting with `[cron]` (e.g. `[cron] 任务执行失败: …`), not wrapped with a job-name prefix || **In-progress placeholder** | `{job name} 正在执行中,结果稍后补发(push_at=…)` |Channel differences are mainly **routing**, not body format:diff --git "a/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md" "b/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"index 22bd3e2f6d..c70a22d374 100644--- "a/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"+++ "b/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"@@ -128,8 +128,8 @@ TUI / Web 创建任务时可传 `mode=`;前端通过 `cron.job.meta` 拉取当| 场景 | 推送正文格式 ||---|---|-| **正常完成** | `{任务名} result:\n\n{Agent 返回正文}`(无 `[cron]` 前缀) |-| **执行失败 / 超时 / 无有效报告等** | 以 `[cron]` 开头的状态文案(如 `[cron] 任务执行失败: …`),不再套 `{任务名} result:` 包装 |+| **正常完成** | `{Agent 返回正文}`(不拼接任务名前缀,也无 `[cron]` 前缀) |+| **执行失败 / 超时 / 无有效报告等** | 以 `[cron]` 开头的状态文案(如 `[cron] 任务执行失败: …`),不拼接任务名前缀 || **执行中占位** | `{任务名} 正在执行中,结果稍后补发(push_at=…)` |各频道差异主要在 **路由**,不在正文格式:diff --git a/jiuwenswarm/gateway/cron/scheduler.py b/jiuwenswarm/gateway/cron/scheduler.pyindex c5bd1d5c9b..fd126ddff1 100644--- a/jiuwenswarm/gateway/cron/scheduler.py+++ b/jiuwenswarm/gateway/cron/scheduler.py@@ -202,13 +202,9 @@ def _extract_text_from_agent_payload(payload: dict | None) -> str:def _format_cron_broadcast_text(*, job_name: str, text: str, is_placeholder: bool) -> str:- body = str(text or "").strip()- if not body:- return body- if is_placeholder or body.startswith("[cron]"):- return body- name = str(job_name or "").strip() or "cron"- return f"{name} result:\n\n{body}"+ # Result body, in-progress placeholders, and [cron] status text are all+ # delivered as-is — no job-name prefix is prepended.+ return str(text or "").strip()def _cron_next_push_dt(cron_expr: str, base_dt: datetime) -> datetime:diff --git a/tests/unit_tests/gateway/test_cron_scheduler.py b/tests/unit_tests/gateway/test_cron_scheduler.pyindex c7ab2c39ac..0365f76716 100644--- a/tests/unit_tests/gateway/test_cron_scheduler.py+++ b/tests/unit_tests/gateway/test_cron_scheduler.py@@ -459,7 +459,7 @@ class TestHandleEventStoreValidation:# push_update delivered successfullyassert len(handler.published) == 1content = _cron_published_content(handler.published[0])- assert content == f"{job.name} result:\n\nresult: 9am now"+ assert content == "result: 9am now"@pytest.mark.asyncioasync def test_wake_executes_normally_when_job_present(self, tmp_path):@@ -1292,12 +1292,12 @@ class TestCronTeamStreamHelpers:class TestCronBroadcastText:@staticmethod- def test_prefixes_final_result_with_job_name():+ def test_final_result_returned_without_prefix():assert _CronSchedulerTeamTestApi.format_cron_broadcast_text(job_name="agent-core-commit-review",text="## 审查完成",is_placeholder=False,- ) == "agent-core-commit-review result:\n\n## 审查完成"+ ) == "## 审查完成"@staticmethoddef test_keeps_placeholder_unchanged_and_passes_through_cron_prefixed_status():