From 7f7bf72da89e035f631f01a8e4a5704c1b5faf8c Mon Sep 17 00:00:00 2001 From: hugocasa Date: Fri, 11 Sep 2026 12:09:16 +0200 Subject: [PATCH] fix: move the agent meta line and system prompt below the conversation Co-Authored-By: Claude Opus 5 (1M context) --- .../lib/components/AgentResultDisplay.svelte | 40 +++++++++---------- .../src/lib/components/AgentTranscript.svelte | 30 +++++++++----- .../src/lib/components/FlowJobResult.svelte | 34 +++++----------- .../ModulePreviewResultViewer.svelte | 10 ----- 4 files changed, 49 insertions(+), 65 deletions(-) diff --git a/frontend/src/lib/components/AgentResultDisplay.svelte b/frontend/src/lib/components/AgentResultDisplay.svelte index 237f85854a..dab8865f16 100644 --- a/frontend/src/lib/components/AgentResultDisplay.svelte +++ b/frontend/src/lib/components/AgentResultDisplay.svelte @@ -1,5 +1,4 @@ - -
+
+ {#if view === 'transcript'} + + {:else if textOutput !== undefined} + {#if textOutput === ''} + The agent returned no answer + {:else} + + + {/if} + {:else} + {@render structuredOutput(result.output)} + {/if} + +
- {#if summary.toolCalls > 0} {summary.toolCalls} @@ -51,20 +65,4 @@ {formatTokenCount(summary.cachedTokens)} cached {/if}
- - {#if view === 'transcript'} - - {:else if textOutput !== undefined} - {#if textOutput === ''} - The agent returned no answer - {:else} - - - {/if} - {:else} - {@render structuredOutput(result.output)} - {/if}
diff --git a/frontend/src/lib/components/AgentTranscript.svelte b/frontend/src/lib/components/AgentTranscript.svelte index 8c1b8ba02b..cc9ac194c8 100644 --- a/frontend/src/lib/components/AgentTranscript.svelte +++ b/frontend/src/lib/components/AgentTranscript.svelte @@ -19,8 +19,15 @@ let { messages, workspaceId }: Props = $props() - let entries = $derived(buildTranscript(messages)) + const all = $derived(buildTranscript(messages)) + // The prompt is the run's configuration, not its opening line: it is the same + // on every run of the step, and reading the conversation from it buries what + // the user actually asked. Kept reachable, at the end. + const entries = $derived(all.filter((entry) => entry.kind !== 'system')) + const systemPrompt = $derived(all.find((entry) => entry.kind === 'system')) + // Out of the entry index space, since the prompt is rendered outside the list. + const SYSTEM_PROMPT_KEY = -1 let expanded = new SvelteSet() // A tool's own job holds what the envelope does not: its logs, how long it // took, and whether it succeeded. Fetched when a row is opened rather than @@ -89,16 +96,6 @@
{/if} - {:else if entry.kind === 'system'} -
- toggle(index, entry)} - > -
{entry.content}
-
-
{:else if entry.kind === 'search'}
{/if} {/each} + {#if systemPrompt} +
+ toggle(SYSTEM_PROMPT_KEY, systemPrompt)} + > +
{systemPrompt.content}
+
+
+ {/if}
diff --git a/frontend/src/lib/components/FlowJobResult.svelte b/frontend/src/lib/components/FlowJobResult.svelte index 3221ee06b5..346cd82519 100644 --- a/frontend/src/lib/components/FlowJobResult.svelte +++ b/frontend/src/lib/components/FlowJobResult.svelte @@ -3,8 +3,6 @@ import DisplayResult from './DisplayResult.svelte' import LogViewer from './LogViewer.svelte' import { twMerge } from 'tailwind-merge' - import AgentTranscript from './AgentTranscript.svelte' - import { parseAgentResult } from './aiAgentResult' interface Props { waitingForExecutor?: boolean @@ -36,10 +34,6 @@ downloadLogs = true, tagLabel = undefined }: Props = $props() - - // An agent step's own logs are worker chatter; what happened is its conversation. - // Derived from the result rather than passed in, so every caller gets it. - let agentResult = $derived(parseAgentResult(result))
- {agentResult ? 'Transcript' : 'Logs'} - {#if agentResult} -
- -
- {:else} -
- -
- {/if} + Logs +
+ +
diff --git a/frontend/src/lib/components/ModulePreviewResultViewer.svelte b/frontend/src/lib/components/ModulePreviewResultViewer.svelte index e1ae3915bb..fccb258b0d 100644 --- a/frontend/src/lib/components/ModulePreviewResultViewer.svelte +++ b/frontend/src/lib/components/ModulePreviewResultViewer.svelte @@ -10,8 +10,6 @@ import type { FlowEditorContext, OutputViewerJob } from './flows/types' import { getContext } from 'svelte' import { getStringError } from './copilot/chat/utils' - import AgentTranscript from './AgentTranscript.svelte' - import { parseAgentResult } from './aiAgentResult' interface Props { lang: Script['language'] @@ -57,10 +55,6 @@ ) const logJob = $derived(testJob ?? selectedJob) const preview = $derived.by(() => outputPickerInner?.getPreview?.()) - // The trace of an agent step is its conversation, which its own result carries. - const agentResult = $derived( - logJob?.type === 'CompletedJob' ? parseAgentResult(logJob.result) : undefined - ) @@ -105,10 +99,6 @@ customEmptyMessage="Using pinned data" {tagLabel} /> - {:else if agentResult} -
- -
{:else}