diff --git a/frontend/src/lib/components/flows/content/AgentHistoryInput.svelte b/frontend/src/lib/components/flows/content/AgentHistoryInput.svelte index 24b82ef7e9..3825228bf0 100644 --- a/frontend/src/lib/components/flows/content/AgentHistoryInput.svelte +++ b/frontend/src/lib/components/flows/content/AgentHistoryInput.svelte @@ -16,6 +16,9 @@ chatInputEnabled?: boolean /** Why no memory id applies to this step, when the agent reads no memory. */ memoryUnusedNote?: string + /** What providing messages starts from: the list a legacy `manual` memory already sends, which the + * step's own messages replace at runtime. */ + seedMessages?: unknown[] /** The step's editor for one history input, with the error to show under it. */ field: Snippet<[AgentHistoryKey, string | undefined]> /** Called for each key this row removes, so the form forgets its validity. */ @@ -28,6 +31,7 @@ tooltip = undefined, chatInputEnabled = false, memoryUnusedNote = undefined, + seedMessages = undefined, field, onRemoveKey = undefined }: Props = $props() @@ -50,7 +54,12 @@ remove('memory_id') remove('messages') if (next === 'here') args.memory_id = { type: 'static', value: '' } - if (next === 'messages') args.messages = { type: 'static', value: [] } + if (next === 'messages') { + args.messages = { + type: 'static', + value: structuredClone($state.snapshot(seedMessages ?? [])) + } + } } @@ -59,7 +68,11 @@ {#if memoryUnusedNote} -

{memoryUnusedNote}

+ + {#if source !== 'messages'} +

{memoryUnusedNote}

+ {/if} {#if source === 'here'}
Ignored diff --git a/frontend/src/lib/components/flows/content/AiAgentStepInputs.svelte b/frontend/src/lib/components/flows/content/AiAgentStepInputs.svelte index ae4dc861a8..d5b89b7f12 100644 --- a/frontend/src/lib/components/flows/content/AiAgentStepInputs.svelte +++ b/frontend/src/lib/components/flows/content/AiAgentStepInputs.svelte @@ -174,6 +174,18 @@ return linkedMemory ? memoryIdUnusedNote(linkedMemory.memory) : undefined }) + // The messages a legacy `manual` memory sends, so providing messages on the step starts from them + // rather than from an empty list that would silently drop them. + let manualMemoryMessages = $derived.by(() => { + const memory: any = + 'memory' in schemaProperties + ? args?.memory?.type === 'static' + ? args.memory.value + : undefined + : linkedMemory?.memory + return memory?.kind === 'manual' ? (memory.messages as unknown[] | undefined) : undefined + }) + let scopedFields = $derived( AGENT_FIELDS.filter( (spec) => @@ -416,6 +428,7 @@ tooltip={spec.tooltip} {chatInputEnabled} {memoryUnusedNote} + seedMessages={manualMemoryMessages} onRemoveKey={(key) => delete inputCheck[key]} > {#snippet field(key, error)}