mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-09 14:25:25 -05:00
Make agent graph execution durable by making it retriable. When it fails to retry, we should make the error visible to the UI. <img width="900" height="495" alt="image" src="https://github.com/user-attachments/assets/70e3e117-31e7-4704-8bdf-1802c6afc70b" /> <img width="900" height="407" alt="image" src="https://github.com/user-attachments/assets/78ca6c28-6cc2-4aff-bfa9-9f94b7f89f77" /> ### Changes 🏗️ * Make _on_graph_execution retriable * Increase retry count for failing db-manager RPC * Add test coverage for RPC failure retry ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] Allow graph execution retry
120 lines
3.2 KiB
TypeScript
120 lines
3.2 KiB
TypeScript
import React, {
|
|
useState,
|
|
forwardRef,
|
|
useImperativeHandle,
|
|
useMemo,
|
|
} from "react";
|
|
import { Node } from "@xyflow/react";
|
|
import { CustomNodeData } from "@/components/CustomNode";
|
|
import { RunnerInputDialog } from "@/components/runner-ui/RunnerInputUI";
|
|
import {
|
|
BlockUIType,
|
|
CredentialsMetaInput,
|
|
GraphMeta,
|
|
} from "@/lib/autogpt-server-api/types";
|
|
import RunnerOutputUI, {
|
|
OutputNodeInfo,
|
|
} from "@/components/runner-ui/RunnerOutputUI";
|
|
|
|
interface RunnerUIWrapperProps {
|
|
graph: GraphMeta;
|
|
nodes: Node<CustomNodeData>[];
|
|
graphExecutionError?: string | null;
|
|
saveAndRun: (
|
|
inputs: Record<string, any>,
|
|
credentialsInputs: Record<string, CredentialsMetaInput>,
|
|
) => void;
|
|
createRunSchedule: (
|
|
cronExpression: string,
|
|
scheduleName: string,
|
|
inputs: Record<string, any>,
|
|
credentialsInputs: Record<string, CredentialsMetaInput>,
|
|
) => Promise<void>;
|
|
}
|
|
|
|
export interface RunnerUIWrapperRef {
|
|
openRunInputDialog: () => void;
|
|
openRunnerOutput: () => void;
|
|
runOrOpenInput: () => void;
|
|
}
|
|
|
|
const RunnerUIWrapper = forwardRef<RunnerUIWrapperRef, RunnerUIWrapperProps>(
|
|
(
|
|
{ graph, nodes, graphExecutionError, saveAndRun, createRunSchedule },
|
|
ref,
|
|
) => {
|
|
const [isRunInputDialogOpen, setIsRunInputDialogOpen] = useState(false);
|
|
const [isRunnerOutputOpen, setIsRunnerOutputOpen] = useState(false);
|
|
|
|
const graphInputs = graph.input_schema.properties;
|
|
|
|
const graphOutputs = useMemo((): OutputNodeInfo[] => {
|
|
const outputNodes = nodes.filter(
|
|
(node) => node.data.uiType === BlockUIType.OUTPUT,
|
|
);
|
|
|
|
return outputNodes.map(
|
|
(node) =>
|
|
({
|
|
metadata: {
|
|
name: node.data.hardcodedValues.name || "Output",
|
|
description:
|
|
node.data.hardcodedValues.description ||
|
|
"Output from the agent",
|
|
},
|
|
result:
|
|
(node.data.executionResults as any)
|
|
?.map((result: any) => result?.data?.output)
|
|
.join("\n--\n") || "No output yet",
|
|
}) satisfies OutputNodeInfo,
|
|
);
|
|
}, [nodes]);
|
|
|
|
const openRunInputDialog = () => setIsRunInputDialogOpen(true);
|
|
const openRunnerOutput = () => setIsRunnerOutputOpen(true);
|
|
|
|
const runOrOpenInput = () => {
|
|
if (
|
|
Object.keys(graphInputs).length > 0 ||
|
|
Object.keys(graph.credentials_input_schema.properties).length > 0
|
|
) {
|
|
openRunInputDialog();
|
|
} else {
|
|
saveAndRun({}, {});
|
|
}
|
|
};
|
|
|
|
useImperativeHandle(
|
|
ref,
|
|
() =>
|
|
({
|
|
openRunInputDialog,
|
|
openRunnerOutput,
|
|
runOrOpenInput,
|
|
}) satisfies RunnerUIWrapperRef,
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<RunnerInputDialog
|
|
isOpen={isRunInputDialogOpen}
|
|
doClose={() => setIsRunInputDialogOpen(false)}
|
|
graph={graph}
|
|
doRun={saveAndRun}
|
|
doCreateSchedule={createRunSchedule}
|
|
/>
|
|
<RunnerOutputUI
|
|
isOpen={isRunnerOutputOpen}
|
|
doClose={() => setIsRunnerOutputOpen(false)}
|
|
outputs={graphOutputs}
|
|
graphExecutionError={graphExecutionError}
|
|
/>
|
|
</>
|
|
);
|
|
},
|
|
);
|
|
|
|
RunnerUIWrapper.displayName = "RunnerUIWrapper";
|
|
|
|
export default RunnerUIWrapper;
|