Skip to content

fix(cron): mirror synthesized text back to session transcript on direct delivery#11

Open
suboss87 wants to merge 51 commits into
mainfrom
fix/74743-cron-mirror-session-transcript
Open

fix(cron): mirror synthesized text back to session transcript on direct delivery#11
suboss87 wants to merge 51 commits into
mainfrom
fix/74743-cron-mirror-session-transcript

Conversation

@suboss87
Copy link
Copy Markdown
Owner

@suboss87 suboss87 commented Apr 30, 2026

Closes openclaw#74743

Problem

When a cron job targets a session via --session session:<sessionId>, the agent turn runs inside that session and delivers its output to the configured channel. However, the delivered text is never written back to the session transcript. On the next turn the agent has no memory of what it last said -- effectively losing the conversation history for cron-driven sessions.

Root cause

deliverViaDirect in src/cron/isolated-agent/delivery-dispatch.ts called deliverOutboundPayloads without the mirror parameter. The mirror param is what triggers appendAssistantMessageToSessionTranscript in src/infra/outbound/deliver.ts (line 819). Without it, delivery succeeds but the session transcript is never updated.

Fix

Pass mirror: { sessionKey: params.agentSessionKey, agentId: params.agentId, text: synthesizedText } to deliverOutboundPayloads when synthesizedText is non-empty. When synthesizedText is empty no delivery occurs at all (the payloadsForDelivery.length === 0 guard returns early), so mirror is correctly omitted in that case.

Tests

Added two tests to delivery-dispatch.double-announce.test.ts:

  • passes mirror param with agentSessionKey and synthesizedText so transcript is updated -- verifies deliverOutboundPayloads receives mirror: { sessionKey, agentId, text } with the correct values
  • skips delivery entirely when synthesizedText is empty (no spurious transcript write) -- verifies that an empty synthesizedText results in zero deliverOutboundPayloads calls (the early-return guard is hit first)

All 13 tests in the file pass.


Generated by Claude Code


Open in Devin Review

claude added 30 commits April 1, 2026 15:34
claude and others added 21 commits April 18, 2026 03:46
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Custom session cron jobs do not persist in destination session.

2 participants