fix(auto-reply): RawBody command parsing + safer usage save#643
fix(auto-reply): RawBody command parsing + safer usage save#643mcinteerj wants to merge 5 commits intoopenclaw:mainfrom
Conversation
WhatsApp group messages include structural context (history, sender labels) in the Body field for LLM context. This caused command detection to fail when the formatted body did not match exact command strings like "/status". Changes: - Add RawBody field to MsgContext for clean message text - WhatsApp gateway sets RawBody to msg.body (original Baileys message) - Command detection, directive parsing, abort detection, and reset triggers now prefer RawBody over Body - BodyStripped falls back to RawBody before Body This separates concerns: Body carries formatted LLM context, RawBody carries clean text for command matching. Tests: - session.test.ts: RawBody extraction, reset triggers, fallback - abort.test.ts: /stop detection, bare word triggers - reply.raw-body.test.ts: /think, /model, /status directive parsing Related: openclaw#638 (RFC: Structured MsgContext and Decomposition of CombinedBody) Note: Discord has a similar combinedBody pattern that may need the same fix.
|
Thanks Jake! |
|
Pushed follow-up fix (3a32cde): keeps combined prompt context in Body/BodyStripped while using RawBody for command/directive parsing (prevents dropping the history wrapper). Also ran biome formatting so CI lint is green.\n\nLocal gate: pnpm lint && pnpm test && pnpm build. |
|
More cleanup + concurrency fix pushed:\n\n- 8451b08: Discord now sets MsgContext.RawBody (message.content/placeholder) so commands/directives don’t get confused by the combined history wrapper.\n- 5852ef6: Replace reload-before-save with a real lock+merge helper (updateSessionStoreEntry) and use it for usage/model persistence in agent-runner + followup-runner; adds regression test + docs {{RawBody}}. |
|
Landed on main via e3cd431 (squash/manual). Thanks @mcinteerj!\n\nNotes: = provider-raw inbound text used for command/directive parsing; keeps history+wrapper for LLM context. Session store updates now use lock+merge+save to avoid clobbering concurrent writers. |
|
Landed on Clarify:
Thanks @mcinteerj! |
Fixes two auto-reply reliability issues:\n\n1) WhatsApp group messages: introduce MsgContext.RawBody (clean message text) and prefer it for command/directive/abort/reset parsing. Keep Body/BodyStripped as the best-available prompt text (may include structural context/history).\n\n2) Fallback runs: reload the session store from disk immediately before persisting usage/model info to reduce clobbering concurrent session updates (e.g. /model during a long run).\n\nIncludes tests covering RawBody parsing and abort/reset triggers.