fix(cli-session): only hash static extraSystemPrompt for session reuse · openclaw/openclaw@d1c4143
2026-04-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -107,7 +107,11 @@ export async function prepareCliRunContext(
|
107 | 107 | authCredential = authStore.profiles[effectiveAuthProfileId]; |
108 | 108 | } |
109 | 109 | const extraSystemPrompt = params.extraSystemPrompt?.trim() ?? ""; |
110 | | -const extraSystemPromptHash = hashCliSessionText(extraSystemPrompt); |
| 110 | +// Use the static portion (excluding per-message inbound metadata) for session reuse hashing. |
| 111 | +// Per-message metadata (timestamps, message IDs) changes every turn and must not trigger session resets. |
| 112 | +const extraSystemPromptHash = hashCliSessionText(params.extraSystemPromptStatic?.trim() || undefined) ?? hashCliSessionText(extraSystemPrompt); |
| 113 | + |
| 114 | + |
111 | 115 | const modelId = (params.model ?? "default").trim() || "default"; |
112 | 116 | const normalizedModel = normalizeCliModel(modelId, backendResolved.config); |
113 | 117 | const modelDisplay = `${params.provider}/${modelId}`; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,8 @@ export type RunCliAgentParams = {
|
23 | 23 | timeoutMs: number; |
24 | 24 | runId: string; |
25 | 25 | extraSystemPrompt?: string; |
| 26 | +/** Static portion of extraSystemPrompt (excluding per-message inbound metadata) for session reuse hashing. */ |
| 27 | +extraSystemPromptStatic?: string; |
26 | 28 | streamParams?: import("../command/types.js").AgentStreamParams; |
27 | 29 | ownerNumbers?: string[]; |
28 | 30 | cliSessionId?: string; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -305,6 +305,18 @@ export async function runPreparedReply(
|
305 | 305 | fullAccessBlockedReason: fullAccessState.blockedReason, |
306 | 306 | }), |
307 | 307 | ].filter(Boolean); |
| 308 | +// Static parts only (no per-message inbound metadata) for CLI session reuse hashing. |
| 309 | +const extraSystemPromptStaticParts = [ |
| 310 | +groupChatContext, |
| 311 | +groupIntro, |
| 312 | +groupSystemPrompt, |
| 313 | +buildExecOverridePromptHint({ |
| 314 | + execOverrides, |
| 315 | +elevatedLevel: resolvedElevatedLevel, |
| 316 | +fullAccessAvailable: fullAccessState.available, |
| 317 | +fullAccessBlockedReason: fullAccessState.blockedReason, |
| 318 | +}), |
| 319 | +].filter(Boolean); |
308 | 320 | const baseBody = sessionCtx.BodyStripped ?? sessionCtx.Body ?? ""; |
309 | 321 | // Use CommandBody/RawBody for bare reset detection (clean message without structural context). |
310 | 322 | const rawBodyTrimmed = (ctx.CommandBody ?? ctx.RawBody ?? ctx.Body ?? "").trim(); |
@@ -734,6 +746,7 @@ export async function runPreparedReply(
|
734 | 746 | ownerNumbers: command.ownerList.length > 0 ? command.ownerList : undefined, |
735 | 747 | inputProvenance: ctx.InputProvenance ?? sessionCtx.InputProvenance, |
736 | 748 | extraSystemPrompt: extraSystemPromptParts.join("\n\n") || undefined, |
| 749 | +extraSystemPromptStatic: extraSystemPromptStaticParts.join("\n\n") || undefined, |
737 | 750 | skipProviderRuntimeHints: useFastReplyRuntime, |
738 | 751 | ...(!useFastReplyRuntime && |
739 | 752 | isReasoningTagProvider(provider, { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。