Repository navigation
Conversation
…en session pre-created When replyToMode='all', the bot's outbound reply calls recordSessionMetaFromInbound which pre-creates the thread session entry before any user message arrives. This makes isNewSession=false when the user's first thread reply is processed, so forkSessionFromParent() is never called — even with inheritParent: true. Replace the isNewSession gate with a forkedFromParent session flag that tracks whether the fork has been attempted. This allows the fork to fire on the first user message regardless of whether the session entry was pre-created by outbound delivery. Also add logging to forkSessionFromParent's catch block, which previously swallowed all errors silently. Fixes openclaw#4927 Related: openclaw#23037, openclaw#12742, openclaw#12586
Taskle
force-pushed
the
fix/thread-fork-gate-4927
branch
2 times, most recently
from
February 22, 2026 02:09
5a45b73 to
dad1d36
Compare
Two gates block thread history on subsequent turns: 1. prepare.ts: `!threadSessionPreviousTimestamp` condition skips the thread history fetch when the session already has a stored timestamp (i.e. every turn after the first). 2. get-reply-run.ts: `isNewSession &&` condition discards the fetched thread history body when injecting it into the prompt on non-new sessions. Remove both gates so thread context is fetched and injected on every turn, giving the agent sliding-window thread awareness.
Taskle
force-pushed
the
fix/thread-fork-gate-4927
branch
from
February 22, 2026 02:24
dad1d36 to
6a3a99c
Compare
Contributor
Author
|
The checks-windows (node, test) failure is not related to this PR — it's a pre-existing bug in src/memory/qmd-manager.test.ts where the test hardcodes Unix-style path separators (/agents/main/qmd/xdg-config) but Windows resolves with backslashes. Same test is failing on at least 7 other unrelated PRs (#23134, #23131, #23118, #23117, #23112, #23110, #23108). All Linux/bun/node checks pass |
This was referenced Feb 22, 2026
Member
|
Consolidated into #23843 to land this as a focused continuity fix on current This keeps the three thread-session gates in one mergeable PR:
Closing as superseded. |
Member
|
Superseded by #23843. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Thread sessions in Slack DMs are fundamentally broken. Agents lose all thread context after the first turn, making threaded conversations unusable.
Root Cause
Three independent gates conspire to break thread sessions:
1. Session fork gate (
initSessionState)The
forkSessionFromParentcall is gated byisNewSession, but the session is always pre-created by the outbound reply handler beforeinitSessionStateruns. SoisNewSessionis alwaysfalsefor thread sessions, and forking never fires.Fix: Track
forkedFromParentflag on the session entry. Gate on!alreadyForkedinstead ofisNewSession.2. Thread history fetch gate (
prepare.ts)The
!threadSessionPreviousTimestampcondition means thread history is only fetched on the very first turn. Once the session exists and has a stored timestamp, this gate blocks all subsequent fetches.Fix: Remove
&& !threadSessionPreviousTimestamp— always fetch the last N messages.3. Thread history injection gate (
get-reply-run.ts)The
isNewSession &&condition discards fetched thread history when building the prompt on non-new sessions. Even if history was successfully fetched, it is thrown away.Fix: Remove
isNewSession &&— always inject thread context when available.Changes
src/auto-reply/session/init-session-state.tsforkedFromParentflag, gate fork on!alreadyForkedinstead ofisNewSession, add error loggingsrc/slack/monitor/message-handler/prepare.ts!threadSessionPreviousTimestampfrom fetch gatesrc/auto-reply/reply/get-reply-run.tsisNewSession &&from injection gateTesting
Validated on a live OpenClaw instance with monkeypatched dist: