openclaw - ✅(Solved) Fix [Feature]: keep each cron run in its own Telegram forum topic [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#71606Fetched 2026-04-26 05:10:45
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1cross-referenced ×1

Cron delivery can target a Telegram group or an existing Telegram forum topic, but there is no first-class way to keep each scheduled run in its own Telegram forum topic.

Root Cause

Severity: medium. Static delivery works, but high-frequency or high-value recurring jobs become difficult to review because run output is interleaved.

PR fix notes

PR #60890: fix(cron): support thread-id in cron add/edit and paged lookup

Description (problem / solution / changelog)

Summary

  • Problem: openclaw cron add / openclaw cron edit did not support --thread-id, so CLI users could not configure Telegram topic delivery for cron jobs.
  • Why it matters: Telegram forum-topic workflows require topic-aware targets, and missing CLI support forced users into manual edits or left cron jobs unable to target topics.
  • What changed: added --thread-id support to cron add and cron edit, validated it against the final cron job shape, reused existing Telegram targets safely during edit, and stabilized paged job lookup ordering for edit flows.
  • What did NOT change (scope boundary): this PR does not change non---thread-id delivery semantics for other channels, does not redesign backend cron delivery storage, and does not change generic webhook delivery behavior outside the --thread-id path.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #50982
  • Related #60373
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: the cron CLI exposed delivery channel/target flags but had no dedicated --thread-id support or consistent validation model for Telegram topic delivery.
  • Missing detection / guardrail: cron edit had no effective-state validation for topic delivery, so fallback reuse, blank inputs, webhook targets, and non-Telegram targets could slip into invalid paths.
  • Contributing context (if known): topic delivery was historically represented through Telegram target strings, but the CLI did not implement the required parsing/validation path for add/edit flows.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • src/cli/cron-cli.test.ts
  • Scenario the test should lock in:
    • cron add accepts valid Telegram topic delivery and rejects invalid --thread-id combinations.
    • cron edit accepts valid Telegram topic edits, rejects invalid fallback/webhook/non-Telegram paths, and finds jobs across paged lookup.
  • Why this is the smallest reliable guardrail:
    • the logic is entirely in CLI argument parsing, normalization, fallback resolution, and patch construction.
  • Existing test that already covers this (if any):
    • existing cron CLI add/edit tests covered adjacent delivery behavior but not topic-specific paths.
  • If no new test is added, why not:
    • N/A

User-visible / Behavior Changes

  • openclaw cron add now accepts --thread-id <id>.
  • openclaw cron edit now accepts --thread-id <id>.
  • When --thread-id is used, the CLI requires a Telegram delivery target and composes topic delivery as <chatId>:topic:<threadId>.
  • cron edit now rejects blank --thread-id, blank --channel, blank --to, non-Telegram fallback reuse, and webhook reuse without explicit compatible announce retargeting.
  • cron edit --exact / paged lookup now uses stable ordering (sortBy=name, sortDir=asc) when searching for the target job.

Diagram (if applicable)

Before:
[cron add/edit --thread-id] -> [CLI has no supported path or unsafe fallback path] -> [cannot target Telegram topic correctly]

After:
[cron add/edit --thread-id]
  -> [normalize thread-id/channel/to]
  -> [validate final job is non-main + agentTurn + telegram]
  -> [reuse existing telegram target only when safe]
  -> [compose "<chatId>:topic:<threadId>"]
  -> [send cron.add / cron.update patch]

## Security Impact (required)

- New permissions/capabilities? (No)
- Secrets/tokens handling changed? (No)
- New/changed network calls? (No)
- Command/tool execution surface changed? (No)
- Data access scope changed? (No)
- If any Yes, explain risk + mitigation:
    - N/A

## Repro + Verification

### Environment

- OS: macOS
- Runtime/container: Node 22.20.0
- Model/provider: N/A
- Integration/channel (if any): Telegram cron delivery
- Relevant config (redacted): local CLI test mocks

### Steps

1. Run pnpm exec vitest run --config vitest.cli.config.ts src/cli/cron-cli.test.ts
2. Run OPENCLAW_CONFIG_PATH=./openclaw.test.json OPENCLAW_SKIP_CHANNELS=1 pnpm openclaw cron add --name codex-thread-id-e2e --cron "*/30 * * * *"
   --message "hello from e2e" --channel telegram --to -1003735618174 --thread-id 48 --json

### Expected

- CLI cron tests pass.
- cron add builds a Telegram topic target.
- Invalid combinations fail fast with CLI errors.

### Actual

- src/cli/cron-cli.test.ts passed completely (63 passed).
- cron add returned a job with:
    - delivery.channel = "telegram"
    - delivery.to = "-1003735618174:topic:48"

## Evidence

Attach at least one:

- [x] Failing test/log before + passing after
- [ ] Trace/log snippets
- [ ] Screenshot/recording
- [ ] Perf numbers (if relevant)

## Human Verification (required)

What you personally verified (not just CI), and how:

- Verified scenarios:
    - valid cron add --thread-id Telegram target composition
    - valid cron edit --thread-id with explicit Telegram target
    - valid cron edit --thread-id reusing existing Telegram target
    - valid cron edit --thread-id for current and session:<id> jobs
    - rejection of main/systemEvent, blank input, non-Telegram fallback, --no-deliver, and webhook-without-announce cases
    - paged cron edit --exact lookup with stable ordering
- Edge cases checked:
    - replacing an existing :topic:<id> suffix instead of appending a second one
    - requiring explicit Telegram retargeting when existing delivery is webhook
    - rejecting blank --channel, blank --to, and blank --thread-id
- What you did not verify:
    - end-to-end live Telegram delivery against a real channel/account
    - unrelated repo-wide typecheck failures outside this change

## Review Conversations

- [ ] I replied to or resolved every bot review conversation I addressed in this PR.
- [ ] I left unresolved only the conversations that still need reviewer or maintainer judgment.

## Compatibility / Migration

- Backward compatible? (Yes)
- Config/env changes? (No)
- Migration needed? (No)
- If yes, exact upgrade steps:
    - N/A

## Risks and Mitigations

- Risk:
    - cron edit topic delivery fallback could accidentally reuse incompatible delivery state.
    - Mitigation:
        - explicit effective-state validation only allows safe Telegram reuse and rejects webhook/non-Telegram fallback paths.
- Risk:
    - paged lookup could miss jobs if ordering drifts between pages.
    - Mitigation:
        - lookup now requests stable name-based ordering.
- Risk:
    - repo pre-commit global typecheck currently fails on unrelated existing files.
    - Mitigation:
        - verified this change with targeted CLI tests; commit was created with --no-verify only because of unrelated pre-existing hook failures
          outside these touched files.

## Changed files

- `docs/notes/cron-thread-id-redesign.md` (added, +293/-0)
- `src/cli/cron-cli.test.ts` (modified, +365/-1)
- `src/cli/cron-cli/register.cron-add.ts` (modified, +43/-8)
- `src/cli/cron-cli/register.cron-edit.ts` (modified, +142/-5)
- `src/cli/cron-cli/thread-id-shared.ts` (added, +62/-0)

Code Example

$ openclaw --version
OpenClaw 2026.4.23

$ openclaw cron add --help | grep -- '--thread-id'
# no output

$ openclaw message send --help | grep -- '--thread-id'
  --thread-id <id>       Thread id (Telegram forum thread)

---

For Telegram forum topics, use -1001234567890:topic:123.

---

09:00 cron run "Daily report"
  -> final report delivered into the configured Telegram destination

10:00 cron run "Daily report"
  -> final report delivered into the same Telegram destination

Result:
  The two runs share one conversation history even though follow-up discussion
  often belongs to one specific run.
RAW_BUFFERClick to expand / collapse

Summary

Cron delivery can target a Telegram group or an existing Telegram forum topic, but there is no first-class way to keep each scheduled run in its own Telegram forum topic.

Problem to solve

Recurring cron jobs often produce outputs that are naturally reviewed per run: daily reports, periodic checks, inbox digests, alert summaries, and similar operational updates.

When those jobs deliver into one Telegram group or one static forum topic, the history for separate runs becomes interleaved:

  • Follow-up discussion for an older run appears beside newer run output.
  • Failures and normal reports share the same thread history.
  • It is harder to tell which comments belong to which scheduled run.
  • Users need manual topic creation, prompt-level message sends, or external webhook scripts to preserve per-run context.

This is related to static Telegram topic delivery, but it is a different user problem. Static topic targeting answers "send every run to this existing topic." The missing workflow is "make each run easy to review as a separate Telegram forum thread."

Impact

Affected users/systems/channels:

  • Users running recurring OpenClaw cron jobs that report into Telegram forum groups.
  • Operational/reporting workflows where each run needs its own review thread.
  • Telegram forum groups used as an inbox or task queue for scheduled agent work.

Severity: medium. Static delivery works, but high-frequency or high-value recurring jobs become difficult to review because run output is interleaved.

Frequency: every scheduled run for users who use Telegram forum topics as their delivery surface.

Consequence: users have to preserve per-run context outside the normal cron delivery path.

Evidence/examples

Example

Current CLI surface on OpenClaw 2026.4.23:

$ openclaw --version
OpenClaw 2026.4.23

$ openclaw cron add --help | grep -- '--thread-id'
# no output

$ openclaw message send --help | grep -- '--thread-id'
  --thread-id <id>       Thread id (Telegram forum thread)

Current docs support static Telegram topic delivery:

For Telegram forum topics, use -1001234567890:topic:123.

Example workflow pain:

09:00 cron run "Daily report"
  -> final report delivered into the configured Telegram destination

10:00 cron run "Daily report"
  -> final report delivered into the same Telegram destination

Result:
  The two runs share one conversation history even though follow-up discussion
  often belongs to one specific run.

Related existing work:

I did not find an existing issue specifically for the per-run Telegram forum topic workflow.

Additional information

The main user-facing gap is organization and reviewability of recurring cron output in Telegram forum groups. Existing delivery modes make it possible to send the output somewhere, but they do not make each run naturally separable in the destination chat.

extent analysis

TL;DR

Create a new Telegram forum topic for each scheduled run to keep the output of each run separate and organized.

Guidance

  • Consider adding a --thread-id option to the openclaw cron add command to allow users to specify a unique thread ID for each run.
  • Modify the openclaw message send command to automatically create a new thread for each run if a thread ID is not provided.
  • Update the documentation to include an example of how to use the --thread-id option to deliver cron output to a separate thread for each run.
  • Investigate the feasibility of automatically generating a unique thread ID for each run based on the cron job name and run timestamp.

Example

$ openclaw cron add --thread-id "daily-report-2024-09-16" -- "Daily report"

This example assumes the addition of a --thread-id option to the openclaw cron add command.

Notes

The implementation details of creating a new thread for each run will depend on the Telegram API and the existing OpenClaw codebase. The proposed solution may require changes to the OpenClaw backend and CLI.

Recommendation

Apply a workaround by manually creating a new Telegram forum topic for each scheduled run until a native solution is implemented. This will allow users to keep the output of each run separate and organized, but it will require manual effort and may not be scalable for high-frequency cron jobs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Feature]: keep each cron run in its own Telegram forum topic [1 pull requests, 1 comments, 2 participants]