diff --git a/CHANGELOG.md b/CHANGELOG.md index c58b04fc3c4..352fce0f514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Docs: https://docs.openclaw.ai ### Fixes +- Agents/compaction safeguard pre-check: skip embedded compaction before entering the Pi SDK when a session has no real conversation messages, avoiding unnecessary LLM API calls on idle sessions. (#36451) thanks @Sid-Qin. - iMessage/cron completion announces: strip leaked inline reply tags (for example `[[reply_to:6100]]`) from user-visible completion text so announcement deliveries do not expose threading metadata. (#24600) Thanks @vincentkoc. - Feishu/group slash command detection: normalize group mention wrappers before command-authorization probing so mention-prefixed commands (for example `@Bot/model` and `@Bot /reset`) are recognized as gateway commands instead of being forwarded to the agent. (#35994) Thanks @liuxiaopai-ai. - Agents/context pruning: guard assistant thinking/text char estimation against malformed blocks (missing `thinking`/`text` strings or null entries) so pruning no longer crashes with malformed provider content. (openclaw#35146) thanks @Sid-Qin. diff --git a/src/agents/pi-embedded-runner/compact.ts b/src/agents/pi-embedded-runner/compact.ts index 2fc622c842b..83b98f532d4 100644 --- a/src/agents/pi-embedded-runner/compact.ts +++ b/src/agents/pi-embedded-runner/compact.ts @@ -132,6 +132,10 @@ type CompactionMessageMetrics = { contributors: Array<{ role: string; chars: number; tool?: string }>; }; +function hasRealConversationContent(msg: AgentMessage): boolean { + return msg.role === "user" || msg.role === "assistant" || msg.role === "toolResult"; +} + function createCompactionDiagId(): string { return `cmp-${Date.now().toString(36)}-${generateSecureToken(4)}`; } @@ -663,6 +667,17 @@ export async function compactEmbeddedPiSessionDirect( ); } + if (!session.messages.some(hasRealConversationContent)) { + log.info( + `[compaction] skipping — no real conversation messages (sessionKey=${params.sessionKey ?? params.sessionId})`, + ); + return { + ok: true, + compacted: false, + reason: "no real conversation messages", + }; + } + const compactStartedAt = Date.now(); const result = await compactWithSafetyTimeout(() => session.compact(params.customInstructions),