Skip to content

fix(cron): keep delivered results in the destination conversation - #168996

Merged
obviyus merged 14 commits into
mainfrom
cron-destination-owner
Oct 11, 2026
Merged

obviyus merged 14 commits into
mainfrom
cron-destination-owner

Conversation

@obviyus

@obviyus obviyus commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

When an automation delivers to another conversation, that conversation can receive the message without the result becoming available to its next model turn. Transcript-only mirrors and creator-awareness notes provide competing accounts of the same result.

Why This Change Was Made

Make the resolved destination own the conversation result for agent, command, and script jobs. Send the already prepared channel/account/recipient/thread without resolving it again against the execution session. After confirmed delivery, commit through the canonical background-result writer, behind active turns and with occurrence idempotency. A conversation-write failure cannot undo confirmed delivery. If execution already owns the destination, retain its existing final reply instead of appending another.

Remove recipient mirrors and creator-awareness notes. Normalize intentional silence before either sending or writing.

User Impact

  • Upgrade: results delivered to another chat now belong to that destination's model-visible history, not the creator's. Creatorless jobs gain destination context. Existing stored jobs require no migration or configuration change.
  • none and webhook do not create automatic conversation results.
  • A destination bound to another agent still receives the notification, but neither agent gets an invented conversation entry. The previous job-agent-local mirror/awareness write is removed; the run records a delivery warning instead.
  • Native-only output without an honest text projection still sends and records a warning, rather than blocking delivery or inventing transcript text.
  • Two accepted regressions versus main: a job's message-tool send to a chat other than its delivery target no longer leaves a model-visible note there (#168683); delivery-failure awareness notes in the recipient chat are removed (#168684).

Evidence

  • Candidate 121c1905e804f6177fd12157b91e9de22924c197 includes main's UI test-contract repair (ab6c07f595e). Confirmed voice-only speech now enters the existing conversation projection, preserving speech and omitting generated audio. Successful transport fixtures report their confirmed payloads, and media revocation fixtures use a media-capable adapter without weakening cancellation or owner-revocation assertions.
  • Implicit creator-bound agent announcements retain the captured generation through durable sending and queued recovery; explicit destinations remain independent. Both isolated and current reset-after-route-resolution cases fail without their custody repair (incorrectly delivered) and pass after it. The three cron suites pass 117 tests in 43.67 seconds, and the existing outbound generation/recovery suite passes 4 tests (71.39 seconds total wrapper wall time). The affected cron type graph also passes.
  • The exact-head runtime-only build passed. Final Telegram case A → A passed 6 checks with 8 provider requests at 121c1905e804: one native result at +13.475s (Bot API message 82447), exactly one canonical conversation entry, and exactly one occurrence in the next provider request. This round used a DM because Test Server forum fixture preparation failed before Gateway startup. The DM job and all six run-owned messages were removed with deletion readback. The failed forum's exact-title server search found no remaining group; its lease and the final DM lease were released, and both proof ports were free.
  • Exact-head CI run 38164278061 is green: 88 jobs settled with no failures.
  • Command and script announcements intentionally retain main's behavior without a source-generation check once their route has resolved. Adding one would introduce a new failure mode outside this change; their reset semantics are tracked in #169258.
  • The Gateway cron fixture now uses the confirmed-payload return contract, and the route-preservation fixture uses current session metadata. Gateway cron passes 12 tests in 68.78 seconds; destination completion passes 24 tests in 57.05 seconds. Both affected type graphs pass (24.8 and 23.8 seconds). Reset documentation distinguishes explicit external destinations from implicit creator-bound routes; no generation safeguard changed.
  • Prior candidate ac012cc19783aabd1323480bc2d30e3f9e8c5b76 preserves the existing source-isolation policy, binds routes only after confirmed delivery, and records the effective delivered payload. Its runtime-only build passed with the shared build cache.
  • The inherited retained-blob tamper mock was fixed on main by #168975, commit a4056f5bbccdf54679f56dd579dfd22ab945c7c1: corruption now intercepts cat-file --batch while retaining the integrity assertion. After integrating that repair, candidate 0caf96bddec3 passed all 12 sessions-files.repository.test.ts cases in 93.26 seconds.
  • On prior candidate fdd38e70c856d2e4fb0415abdfffbe7bfc918f8b, the nine owner suites plus outbound queue/recovery integration suites passed 225 tests in 11 files, 197.69 seconds. Sixteen targeted counterfactuals failed when their protections were removed; the rebase-sensitive unknown-replay and physical-send deduplication counterfactuals were also rerun and restored.
  • The prior simplification/test audit removed duplicate setup and mock echoes while retaining independent boundary assertions. The failure-alert fixture now supplies its explicit destination, preserving its original adapter-suppression assertion. The three affected Gateway tests passed in 46.78 seconds.
  • Regenerated prompt fixtures after merging main, preserving the intentional scheduler destination-ownership wording and main's new self-resume guidance.
  • Main's new terminal-failure notification is distinct from retrying cancelled command output. The integration test now checks the completion array and separate failure-alert payload, while retaining abort, fresh alert signal, no-retry, and terminal-state assertions; the focused regression passes in 23.55 seconds.
  • The three hosted findings have dedicated regressions: required source sandbox inheritance, rejected/uncertain recipient route preservation, and a real message_sending hook rewriting the visible text. All fail on c407dec21ac2 for the reported reason and pass after repair. The repaired cron suites pass 37 tests in 89.27 seconds, and the Gateway completion suite passes 19 tests in 108.38 seconds.
  • The destination-reset regression also fails on c407dec21ac2 and passes after repair: external delivery continues and the result enters the current destination session. Routeless creator deletion/reset remains fail-closed. Existing released-row coverage still loads and delivers stored jobs without rewriting retained receipts or schema; the minimal persisted fields are also present in the inspected latest stable v2026.10.1 contract. This PR changes no stored schema.
  • On 667cce02e196add1e184096d2740856621eb2447, the refreshed Telegram A → A, A → B, and explicit-destination reset round passed all 16 checks with 22 provider requests. One A message arrived at +8.368s, one B message at +17.836s, and a further result reached B after native /new; transcript and next-provider-request readbacks showed exactly one destination result and no creator copy. The forum and both jobs were deleted, with a zero runner exit.
  • Telegram Test Server, real user, mock provider, fresh forum: prior candidate ac012cc19783 passed all six cases below with 56 recorded provider requests.
Case Recorded round-2 native timeline (identities redacted) Conversation history and next provider request
A → A One message, Bot API message 8, at +9.637s Exactly one result in A; next A request sees it once.
A → B One message, Bot API message 14, at +19.800s Exactly one result in B, none in A; next B request sees it once, next A request sees none.
session:B → B One message, Bot API message 22, at +32.942s Exactly one result in B, none in A; next B request sees it once, next A request sees none.
NO_REPLY No visible message Provider produced NO_REPLY; neither A/B history nor subsequent provider context contains it.
DM thread-99 execution → topicless DM One private message at +232.187s, without a native thread One topicless-DM entry, no A/B mirror; next creator request excludes it.
A → B, then native /new in B, then run again Native reset acknowledgement and one further result in B B's lifecycle revision changes, the new occurrence is committed there, and its next provider request sees that result once with no pre-reset named result.

The doctor passed. The forum was deleted, all five jobs removed, run-owned DM messages verified deleted, and the runner exited zero. Native identities, full events, per-session Gateway transcript reads, and provider requests are retained privately. The thread-99 fixture is a persistent execution-session key, not a fabricated native Telegram private thread. The first reset checker incorrectly expected sessionId rotation; native /new preserves that identifier and rotates the lifecycle revision. The corrected checker uses the native acknowledgement, occurrence identity, and model-context readback from the same preserved recording.

Round 1 on repair head 7c740dbb53392c07278a0dc291530f7fe9cbae3d also passed all five cases with 52 provider requests and clean fixture teardown. Two earlier candidate repetitions at fdd38e70c856 passed the same cases.

Main control at 3f97b146a5aa8dc4c4fdec77d5b182936a74cfe1, A → B twice: one message arrived in B at +9.082s / +7.635s. Both runs showed one transcript-only mirror in B, but the next B provider request contained zero occurrences of the result; A also contained none. This is the discriminating contrast with the candidate's canonical, model-visible destination entry. Both control forums and jobs were deleted, with clean runner exits.

The pre-existing synthetic FTP URL in the completion-webhook redaction fixture is unchanged. ClawSweeper #1931, merged as 472765315dd11b112847ed39a0b2e7d9912f293b, qualifies the exact base/head source blobs for this candidate. The native scan refused before qualification and admitted afterward; foreign-path and changed-source controls remain refused. Only two complete-source hashes were added; the fixture, detector, decoder restrictions, and verification policy are unchanged.

Known limits

  • X has no session resolver, so a non-root post can use the outbound fallback session instead of the conversation-root session used by replies; main has the same gap (#168686).
  • Delivery warnings appear in automations show and run-history JSON, not the Control UI's run-history view (#168687).
  • A job executing in one conversation (session:<key>) and delivering elsewhere retains its run in the executing conversation's transcript; the destination separately owns the delivered result.

Related: #168615 — source of this destination-owner split; the prepared worker-command protocol is not included.

This has a one-way data effect: reverting stops the new behavior but does not relocate entries already written. The blast radius is automation result delivery and the transcript context available to the next reply in the selected destination.

Write cron results once through the canonical session writer in the
resolved destination, independent of the execution session. Send the
prepared notification route without re-resolving it, and remove recipient
mirrors and creator awareness notes.

Keep cross-agent delivery transport-only and record a warning rather than
writing unread context into the job agent's local session.

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Kimiyu-186 <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: XL labels Oct 11, 2026
@obviyus

obviyus commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The input-safety diagnostic identified an unverified FTP detector finding in the synthetic completion-webhook redaction fixture. The fixture now uses the existing URL-construction pattern with placeholder credentials and still exercises credential redaction. No real credential was involved. The cron failure-alert fixture now supplies a real destination, and the intended prompt snapshots have been regenerated.

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

obviyus added a commit to openclaw/clawsweeper that referenced this pull request Oct 11, 2026
* fix(scan): qualify Cron FTP destination-owner source blobs

Add only two reviewed complete-source hashes for the unchanged synthetic FTP fixture in openclaw/openclaw#168996. Preserve detector, decoder, native value, line, path, mode, ref, occurrence and verification checks.

* docs: refresh Cron qualification for frozen destination-owner head
@obviyus

obviyus commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR records confirmed automation output once in the receiving conversation through the canonical session writer.

Example: An automation created in conversation A delivers “Readiness 65 today” to Telegram conversation B.

  • Before: B receives the message, but its next provider request can omit the result.
  • After: B receives one message and its next provider request includes one canonical result, without a creator copy in A.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Shipped-flow evidence supports the central behavior, compatibility coverage preserves stored jobs, and the reviewed head has no remaining introduced blocker.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded Telegram Test Server runs exercise the shipped Gateway and real channel transport, showing one destination transcript entry and one occurrence in the next provider request, with no creator copy. Prior destination/reset evidence remains applicable, and the final head refreshes same-chat delivery. Production-owner regressions and reported counterfactual runs cover stale implicit generations and revoked occurrence authority before their respective final effects.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A user replies to a delivered automation report, but the receiving agent lacks that report in its model context.
Reason: The demonstrated destination-context failure merits repair, and the supplied maintainer-authored direction settles the documented ownership tradeoffs.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses demonstrated missing destination context, repairs the prior current-session generation defect, and has no remaining actionable finding.

Priority: P1
Reviewed head: 121c1905e804f6177fd12157b91e9de22924c197

Before merge

None.

Findings

None.

Agent review details

How this fits together

Cron finalization consumes execution output and prepared delivery coordinates, confirms channel delivery, then publishes model-visible output through the destination’s existing conversation writer.

flowchart TD
  A[Automation execution] --> B[Finalize visible payload]
  B --> C[Prepared destination]
  C --> D[Durable channel send]
  D --> E[Confirmed delivered payload]
  E --> F[Canonical conversation writer]
  F --> G[History and next model turn]
Loading

Technical review

Best possible solution:

Use the confirmed destination payload and existing serialized conversation writer while retaining implicit source custody and visible warnings for failed history writes.

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

Current source retains the competing mirror/awareness paths, and the supplied main-control Telegram readback demonstrates a delivered result missing from the next destination provider request; this review executed no target code.

Is this the best way to solve the issue?

The patch consolidates result persistence behind the existing conversation writer, commits effective delivered content, and preserves delivery success when subsequent history work fails.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 963017465bce.

Provenance checked

  • Recipient mirrors and ephemeral awareness changes intended behavior with a stated reason (81abc2b: The earlier delivery-awareness work supplied next-turn recipient context while keeping cron metadata out of visible messages.)
  • Current-session result ownership changes intended behavior with a stated reason (133d5ff: Current-session completions became durable source-conversation output so WebChat could recover them after reconnect.)
  • Post-success route persistence keeps the original intent (0774c20: Failed cron sends must not persist invalid recipient coordinates that poison subsequent delivery.)
  • Implicit creator custody keeps the original intent (d8e0e88: Creator-bound isolated jobs retained the creating conversation’s generation through route selection and durable delivery.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Destination ownership and confirmed content: The dispatcher sends the prepared route, adopts transport-confirmed payloads, binds the destination after success, and commits through the shared conversation-result owner. (src/cron/isolated-agent/delivery-dispatch.ts:289, 121c1905e804)
  • Prior current-session finding repaired: The change from the previous reviewed head extends implicit creator-generation forwarding to current jobs; the regression resets the creator after route resolution and asserts rejection before channel I/O. (src/cron/isolated-agent/delivery-dispatch-policy.ts:55, 121c1905e804)
  • Final-effect generation checks: The forwarded generation reaches durable delivery, whose adapter handoff and platform dispatch revalidate it after awaited work. (src/infra/outbound/deliver-queue-execute.ts:245, 121c1905e804)
  • Prior command/script finding withdrawn: The original command/script sender already omitted source-generation custody after route resolution; requiring it here would change existing behavior rather than repair an introduced defect. (src/gateway/server-cron-completion.ts:93, af288ea70b81)
  • Recorded Telegram behavior: The supplied body records real Telegram Test Server delivery and transcript/provider-request readbacks for same-chat, different-chat, persistent-session, silence, and destination-reset scenarios; the final head refreshes same-chat delivery. The main control receives the notification while omitting its result from the next destination provider request. Prepared screenshots depict historical work and were not counted as candidate proof. (121c1905e804)
  • Sandbox and occurrence authority coverage: Production-owner fixtures verify required sandbox inheritance, rejected and uncertain route preservation, cancellation, owner retirement, and rejection of writes after transcript preparation loses authority. (src/cron/isolated-agent/current-session-completion.test.ts:109, 121c1905e804)

Likely related people:

  • Peter Steinberger: Raw commit d8e0e88 adds src/cron/isolated-agent/delivery-dispatch-policy.ts:294 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d8e0e88a65e8; files: src/cron/isolated-agent/delivery-dispatch-policy.ts)
  • Ayaan Zaidi: Raw commit 9f330ef adds src/gateway/server-methods/cron.ts:920 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9f330efbe677; files: src/gateway/server-methods/cron.ts)

PR surface

Source -652, Tests +1289, Docs -2, Other -8. Total +627 across 68 files. Added test files: 5.

View PR surface stats
Area Files Added Removed Net
Source 27 1144 1796 -652
Tests 35 2899 1610 +1289
Docs 4 29 31 -2
Config 0 0 0 0
Generated 0 0 0 0
Other 2 0 8 -8
Total 68 4072 3445 +627

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review merge-risk labels are merge-risk: 🚨 session-state.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Delivered automation output can be absent from the receiving conversation’s next model turn, breaking follow-up replies.
  • merge-risk: 🚨 session-state: The accepted change moves result ownership and removes existing awareness projections; persisted entries are not relocated by a revert.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Destination context changes what Telegram follow-up replies can use; the supplied Test Server runs exercise that behavior.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-11T16:45:34.004Z sha c407dec :: blocked before merge. :: [P1] Preserve required sandbox policy when creating the destination | [P1] Delay route persistence until the recipient is reached | [P2] Commit the effective delivered payload to destination history
  • reviewed 2026-10-11T17:31:53.974Z sha ac012cc :: needs changes before merge. :: [P2] Preserve spoken text when converting delivered payload summaries | [P2] Emit confirmed payloads from the delivery test fixtures
  • reviewed 2026-10-11T17:45:47.753Z sha 5409c0a :: needs changes before merge. :: [P3] Qualify the reset guarantee for implicit creator-bound delivery
  • reviewed 2026-10-11T18:00:09.030Z sha 667cce0 :: blocked before merge. :: [P1] Preserve creator-generation custody for implicit announcements
  • reviewed 2026-10-11T18:12:28.042Z sha 644fb2f :: blocked before merge. :: [P1] Fence implicit current-session delivery with its captured generation | [P1] Carry creator generation through command and script announcements

Reviewed October 11, 2026, 2:48 PM ET / 18:48 UTC (Revision 6).

scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
…absorb: step 57

openclaw#168996 "fix(cron): keep delivered results in the
destination conversation", isolated as its own step (+3 conflicts).
It removes recipient mirrors and creator-awareness notes and deletes
the cron delivery-outbound runtime barrel.

Conflicts:
- delivery-outbound.runtime.ts: deleted upstream; our only delta was the
  enqueueSystemEventRaw alias re-export. No cron code imports system
  events any more, so the deletion is taken.
- delivery-dispatch.double-announce.test.ts: took upstream's rewrite
  (2076 -> 1680 lines). Our line-cap helper
  delivery-dispatch.double-announce.test-support.ts (emptyParams,
  deletingRunParams) and the enqueueSystemEventRaw mock alias are
  obsolete and removed; the two mock-isolation annotations our side had
  (outbound send deps, system events) are re-applied so the mock-factory
  baseline stays shrink-only.
- test-mock-exports-baseline.txt: upstream's removals plus our 19
  removals (mock factory ratchet OK vs step 56).

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
…gain

Step 57 (5e55eb2) took upstream's openclaw#168996 rewrite of
delivery-dispatch.double-announce.test.ts and dropped our
enqueueSystemEventRaw mock export. The "real outbound retry outcomes"
suite loads the real cron run path, whose continuation modules import
system events under that name, so the suite failed to load: "No
"enqueueSystemEventRaw" export is defined on the mock", 5 cases skipped.

Both names now share one mock function, as they are one function in the
real module, so the suite's "not called" assertions cover both.

Pre-fix at 9a3022b: 67 passed | 5 skipped, file FAILED. Now 72/72.
Found by 🩸 Cael's review of 9a3022b.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime 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: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant