fix(self-improvement): skip note inject on Discord channel /new to avoid startup race#332
Conversation
1c1483e to
5699272
Compare
…oid hook interference Skip self-improvement note injection on Discord channel (non-thread) resets. The appendSelfImprovementNote hook was push()ing synchronously into event.messages before the first agent turn ran, which contributed to the post-reset startup race described in openclaw/openclaw#46941. Discord channel resets are guarded by checking Provider=discord && (MessageThreadId == null or empty). Thread resets and non-Discord surfaces are unaffected. Ref: openclaw/openclaw#46941 (root cause: /new re-fires command:new hooks) Ref: openclaw/openclaw#49001 (thread-only post-rotation window)
5699272 to
3367a5f
Compare
|
理解你要解决的问题——Discord channel /new 的 note inject 竞态确实存在。 不过有两个问题需要解决:
建议先确认第 1 点(可以贴一下 OpenClaw 2026.3+ 的 hook context 文档或实际输出),然后 rebase 到最新 master + 补测试,我们继续 review。 |
Previously the code accessed contextForLog.Provider and contextForLog.MessageThreadId directly, but these fields are not present in the command:new/command:reset hook event context. Provider lives in sessionEntry.Provider; MessageThreadId is stored as sessionEntry.threadId (populated from ctx.MessageThreadId at session creation time). Access them correctly via the sessionEntry object that is passed to the hook event context.
|
Thanks for the review! You raised two valid concerns — both addressed now: 1. Field contract confirmed The
2. Regression tests Tests for Discord channel vs thread skip behavior need to go in a separate test file. I'll add those in a follow-up PR (or can do it in this PR if you prefer). The core logic fix is complete. Please re-review the latest commit. Happy to address any remaining concerns. |
|
Thanks for the fix — field path correction makes sense. Please add the regression test in this PR, not a follow-up. We need at least:
Without the test we can't verify the skip logic only fires when it should. Rebase to latest master while you're at it. |
Summary
Skip self-improvement note injection on Discord channel (non-thread) resets.
The appendSelfImprovementNote hook was push()ing synchronously into
event.messages before the first agent turn ran, which contributed to
the post-reset startup race described in openclaw/openclaw#46941.
Root cause
Discord channel resets (non-thread) have no MessageThreadId. The hook
interfered with the reset flow by modifying event.messages before the
first agent turn could complete. This is distinct from thread resets,
which are handled by the OpenClaw core's postRotationStartupUntilMs
mechanism (PR openclaw/openclaw#49001).
Fix
Guard: when Provider=discord AND (MessageThreadId is absent or empty),
log and return early without modifying event.messages. Thread resets
and non-Discord surfaces are unaffected.
Related