mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:58:28 +00:00
fix(auto-reply): move volatile inbound flags out of system metadata
Co-authored-by: aidiffuser <aidiffuser@users.noreply.github.com>
This commit is contained in:
@@ -16,9 +16,9 @@ export function buildInboundMetaSystemPrompt(ctx: TemplateContext): string {
|
||||
|
||||
// Keep system metadata strictly free of attacker-controlled strings (sender names, group subjects, etc.).
|
||||
// Those belong in the user-role "untrusted context" blocks.
|
||||
// Per-message identifiers (message_id, reply_to_id, sender_id) are also excluded here: they change
|
||||
// on every turn and would bust prefix-based prompt caches on local model providers. They are
|
||||
// included in the user-role conversation info block via buildInboundUserContextPrefix() instead.
|
||||
// Per-message identifiers and dynamic flags are also excluded here: they change on turns/replies
|
||||
// and would bust prefix-based prompt caches on providers that use stable system prefixes.
|
||||
// They are included in the user-role conversation info block instead.
|
||||
|
||||
// Resolve channel identity: prefer explicit channel, then surface, then provider.
|
||||
// For webchat/Hub Chat sessions (when Surface is 'webchat' or undefined with no real channel),
|
||||
@@ -43,14 +43,6 @@ export function buildInboundMetaSystemPrompt(ctx: TemplateContext): string {
|
||||
provider: safeTrim(ctx.Provider),
|
||||
surface: safeTrim(ctx.Surface),
|
||||
chat_type: chatType ?? (isDirect ? "direct" : undefined),
|
||||
flags: {
|
||||
is_group_chat: !isDirect ? true : undefined,
|
||||
was_mentioned: ctx.WasMentioned === true ? true : undefined,
|
||||
has_reply_context: Boolean(ctx.ReplyToBody),
|
||||
has_forwarded_context: Boolean(ctx.ForwardedFrom),
|
||||
has_thread_starter: Boolean(safeTrim(ctx.ThreadStarterBody)),
|
||||
history_count: Array.isArray(ctx.InboundHistory) ? ctx.InboundHistory.length : 0,
|
||||
},
|
||||
};
|
||||
|
||||
// Keep the instructions local to the payload so the meaning survives prompt overrides.
|
||||
@@ -92,7 +84,15 @@ export function buildInboundUserContextPrefix(ctx: TemplateContext): string {
|
||||
group_space: safeTrim(ctx.GroupSpace),
|
||||
thread_label: safeTrim(ctx.ThreadLabel),
|
||||
is_forum: ctx.IsForum === true ? true : undefined,
|
||||
is_group_chat: !isDirect ? true : undefined,
|
||||
was_mentioned: ctx.WasMentioned === true ? true : undefined,
|
||||
has_reply_context: ctx.ReplyToBody ? true : undefined,
|
||||
has_forwarded_context: ctx.ForwardedFrom ? true : undefined,
|
||||
has_thread_starter: safeTrim(ctx.ThreadStarterBody) ? true : undefined,
|
||||
history_count:
|
||||
Array.isArray(ctx.InboundHistory) && ctx.InboundHistory.length > 0
|
||||
? ctx.InboundHistory.length
|
||||
: undefined,
|
||||
};
|
||||
if (Object.values(conversationInfo).some((v) => v !== undefined)) {
|
||||
blocks.push(
|
||||
|
||||
Reference in New Issue
Block a user