Skip to content

fix: canonicalize topic session transcript fallback#64869

Merged
jalehman merged 2 commits intomainfrom
josh/fix-topic-session-file-canonicalization
Apr 11, 2026
Merged

fix: canonicalize topic session transcript fallback#64869
jalehman merged 2 commits intomainfrom
josh/fix-topic-session-file-canonicalization

Conversation

@jalehman
Copy link
Copy Markdown
Contributor

What

Fix OpenClaw session initialization so topic-scoped sessions keep using the topic-qualified transcript path even when an inbound turn does not carry MessageThreadId.

Why

We traced LCM session-history loss to OpenClaw alternating between <session-id>.jsonl and <session-id>-topic-<n>.jsonl for the same Telegram topic session. That made one logical session look like two transcript files and triggered session-file rotation handling downstream.

Changes

  • Parse thread id from SessionKey during session init fallback
  • Keep topic-qualified transcript paths without MessageThreadId
  • Add regression coverage for topic session init fallback

Testing

  • pnpm -C /Users/phaedrus/Projects/openclaw exec vitest run src/auto-reply/reply/session.test.ts -t "records topic-specific session files" --reporter=verbose
  • pnpm -C /Users/phaedrus/Projects/openclaw exec vitest run src/auto-reply/reply/session.test.ts --reporter=dot

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Apr 11, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 11, 2026

Greptile Summary

This PR fixes a session transcript file path inconsistency for Telegram topic sessions. When an inbound turn lacks MessageThreadId, the code now falls back to extracting the thread ID from SessionKey via parseSessionThreadInfo, so the transcript always uses the topic-qualified path (<id>-topic-<n>.jsonl) instead of alternating between the topic and plain paths.

Confidence Score: 5/5

Safe to merge — targeted fix for a well-understood data-path bug with matching regression coverage.

The change is minimal and correctly uses the existing parseSessionThreadInfo helper. The ?? fallback ensures MessageThreadId still takes precedence; the new path only activates when it is absent. Both tests are well-structured with proper cleanup. No P0/P1 findings.

No files require special attention.

Reviews (1): Last reviewed commit: "fix: canonicalize topic session transcri..." | Re-trigger Greptile

@jalehman jalehman self-assigned this Apr 11, 2026
When initSessionState has a topic-scoped SessionKey but no MessageThreadId, fallback transcript selection should still land on the topic-qualified JSONL path instead of the bare session file. Match the existing transcript resolver by parsing the thread id from the session key, and cover the regression with a session init test that loads the Telegram session-conversation grammar.

Regeneration-Prompt: |
  Investigate why a Telegram topic session could alternate between <session-id>.jsonl and <session-id>-topic-<n>.jsonl for the same logical session. The fix should be in OpenClaw's session initialization path, not in lossless-claw. Keep behavior unchanged when MessageThreadId is present, but when the inbound turn only carries a topic-scoped SessionKey, derive the same topic-specific transcript path that the canonical transcript resolver would use. Add a regression test that proves initSessionState chooses the topic-qualified file even without MessageThreadId, and make the test load the session-conversation registry needed to parse Telegram :topic: grammar.
@jalehman jalehman force-pushed the josh/fix-topic-session-file-canonicalization branch from 58535ee to 539b090 Compare April 11, 2026 16:03
@jalehman jalehman merged commit 77a0ee7 into main Apr 11, 2026
41 checks passed
@jalehman jalehman deleted the josh/fix-topic-session-file-canonicalization branch April 11, 2026 16:06
amittell pushed a commit to amittell/openclaw that referenced this pull request Apr 11, 2026
* fix: canonicalize topic session transcript fallback

When initSessionState has a topic-scoped SessionKey but no MessageThreadId, fallback transcript selection should still land on the topic-qualified JSONL path instead of the bare session file. Match the existing transcript resolver by parsing the thread id from the session key, and cover the regression with a session init test that loads the Telegram session-conversation grammar.

Regeneration-Prompt: |
  Investigate why a Telegram topic session could alternate between <session-id>.jsonl and <session-id>-topic-<n>.jsonl for the same logical session. The fix should be in OpenClaw's session initialization path, not in lossless-claw. Keep behavior unchanged when MessageThreadId is present, but when the inbound turn only carries a topic-scoped SessionKey, derive the same topic-specific transcript path that the canonical transcript resolver would use. Add a regression test that proves initSessionState chooses the topic-qualified file even without MessageThreadId, and make the test load the session-conversation registry needed to parse Telegram :topic: grammar.

* fix: preserve topic session transcript history
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* fix: canonicalize topic session transcript fallback

When initSessionState has a topic-scoped SessionKey but no MessageThreadId, fallback transcript selection should still land on the topic-qualified JSONL path instead of the bare session file. Match the existing transcript resolver by parsing the thread id from the session key, and cover the regression with a session init test that loads the Telegram session-conversation grammar.

Regeneration-Prompt: |
  Investigate why a Telegram topic session could alternate between <session-id>.jsonl and <session-id>-topic-<n>.jsonl for the same logical session. The fix should be in OpenClaw's session initialization path, not in lossless-claw. Keep behavior unchanged when MessageThreadId is present, but when the inbound turn only carries a topic-scoped SessionKey, derive the same topic-specific transcript path that the canonical transcript resolver would use. Add a regression test that proves initSessionState chooses the topic-qualified file even without MessageThreadId, and make the test load the session-conversation registry needed to parse Telegram :topic: grammar.

* fix: preserve topic session transcript history
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* fix: canonicalize topic session transcript fallback

When initSessionState has a topic-scoped SessionKey but no MessageThreadId, fallback transcript selection should still land on the topic-qualified JSONL path instead of the bare session file. Match the existing transcript resolver by parsing the thread id from the session key, and cover the regression with a session init test that loads the Telegram session-conversation grammar.

Regeneration-Prompt: |
  Investigate why a Telegram topic session could alternate between <session-id>.jsonl and <session-id>-topic-<n>.jsonl for the same logical session. The fix should be in OpenClaw's session initialization path, not in lossless-claw. Keep behavior unchanged when MessageThreadId is present, but when the inbound turn only carries a topic-scoped SessionKey, derive the same topic-specific transcript path that the canonical transcript resolver would use. Add a regression test that proves initSessionState chooses the topic-qualified file even without MessageThreadId, and make the test load the session-conversation registry needed to parse Telegram :topic: grammar.

* fix: preserve topic session transcript history
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
* fix: canonicalize topic session transcript fallback

When initSessionState has a topic-scoped SessionKey but no MessageThreadId, fallback transcript selection should still land on the topic-qualified JSONL path instead of the bare session file. Match the existing transcript resolver by parsing the thread id from the session key, and cover the regression with a session init test that loads the Telegram session-conversation grammar.

Regeneration-Prompt: |
  Investigate why a Telegram topic session could alternate between <session-id>.jsonl and <session-id>-topic-<n>.jsonl for the same logical session. The fix should be in OpenClaw's session initialization path, not in lossless-claw. Keep behavior unchanged when MessageThreadId is present, but when the inbound turn only carries a topic-scoped SessionKey, derive the same topic-specific transcript path that the canonical transcript resolver would use. Add a regression test that proves initSessionState chooses the topic-qualified file even without MessageThreadId, and make the test load the session-conversation registry needed to parse Telegram :topic: grammar.

* fix: preserve topic session transcript history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant