Skip to content

Sessions: parse thread suffixes by channel - #58100

Merged
gumadeiras merged 3 commits into
mainfrom
codex/thread-suffix-fix
Mar 31, 2026
Merged

gumadeiras merged 3 commits into
mainfrom
codex/thread-suffix-fix

Conversation

@gumadeiras

Copy link
Copy Markdown
Member

Summary

  • fix shared session-thread suffix parsing to respect channel semantics
  • preserve Feishu conversation IDs that legitimately contain embedded :topic:
  • keep Telegram :topic: suffix parsing and add regressions around announce/reset/session-key consumers

Testing

  • pnpm test -- src/agents/tools/sessions-send-helpers.test.ts src/config/sessions/delivery-info.test.ts src/config/sessions/reset.test.ts src/routing/session-key.test.ts
  • pnpm check

Copilot AI review requested due to automatic review settings March 31, 2026 03:15
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Mar 31, 2026
@greptile-apps

greptile-apps Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a long-standing bug where :topic: in a session key was unconditionally treated as a thread-suffix delimiter for all channels. Since Feishu legitimately embeds :topic:TopicId:sender:UserId inside its group conversation IDs, the old logic was incorrectly splitting those IDs and producing wrong baseSessionKey and threadId values everywhere the parsing was used (announce-target resolution, session-reset type classification, model-selection parent lookup, transcript delivery, etc.).

Key changes:

  • Introduces parseThreadSessionSuffix in session-key-utils.ts with a channelHint parameter; :topic: is now only recognized as a thread suffix when the inferred or explicit channel is telegram.
  • inferThreadSuffixChannelHint auto-detects the channel from agent:AGENTID:CHANNEL:… and legacy non-prefixed key formats, so callers that don't supply an explicit hint still work correctly.
  • parseSessionThreadInfo (delivery-info.ts) becomes a thin wrapper that delegates to the new function.
  • isThreadSessionKey (reset.ts) now derives its answer from parseThreadSessionSuffix, replacing the previous simple substring scan.
  • resolveAnnounceTargetFromKey (sessions-send-helpers.ts) passes the already-extracted channelRaw as channelHint, ensuring channel-local parsing even when the rest-joined key has no agent prefix.
  • New regression tests cover Feishu embedded-topic preservation, Telegram :topic: thread parsing, and session-reset type detection.

Confidence Score: 5/5

Safe to merge — the fix is targeted and well-tested, with no logic errors found across all impacted call sites.

The change is a focused correctness fix that replaces a global string-scan with a channel-aware parse. All existing callers delegate to the new function and gain the fix automatically. The PR adds targeted regression tests for every affected consumer. No P0/P1 issues were found.

No files require special attention.

Reviews (1): Last reviewed commit: "Sessions: parse thread suffixes by chann..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates session thread-suffix parsing so that :topic: is only treated as a thread marker for Telegram, preventing false positives for other channels (notably Feishu conversation IDs that legitimately embed :topic:).

Changes:

  • Introduce parseThreadSessionSuffix() in session-key-utils to parse :thread: universally and :topic: only for Telegram (using a channel hint or inferred channel).
  • Switch thread detection/consumers (reset logic, delivery-info parsing, announce target parsing) to use the new shared parsing helper.
  • Add regression tests covering Feishu embedded :topic: and Telegram :topic: suffix behavior across key consumers.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/sessions/session-key-utils.ts Adds channel-aware thread/topic suffix parsing and refactors parent-key resolution to use it.
src/routing/session-key.test.ts Adds focused unit tests for thread suffix parsing and parent resolution (Feishu + Telegram).
src/config/sessions/reset.ts Updates thread-session detection to use the shared parsing helper.
src/config/sessions/reset.test.ts Adds regression tests for Feishu vs Telegram thread detection in reset logic.
src/config/sessions/delivery-info.ts Reuses the shared parsing helper for extracting base/thread IDs.
src/config/sessions/delivery-info.test.ts Extends delivery-info tests to cover Feishu embedded :topic: preservation.
src/agents/tools/sessions-send-helpers.ts Uses shared parsing with an explicit channel hint when resolving announce targets.
src/agents/tools/sessions-send-helpers.test.ts Adds a Feishu regression case for announce target parsing with embedded :topic:.

Comment thread src/sessions/session-key-utils.ts Resolved
@gumadeiras gumadeiras self-assigned this Mar 31, 2026
@gumadeiras
gumadeiras force-pushed the codex/thread-suffix-fix branch from 7152a36 to 2829b9c Compare March 31, 2026 12:53
@gumadeiras
gumadeiras merged commit 4ea1ca4 into main Mar 31, 2026
11 checks passed
@gumadeiras
gumadeiras deleted the codex/thread-suffix-fix branch March 31, 2026 12:54
@gumadeiras

Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @gumadeiras!

singleGanghood pushed a commit to singleGanghood/openclaw that referenced this pull request Mar 31, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
vincentkoc pushed a commit that referenced this pull request Mar 31, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
steipete pushed a commit to Mlightsnow/openclaw that referenced this pull request Apr 1, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
Merged via squash.

Prepared head SHA: 2829b9c
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
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 size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants