Skip to content

fix: preserve cron session transcript rotation#82200

Merged
steipete merged 2 commits into
mainfrom
fix/cron-session-target-compaction-continuity
May 15, 2026
Merged

fix: preserve cron session transcript rotation#82200
steipete merged 2 commits into
mainfrom
fix/cron-session-target-compaction-continuity

Conversation

@steipete

@steipete steipete commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve cron run transcript rotations by adopting the embedded runner's final session id/file before persisting session-bound scheduled runs.
  • Carry the active session file through embedded error metadata so compact-then-fail cron runs also persist the rotated transcript identity.
  • Add focused regression coverage for session-bound cron persistence and embedded error metadata.

Fixes #82164.

Verification

  • /Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-review --parallel-tests "node scripts/run-vitest.mjs src/cron/isolated-agent.session-identity.test.ts src/cron/isolated-agent/run-session-state.test.ts src/agents/pi-embedded-runner/run/helpers.test.ts"
  • node scripts/run-vitest.mjs src/cron/isolated-agent.session-identity.test.ts src/cron/isolated-agent/run-session-state.test.ts src/agents/pi-embedded-runner/run/helpers.test.ts
  • git diff --check

Real behavior proof

Behavior addressed: session-bound cron runs with transcript rotation now persist the rotated session id and session file before the next user turn.
Real environment tested: maintainer source checkout. Maintainer override applies because the exact regression path is covered with the cron runner and embedded runner test harness; no external chat credentials were exercised.
Exact steps or command run after this patch: node scripts/run-vitest.mjs src/cron/isolated-agent.session-identity.test.ts src/cron/isolated-agent/run-session-state.test.ts src/agents/pi-embedded-runner/run/helpers.test.ts
Evidence after fix: terminal output showed Test Files 3 passed (3) and Tests 19 passed (19) for the focused cron session identity, cron session-state, and embedded runner helper tests. Codex review then reported codex-review clean: no accepted/actionable findings reported.
Observed result after fix: the persisted session store entry keeps sessionId as the rotated id and sessionFile as the rotated transcript for session-bound cron runs; embedded error metadata now also carries the active session file after transcript rotation.
What was not tested: live scheduled run against a real external chat channel.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels May 15, 2026
@steipete steipete added the proof: override Maintainer override for the external PR real behavior proof gate. label May 15, 2026
@clawsweeper

clawsweeper Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adopts rotated embedded-runner session id/file metadata before cron session persistence, propagates sessionFile through embedded error metadata, and adds focused regression tests plus a changelog entry.

Reproducibility: yes. at source level: the docs define current as context-aware, and current main persists the cron session entry without adopting rotated embedded-runner session id/file metadata before the next user turn. I did not run a live Telegram flow.

Real behavior proof
Override: A maintainer applied proof: override for this PR.

Next step before merge
Protected maintainer label and proof override make this a human merge/CI decision, not a ClawSweeper repair task.

Security
Cleared: The diff changes cron/session metadata propagation, tests, and changelog only; I found no dependency, workflow, secret, install, or code-download risk.

Review details

Best possible solution:

Land this PR after maintainer review and CI, then close #82164 as fixed by the merged cron/session identity change.

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

Yes, at source level: the docs define current as context-aware, and current main persists the cron session entry without adopting rotated embedded-runner session id/file metadata before the next user turn. I did not run a live Telegram flow.

Is this the best way to solve the issue?

Yes: adopting the embedded runner's final session id/file at cron finalization is the narrowest maintainable fix, and carrying sessionFile through error metadata covers compact-then-fail paths without channel-specific policy.

Acceptance criteria:

  • node scripts/run-vitest.mjs src/cron/isolated-agent.session-identity.test.ts src/cron/isolated-agent/run-session-state.test.ts src/agents/pi-embedded-runner/run/helpers.test.ts
  • git diff --check

What I checked:

  • Protected PR state: The provided GitHub context shows labels maintainer and proof: override, so conservative cleanup should not close this PR and the real-behavior proof gate is explicitly overridden.
  • Current main persistence path: On current main, finalizeCronRun reads finalRunResult.meta?.agentMeta for usage/model/CLI-session data and then calls prepared.persistSessionEntry(), but it does not adopt agentMeta.sessionId or agentMeta.sessionFile into the cron session entry before persistence. (src/cron/isolated-agent/run.ts:852, 29b5563ccda2)
  • Current main reports the original run id: prepareCronRunContext captures runSessionId before execution and current main's withRunSession returns that original value, so a rotated transcript identity is not reflected in the final cron result. (src/cron/isolated-agent/run.ts:581, 29b5563ccda2)
  • Documented cron contract: The cron docs describe current as bound at creation time for context-aware recurring work and direct users to current or session:<id> when a recurring job should build on the same conversation context. Public docs: docs/automation/cron-jobs.md. (docs/automation/cron-jobs.md:91, 29b5563ccda2)
  • Embedded runner metadata contract: EmbeddedPiAgentMeta already includes optional sessionFile, and the successful embedded-runner path reports both sessionId and sessionFile, which supports using that metadata during cron finalization. (src/agents/pi-embedded-runner/types.ts:10, 29b5563ccda2)
  • PR adoption path: The PR diff adds adoptCronRunSessionMetadata, normalizes run metadata, updates session id/file plus usage-family ids, and calls it from finalizeCronRun before persistence. (src/cron/isolated-agent/run-session-state.ts:66, 34c0354af3fa)

Likely related people:

  • steipete: Current-main history shows Peter Steinberger recently touched the cron runtime path and introduced the current session persistence helper surface that this PR updates. (role: recent area contributor; confidence: high; commits: 38e53a89b256, b4f6cb29b846; files: src/cron/isolated-agent/run.ts, src/cron/isolated-agent/run-session-state.ts, src/agents/pi-embedded-runner/run/helpers.ts)
  • jalehman: Josh Lehman authored prior cron context-engine/session-key work across the same isolated-agent session-state and runner files, making him a useful secondary reviewer for session continuity semantics. (role: feature-history contributor; confidence: medium; commits: a3c51f91c58a, 4004c9342d7d; files: src/cron/isolated-agent/run-session-state.ts, src/cron/isolated-agent/run.ts, src/agents/pi-embedded-runner/run.ts)

Remaining risk / open question:

  • I did not run the focused Vitest files or a live scheduled chat flow in this read-only review; the PR body reports focused test output and the maintainer proof override covers the real-behavior gate.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 29b5563ccda2.

@steipete steipete merged commit 65dd71d into main May 15, 2026
86 of 91 checks passed
@steipete steipete deleted the fix/cron-session-target-compaction-continuity branch May 15, 2026 16:00
@steipete

Copy link
Copy Markdown
Contributor Author

Landed via squash merge onto main.

  • Local proof: node scripts/run-vitest.mjs src/cron/isolated-agent.session-identity.test.ts src/cron/isolated-agent/run-session-state.test.ts src/agents/pi-embedded-runner/run/helpers.test.ts (3 files, 19 tests)
  • Review: codex-review clean: no accepted/actionable findings reported
  • PR head before squash: 9786627f468a6f02c82a90bfdc977aaee7228225
  • Code commit in PR: 34c0354af3fa4d62762736fb9c69507e93fc5be5
  • Merge commit: 65dd71d42deea2e7af3b18f3cdabbff517cec3b0

Thanks @weissfl!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix: preserve cron session transcript rotation

* chore: refresh pr checks
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix: preserve cron session transcript rotation

* chore: refresh pr checks
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
* fix: preserve cron session transcript rotation

* chore: refresh pr checks
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix: preserve cron session transcript rotation

* chore: refresh pr checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR proof: override Maintainer override for the external PR real behavior proof gate. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: sessionTarget "current" cron job silently resets the bound chat session

1 participant