Skip to content

[codex] mirror proactive deliveries into session transcripts - #86491

Closed
VishalJ99 wants to merge 2 commits into
openclaw:mainfrom
VishalJ99:codex/proactive-delivery-transcript-mirrors
Closed

VishalJ99 wants to merge 2 commits into
openclaw:mainfrom
VishalJ99:codex/proactive-delivery-transcript-mirrors

Conversation

@VishalJ99

@VishalJ99 VishalJ99 commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Mirror proactive cron announce/failure delivery into custom/main session transcripts with a stable cron-announce-mirror:v1:* idempotency key.
  • Keep routed direct, legacy dm, group, and channel session transcripts out of cron mirrors, including provider-owned suffixes such as Telegram :topic: and Slack thread suffixes.
  • Mirror heartbeat/digest delivery into the active/base chat transcript with a stable heartbeat-delivery-mirror:v1:* idempotency key so follow-up replies can see the proactive message that was actually sent.
  • Add focused regression coverage for both delivery paths.

Supersedes #86140 with the same bug class handled in one PR.

Verification

  • Based on origin/main 5f934830d38272dbe5ed12b453430599378dd936; PR head is 0a806a46410479c718e79884c8cb9148c84645b9.
  • node scripts/run-vitest.mjs src/cron/delivery.failure-notify.test.ts (1 file, 13 tests passed)
  • node scripts/run-vitest.mjs src/infra/heartbeat-runner.respects-ackmaxchars-heartbeat-acks.test.ts (1 file, 14 tests passed)
  • pnpm exec oxfmt --check --threads=1 src/cron/delivery.ts src/cron/delivery.failure-notify.test.ts src/infra/heartbeat-runner.ts src/infra/heartbeat-runner.respects-ackmaxchars-heartbeat-acks.test.ts
  • git diff --check origin/main...HEAD
  • pnpm changed:lanes --json (core, coreTests)
  • pnpm check:changed
  • node --import tsx --input-type=module - temp-state cron alias proof (target_session_key=main, canonical_session_key=agent:ops:work, alias_mirror_ok=true)
  • Added heartbeat text+mediaUrls regression coverage: transcript mirrors preserve the delivered heartbeat text instead of resolving to the attachment filename.

Changelog candidate

  • Proactive delivery: mirror cron announce/failure notifications and heartbeat/digest sends into the destination transcript so follow-up replies keep the delivered message in context.

Note: the changelog line is intentionally kept out of this PR diff to avoid repeated CHANGELOG.md conflicts while main is moving quickly. It can be added at landing.

Real behavior proof

Behavior addressed: Proactive outbound deliveries that are visible to a user now append the delivered assistant text to the transcript that the next turn will read. Cron announce/failure delivery mirrors only into custom/main session keys and skips routed direct/dm/group/channel chat transcripts, including provider-owned suffixes such as Telegram topics. Heartbeat/digest delivery mirrors into the active/base chat session key, so a reply after a WhatsApp-style proactive digest has the sent digest in context.

Real environment tested: Local OpenClaw checkout /Users/dross/openclaw-cron-transcript-mirror, branch codex/proactive-delivery-transcript-mirrors, head 0a806a46410479c718e79884c8cb9148c84645b9, based on origin/main 5f934830d38272dbe5ed12b453430599378dd936, with a temporary OPENCLAW_STATE_DIR. The proof uses a local in-process outbound plugin named proofline, so no private external account, phone number, endpoint, or token is needed. It exercises sendCronAnnouncePayloadStrict and runHeartbeatOnce through sendDurableMessageBatch, outbound delivery, and transcript append.

Exact steps or command run after this patch: Ran node --import tsx --input-type=module - from the repo root with an inline harness that registered a local proofline outbound adapter, seeded the default session store with a custom cron session key, a Telegram topic-suffixed group session key, and a direct heartbeat session key, delivered cron and heartbeat messages, then read the resulting transcript files from the temporary state directory.

Evidence after fix:

OPENCLAW_RUNTIME_PROOF proactive delivery transcript mirrors
state_dir=/var/folders/69/5f9v9rq9045bwk3w75cht7wm0000gn/T/openclaw-proactive-mirror-proof.VAikaS
store_path=/var/folders/69/5f9v9rq9045bwk3w75cht7wm0000gn/T/openclaw-proactive-mirror-proof.VAikaS/agents/main/sessions/sessions.json
send_results=[{"to":"cron-recipient","text":"proof cron mirror text"},{"to":"topic-recipient","text":"proof topic mirror skip text"},{"to":"heartbeat-user","text":"proof heartbeat mirror text"}]
cron_custom_transcript={"exists":true,"lineCount":2,"lastRole":"assistant","lastText":"proof cron mirror text","lastIdempotencyKey":null}
topic_group_transcript={"exists":false,"lineCount":0,"lastRole":null,"lastText":null,"lastIdempotencyKey":null}
heartbeat_transcript={"exists":true,"lineCount":2,"lastRole":"assistant","lastText":"proof heartbeat mirror text","lastIdempotencyKey":null}
cron_mirror_ok=true
topic_group_mirror_skipped=true
heartbeat_mirror_ok=true

Observed result after fix: All three sends reached the local outbound adapter. The custom cron session transcript was created and ended with the mirrored assistant message. The Telegram topic-suffixed group session still delivered but did not create a transcript mirror. The direct heartbeat session transcript was created and ended with the mirrored heartbeat/digest assistant message.

What was not tested: I did not run a real WhatsApp, Telegram, or Slack network send from this branch. The motivating live WhatsApp evidence was captured separately on a private Dross setup: a heartbeat/digest message was visible in WhatsApp, the user replied immediately after it, and the active session transcript did not contain the digest before this patch. That before-fix evidence is privacy-redacted and not attached as a PR image.

@openclaw-barnacle openclaw-barnacle Bot added the proof: supplied External PR includes structured after-fix real behavior proof. label May 25, 2026
@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 9:34 AM ET / 13:34 UTC.

Summary
The branch adds cron announce/failure and heartbeat/digest delivery mirror metadata plus regression tests so proactive sends append assistant rows to selected session transcripts.

PR surface: Source +164, Tests +291. Total +455 across 4 files.

Reproducibility: yes. Source inspection shows the PR writes openclaw/delivery-mirror rows while current replay filtering removes those rows before provider prompt submission, so transcript-append proof does not reproduce the claimed next-turn context fix.

Review metrics: 1 noteworthy metric.

  • Proactive mirror paths: 2 added. Cron announce/failure and heartbeat/digest delivery both gain transcript-mirror writes, so replay and delivery-hook semantics need maintainer review before merge.

Stored data model
Persistent data-model change detected: serialized state: src/cron/delivery.ts, serialized state: src/infra/heartbeat-runner.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #88757
Summary: This PR is a broad candidate fix for the canonical proactive-message/session-context tracker, while merged cron awareness and open heartbeat PRs cover narrower overlapping slices.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦪 silver shellfish
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted proof from a real follow-up agent turn after proactive delivery, preferably in Telegram or another real channel.
  • Align the implementation with the current cron system-event awareness direction or clearly narrow it to transcript/history bookkeeping.
  • Resolve the merge conflict after maintainers choose the context contract.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR supplies copied local runtime output for outbound sends and transcript appends, but not a real follow-up agent turn that sees the proactive context after the fix; add redacted real-channel or terminal proof and update the PR body to trigger re-review.

Mantis proof suggestion
A Telegram Desktop run would directly show whether a reply after proactive delivery reaches an agent turn with the delivered content in context. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: send a proactive heartbeat or cron delivery, reply in the same Telegram chat asking what was just delivered, and record whether the next agent turn has that proactive content in context.

Risk before merge

  • [P1] Delivery-mirror rows are filtered before provider replay, so merging this as a context fix can make transcript/history surfaces look repaired while follow-up model turns still miss proactive heartbeat content.
  • [P1] The branch adds post-send mirror writes keyed by session and idempotency data; wrong session-key assumptions can duplicate or mis-associate proactive context.
  • [P1] The PR is currently dirty against main, and current main already moved the cron slice toward system-event awareness while heartbeat work is split across related open PRs.

Maintainer options:

  1. Route Through Replay-Safe Context (recommended)
    Change the heartbeat/proactive context path so the next provider turn receives the delivered content through system events, pending-question context, or another maintainer-approved replay-safe mechanism.
  2. Accept Transcript-Only Scope
    Maintainers can intentionally land a narrowed version only as transcript/history bookkeeping if the PR stops claiming follow-up turns read the proactive message from replay.
  3. Pause Behind Canonical Context Work
    Pause or close this branch if the desired outcome should be owned by the broader proactive-context tracker and related heartbeat PRs.

Next step before merge

  • [P1] The remaining blocker is a maintainer context-contract decision plus real follow-up proof and conflict resolution, not a narrow automated code repair.

Security
Cleared: The diff changes cron/heartbeat delivery metadata and tests only; it does not add dependencies, workflows, package scripts, credentials, permissions, or package-resolution changes.

Review findings

  • [P1] Route proactive context through a replay-safe path — src/infra/heartbeat-runner.ts:2099-2107
Review details

Best possible solution:

Route proactive delivery context through a replay-safe mechanism such as system events or pending-question context, and keep transcript mirrors as bookkeeping unless maintainers explicitly narrow the scope.

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

Yes. Source inspection shows the PR writes openclaw/delivery-mirror rows while current replay filtering removes those rows before provider prompt submission, so transcript-append proof does not reproduce the claimed next-turn context fix.

Is this the best way to solve the issue?

No. Transcript mirroring is plausible history bookkeeping, but the best fix for the reported conversation-context bug needs a maintainer-approved replay-safe mechanism such as system-event or pending-question context.

Full review comments:

  • [P1] Route proactive context through a replay-safe path — src/infra/heartbeat-runner.ts:2099-2107
    This heartbeat send adds a delivery-mirror transcript row, but current replay normalization drops openclaw/delivery-mirror rows before provider prompt submission. A follow-up turn can still miss the proactive digest, so either narrow this to transcript/history bookkeeping or route the context through an approved replay-safe mechanism.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR targets proactive delivery/session context for real channel workflows and can affect follow-up conversation continuity.
  • merge-risk: 🚨 session-state: The diff writes proactive channel sends into session transcripts and changes which session key owns mirror records.
  • merge-risk: 🚨 message-delivery: Adding mirror metadata changes outbound delivery hook payloads and can affect hook-driven send modification, suppression, or mirrored payload semantics.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR supplies copied local runtime output for outbound sends and transcript appends, but not a real follow-up agent turn that sees the proactive context after the fix; add redacted real-channel or terminal proof and update the PR body to trigger re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The claimed next-turn proactive-context behavior is visible in Telegram-style chats and can be demonstrated with a short proactive-send then reply recording.
Evidence reviewed

PR surface:

Source +164, Tests +291. Total +455 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 176 12 +164
Tests 2 293 2 +291
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 469 14 +455

What I checked:

Likely related people:

  • scotthuang: Authored the merged cron target-session awareness PR that now covers the cron next-turn context slice through system events. (role: recent cron context contributor; confidence: high; commits: 81abc2b21b03; files: src/cron/isolated-agent/delivery-dispatch.ts, src/cron/isolated-agent/run.ts)
  • steipete: Commit fdaeada introduced delivered outbound message mirroring across transcript and outbound delivery surfaces that this PR extends. (role: introduced related transcript mirror behavior; confidence: high; commits: fdaeada3ec76; files: src/config/sessions/transcript.ts, src/infra/outbound/deliver.ts)
  • Countermarch: Authored active related heartbeat PRs around commitment heartbeat mirroring and pending-question reply linkage, which overlap the remaining heartbeat context boundary. (role: adjacent heartbeat context contributor; confidence: medium; commits: e9d2c77708b3, d5d6b6e383de; files: src/infra/heartbeat-runner.ts, src/config/sessions/pending-question-context.ts, src/commitments/extraction.ts)
  • cxbAsDev: Current shallow blame for the reviewed replay, transcript, cron, and heartbeat surfaces points at the current-main grafted snapshot, making this useful as a current routing signal but weak original-authorship proof. (role: recent area contributor; confidence: low; commits: 615558f6fb3a; files: src/agents/embedded-agent-runner/replay-history.ts, src/config/sessions/transcript.ts, src/cron/isolated-agent/delivery-dispatch.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels May 25, 2026
@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

PER-161

Supersedes openclaw#86140 by covering both cron announce/failure delivery and heartbeat/digest delivery in one proactive transcript mirror fix.
@VishalJ99
VishalJ99 force-pushed the codex/proactive-delivery-transcript-mirrors branch from 25ce2a2 to b154199 Compare May 25, 2026 13:54
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 25, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 25, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 25, 2026
@VishalJ99

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 25, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels May 29, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 14, 2026
@clawsweeper

clawsweeper Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: [codex] mirror proactive deliveries into session transcripts This is item 1/1 in the current shard. Shard 18/31.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

This branch had an error being deployed

1 failed deployment
qa-live-shared — 0a806a46 Deployed Jun 20, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #204494
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity 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