Skip to content

fix: retain best-effort cron context for follow-up replies - #130551

Merged
obviyus merged 2 commits into
openclaw:mainfrom
AyitLabs:fix/cron-best-effort-context
Aug 30, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
AyitLabs:fix/cron-best-effort-context

Conversation

@AyitLabs

@AyitLabs AyitLabs commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Related: #88757

What Problem This Solves

Fixes an issue where an operator's terse reply to a successful best-effort isolated Cron announcement could reach the model without the announcement after a Gateway restart.

For example, a scheduled check-in can ask for the operator's current weight. If the operator replies only “200 pounds,” the model needs the delivered check-in to understand what the number means.

This is the best-effort persistence slice of the broader proactive-message context problem. It does not change command Cron or every cross-session message path.

Root Cause

Successful direct Cron delivery already writes an idempotent mirror to the destination session transcript. Normal provider context correctly filters those OpenClaw-authored mirrors.

Required delivery also queues short-lived target awareness. Best-effort delivery does not. After a restart removes the live Telegram chat window, neither source carries the scheduled message into the next ordinary reply.

Why This Change Was Made

The repair marks a successful direct Cron mirror only when no required target-awareness event owns that context. The transcript reader keeps the marker filtered by default and admits it only when an inbound channel asks for a chat window but has no live window.

Strict delivery, explicit reply context, message-tool delivery, current-session completion, failed delivery, partial delivery, reset fencing, and cleanup keep their existing paths.

The Telegram proof runner now accepts bestEffort: true on its Cron scenario action. This keeps the live regression replayable without selecting a credential or bypassing the Convex lease pool.

User Impact

After a successful best-effort isolated Cron announcement, the next ordinary reply can see the delivered content exactly once after a Gateway restart.

No config, environment variable, SQLite schema, migration, database version, public plugin API, or user-facing command changes.

Evidence

  • Live Telegram red: exact current main b30cef73edae8daec41c0ba36bfbe24f02701325 delivered the scheduled result, restarted the Gateway, and processed the terse follow-up with 0 scheduled-result copies in the provider request.
  • Live Telegram green: exact pushed head e6cfe7587123ab9338f1671de4fc36290b5c3d49 ran the same flow with exactly 1 scheduled-result copy in the follow-up provider request.
  • Anti-cheat evidence: each run recorded two provider requests, two distinct Telegram message IDs, a completed Cron run, completed Gateway restart, removed Cron job, complete event recording, and released runner resources.
  • Focused owner tests: transcript 65/65, Cron delivery 164/164, focused channel context 2/2, and Telegram scenario parser 5/5 passed.
  • Repository gates: targeted format and lint, conflict markers, max-lines, assertion safety, coercion, deprecation, database-first, and import-cycle checks passed. Exact main and head builds passed their fingerprints and CLI smoke checks.
  • Production versus proof delta: production +44/-23 (net +21), unit tests +86, and Telegram harness +14/-3. The production growth carries the producer marker, default-closed selective reader, and no-live-window consumer together.

Proof limitations:

Review Follow-up

Sanitized Exact-Head Trace

{
  "head": "e6cfe7587123ab9338f1671de4fc36290b5c3d49",
  "cron": {
    "status": "completed",
    "runStatus": "ok",
    "cleanup": "removed"
  },
  "gatewayRestart": "completed",
  "recordingComplete": true,
  "distinctTelegramMessageCount": 2,
  "scheduledResultCopiesInFollowupProviderRequest": 1,
  "verdictSha256": "42138ef9c5f787cacd3800f1f06a120a7eef02f13456655b00515acb2469c9ee"
}

The equivalent current-main trace recorded scheduledResultCopiesInFollowupProviderRequest: 0.

AI-assisted development disclosure: the implementation and tests were produced with Codex assistance under human direction and validated through the evidence above.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 29, 2026, 11:37 AM ET / 15:37 UTC.

ClawSweeper review

What this changes

The branch tags successful best-effort isolated Cron delivery mirrors and restores that tagged text to a later Telegram reply only when no live chat window remains.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 4 items remain

Keep open. The production change is a coherent, narrowly gated repair with no concrete correctness finding, but its supplied live Telegram evidence names older head 4d2d7de rather than the current e6cfe75 source identity, so current-head behavior proof remains required before merge.

Priority: P2
Reviewed head: e6cfe7587123ab9338f1671de4fc36290b5c3d49

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and its owner-boundary tests are credible, but real behavior proof has not been refreshed for the current head.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The changed production owners are direct Cron dispatch, durable transcript filtering, and inbound Telegram context assembly. The body describes a real Telegram transport/Cron/restart/provider-request trace, but its green run identifies older head 4d2d7de rather than the reviewed e6cfe75 head, so the observed after-fix result is not attributable to the final branch identity. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The changed production owners are direct Cron dispatch, durable transcript filtering, and inbound Telegram context assembly. The body describes a real Telegram transport/Cron/restart/provider-request trace, but its green run identifies older head 4d2d7de rather than the reviewed e6cfe75 head, so the observed after-fix result is not attributable to the final branch identity. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Introduced producer and scope: The introduced dispatch path adds the marker only after a delivered direct Cron batch and only when required target-awareness context is absent; failed or partial delivery remains unmarked.
Default-closed consumer: The inbound context owner requests marked Cron context only when a configured chat window has zero live entries; an existing live window continues to use the ordinary transcript filter.
Transcript filtering contract: The reader continues to exclude all OpenClaw-authored transcript artifacts by default and admits only the exact new marker when its explicit option is set.
Findings None None.
Security None None.

How this fits together

Cron delivery sends scheduled output to a channel session, and the next inbound channel reply assembles transcript and live-window context before reaching the model. This change gives the durable transcript a narrowly scoped fallback when the live Telegram window was lost during a Gateway restart.

flowchart LR
  Cron[Scheduled Cron delivery] --> Mirror[Session transcript mirror]
  Mirror --> Marker[Best-effort context marker]
  Reply[Inbound Telegram reply] --> Window{Live chat window?}
  Window -->|yes| Live[Use live chat context]
  Window -->|no| Reader[Read marked transcript context]
  Reader --> Model[Follow-up model request]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The changed production owners are direct Cron dispatch, durable transcript filtering, and inbound Telegram context assembly. The body describes a real Telegram transport/Cron/restart/provider-request trace, but its green run identifies older head 4d2d7de rather than the reviewed e6cfe75 head, so the observed after-fix result is not attributable to the final branch identity. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The repair adds a durable session-context replay path (+21 net production lines); it must remain marker-specific, default-filtered, bounded by the existing history limit, and enabled only when no live window survives.
  • Resolve merge risk (P1) - The available real-flow trace is tied to an earlier head, so it does not yet prove the exact current branch after its force-push.
  • Complete next step (P2) - A current-head real-behavior trace is a contributor-side merge gate; no mechanical repair is indicated.
Agent review details

Security

None.

PR surface

Source +21, Tests +90, Other +7. Total +118 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 44 23 +21
Tests 4 92 2 +90
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 8 1 +7
Total 11 144 26 +118

Review metrics

Metric Value Why it matters
Production versus test delta production +44/-23 (net +21); tests +86; Telegram harness +14/-3 The positive production growth creates a durable session-context marker and selective reader, so its bounded replay predicate is merge-relevant.

Stored data model

Persistent data-model change detected: serialized state: src/channels/inbound-event/session-transcript-context.runtime.ts, serialized state: src/config/sessions/transcript.ts, unknown-data-model-change: src/config/sessions/transcript.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the final replay boundary (recommended)
    Run the Telegram restart scenario on the current head and publish a redacted event timeline plus provider-request observation showing exactly one restored scheduled message.
  2. Accept the bounded transcript replay design
    Merge only if maintainers accept that a successful best-effort scheduled message becomes durable fallback context when the live window is unavailable.

Technical review

Best possible solution:

