fix(agents): preserve trailing assistant session history#76280
fix(agents): preserve trailing assistant session history#76280jalehman wants to merge 2 commits intoopenclaw:mainfrom
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. Current main can be reproduced statically with a JSONL session ending in a plain assistant message: Next step before merge Security Review detailsBest possible solution: Keep normal assistant final replies in stored session history while preserving provider-specific outbound prefill stripping; land after maintainer review and a rebase/merge that keeps the current debug logging behavior. Do we have a high-confidence way to reproduce the issue? Yes. Current main can be reproduced statically with a JSONL session ending in a plain assistant message: Is this the best way to solve the issue? Yes, directionally. Removing persistent disk trimming is the narrowest fix for transcript history loss because current main already has outbound Anthropic/Gemini prefill stripping at the stream boundary; the final branch should preserve the newer debug logging change. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 7f83ba8ddf84. |
What
Preserves delivered assistant final replies in session JSONL repair instead of trimming every plain trailing assistant message from disk.
Why
The 2026.5.2 session repair path was trimming healthy assistant finals before subsequent runs. In live Telegram/heartbeat sessions this repeatedly erased valid replies like
HEARTBEAT_OKand status responses, producing noisy repair warnings and losing transcript history.Changes
Testing
pnpm test src/agents/session-file-repair.test.ts src/agents/pi-embedded-runner/run/attempt.test.tsgit diff --checksession file repaired: trimmed ... trailing assistantlogs after running on this commit and sending turns