Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend): show all agent outputs instead of only the last one (#12504)

lif3c046eb291dd
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderActions/components/AgentOutputs/AgentOutputs.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderActions/components/AgentOutputs/AgentOutputs.tsx
index 8ec1ba8be3..5a4c2dc9ae 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderActions/components/AgentOutputs/AgentOutputs.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderActions/components/AgentOutputs/AgentOutputs.tsx
@@ -39,39 +39,49 @@ export const AgentOutputs = ({ flowID }: { flowID: string | null }) => {
return outputNodes
.map((node) => {
const executionResults = node.data.nodeExecutionResults || [];
- const latestResult =
- executionResults.length > 0
- ? executionResults[executionResults.length - 1]
- : undefined;
- const outputData = latestResult?.output_data?.output;
- const renderer = globalRegistry.getRenderer(outputData);
+ const items = executionResults
+ .filter((result) => result.output_data?.output !== undefined)
+ .map((result) => {
+ const outputData = result.output_data!.output;
+ const renderer = globalRegistry.getRenderer(outputData);
+ return {
+ nodeExecID: result.node_exec_id,
+ value: outputData,
+ renderer,
+ };
+ })
+ .filter(
+ (
+ item,
+ ): item is typeof item & {
+ renderer: NonNullable<typeof item.renderer>;
+ } => item.renderer !== null,
+ );
+
+ if (items.length === 0) return null;
return {
+ nodeID: node.id,
metadata: {
name: node.data.hardcodedValues?.name || "Output",
description:
node.data.hardcodedValues?.description || "Output from the agent",
},
- value: outputData ?? "No output yet",
- renderer,
+ items,
};
})
- .filter(
- (
- output,
- ): output is typeof output & {
- renderer: NonNullable<typeof output.renderer>;
- } => output.renderer !== null,
- );
+ .filter((group): group is NonNullable<typeof group> => group !== null);
}, [nodes]);
const actionItems = useMemo(() => {
- return outputs.map((output) => ({
- value: output.value,
- metadata: {},
- renderer: output.renderer,
- }));
+ return outputs.flatMap((group) =>
+ group.items.map((item) => ({
+ value: item.value,
+ metadata: group.metadata,
+ renderer: item.renderer,
+ })),
+ );
}, [outputs]);
return (
@@ -116,24 +126,27 @@ export const AgentOutputs = ({ flowID }: { flowID: string | null }) => {
<ScrollArea className="h-full overflow-auto pr-4">
<div className="space-y-6">
{outputs && outputs.length > 0 ? (
- outputs.map((output, i) => (
- <div key={i} className="space-y-2">
+ outputs.map((group) => (
+ <div key={group.nodeID} className="space-y-2">
<div>
<Label className="text-base font-semibold">
- {output.metadata.name || "Unnamed Output"}
+ {group.metadata.name || "Unnamed Output"}
</Label>
- {output.metadata.description && (
+ {group.metadata.description && (
<Label className="mt-1 block text-sm text-gray-600">
- {output.metadata.description}
+ {group.metadata.description}
</Label>
)}
</div>
- <OutputItem
- value={output.value}
- metadata={{}}
- renderer={output.renderer}
- />
+ {group.items.map((item) => (
+ <OutputItem
+ key={item.nodeExecID}
+ value={item.value}
+ metadata={group.metadata}
+ renderer={item.renderer}
+ />
+ ))}
</div>
))
) : (