Retain the producer-owned marker and the default-closed, no-live-window reader predicate, then establish the same Telegram restart-and-terse-reply result on the current head.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible with high confidence: an explicit best-effort isolated Cron delivery writes a transcript-only mirror, current main filters it, and a post-restart Telegram reply has no live window. This read-only review did not execute the contributor branch.

Is this the best way to solve the issue?

Yes. Reusing the existing durable delivery mirror with a closed marker and a no-live-window reader is narrower than a new store or broad replay of proactive messages.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6475e098a014.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The changed production owners are direct Cron dispatch, durable transcript filtering, and inbound Telegram context assembly. The body describes a real Telegram transport/Cron/restart/provider-request trace, but its green run identifies older head 4d2d7de rather than the reviewed e6cfe75 head, so the observed after-fix result is not attributable to the final branch identity. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: This is a bounded repair for an isolated best-effort Cron follow-up path, without evidence of broad runtime unavailability.
  • merge-risk: 🚨 session-state: Merging changes which durable transcript rows become model context after the live channel window disappears.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The changed production owners are direct Cron dispatch, durable transcript filtering, and inbound Telegram context assembly. The body describes a real Telegram transport/Cron/restart/provider-request trace, but its green run identifies older head 4d2d7de rather than the reviewed e6cfe75 head, so the observed after-fix result is not attributable to the final branch identity. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The change affects whether a Telegram user's post-restart reply is interpreted with the scheduled message they received, which the Telegram Test Server scenario can demonstrate.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current-baseline blame covers the transcript-context merger, transcript filtering, and direct Cron delivery decision surface around this repair. (role: baseline session and Cron delivery owner; confidence: medium; commits: 31baa67f9874; files: src/cron/isolated-agent/delivery-dispatch.ts, src/config/sessions/transcript.ts, src/channels/inbound-event/session-transcript-context.runtime.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Run the exact Telegram best-effort Cron, Gateway-restart, and terse-follow-up scenario on e6cfe75 and add redacted event/provider-request evidence to the PR body.
  • After updating proof, let the automatic review refresh or ask a maintainer to comment @clawsweeper re-review if it does not.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-27T01:10:48.268Z sha 17ece9bc314d4d153fd16a32b8247b4ea81ac790 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T01:34:52.568Z sha 17ece9bc314d4d153fd16a32b8247b4ea81ac790 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T02:01:20.326Z sha 17ece9bc314d4d153fd16a32b8247b4ea81ac790 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T02:19:14.167Z sha 17ece9bc314d4d153fd16a32b8247b4ea81ac790 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T13:20:40.643Z sha 4d2d7de52f8f7f7a5fc2feddd8dd1dff938e7c30 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot removed the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Aug 27, 2026
@AyitLabs
AyitLabs marked this pull request as ready for review August 27, 2026 02:12
@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Aug 27, 2026
@obviyus
obviyus force-pushed the fix/cron-best-effort-context branch from 17ece9b to 4d2d7de Compare August 29, 2026 13:12
@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. and removed mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Aug 29, 2026
@obviyus
obviyus force-pushed the fix/cron-best-effort-context branch from 4d2d7de to e6cfe75 Compare August 29, 2026 15:28
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 29, 2026
@obviyus
obviyus merged commit ed37774 into openclaw:main Aug 30, 2026
884 of 891 checks passed
@obviyus

obviyus commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks @AyitLabs!

Proof: A real Telegram Test Server flow delivered a best-effort isolated Cron result, restarted the Gateway, and sent a terse follow-up. Current main passed zero scheduled-result copies to the provider, while this exact head passed exactly one copy.

  • Bug: A successful scheduled message could disappear from model context after a Gateway restart.
  • Fix: The Cron owner marks the durable delivery mirror, and the inbound context reader admits it only when no live chat window survives.

Example

Before After
“What result did the scheduled check deliver?” reached the model without the delivered result. The same follow-up includes the delivered result exactly once.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
Best-effort isolated Cron delivery mirrors now remain available as bounded fallback context after a Gateway restart removes the live chat window.

Normal transcript artifacts stay filtered, strict delivery awareness remains separate, and the fallback activates only when no live window survives.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants