mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(platform): fall back to simulation when dry-run credentials missing + poll execution details
Bug 1: OrchestratorBlock in dry-run fails with "credentials is a required property" when the user hasn't configured any LLM credentials. After prepare_dry_run overrides the model to gpt-4o-mini, the block still requires credentials. Now we check if required credentials fields are still empty after restoring from node defaults and fall back to LLM simulation instead of attempting real execution. Bug 2: WebSocket not showing real-time updates for dry-run executions due to a race condition — the execution can start and complete before the frontend subscribes to WebSocket events. Add refetchInterval polling (2s) on execution details while the graph is running so the frontend catches up on any missed events.
This commit is contained in:
@@ -286,6 +286,7 @@ async def execute_node(
|
||||
if execution_context.dry_run:
|
||||
_dry_run_input = prepare_dry_run(node_block, input_data)
|
||||
if _dry_run_input is not None:
|
||||
pre_dry_run_input = input_data # Save in case we need to fall back
|
||||
input_data = _dry_run_input
|
||||
# Restore credential fields from node defaults so the block can
|
||||
# acquire credentials during dry-run.
|
||||
@@ -296,6 +297,25 @@ async def execute_node(
|
||||
if default_value is not None and not input_data.get(field_name):
|
||||
input_data[field_name] = default_value
|
||||
|
||||
# If any required credentials fields are still missing after restoring
|
||||
# from node defaults, fall back to LLM simulation instead of attempting
|
||||
# real execution that would fail with "credentials is a required property".
|
||||
creds_fields = cast(
|
||||
type[BlockSchema], node_block.input_schema
|
||||
).get_credentials_fields()
|
||||
if creds_fields:
|
||||
missing_creds = any(
|
||||
not input_data.get(f)
|
||||
or (isinstance(input_data.get(f), dict) and not input_data[f].get("id"))
|
||||
for f in creds_fields
|
||||
)
|
||||
if missing_creds:
|
||||
log_metadata.info(
|
||||
"Dry-run: credentials not configured, falling back to simulation"
|
||||
)
|
||||
_dry_run_input = None
|
||||
input_data = pre_dry_run_input
|
||||
|
||||
# Last-minute fetch credentials + acquire a system-wide read-write lock to prevent
|
||||
# changes during execution. ⚠️ This means a set of credentials can only be used by
|
||||
# one (running) block at a time; simultaneous execution of blocks using same
|
||||
|
||||
@@ -56,6 +56,10 @@ export const useFlow = () => {
|
||||
flowExecutionID: parseAsString,
|
||||
});
|
||||
|
||||
const isGraphRunning = useGraphStore(
|
||||
useShallow((state) => state.isGraphRunning),
|
||||
);
|
||||
|
||||
const { data: executionDetails } = useGetV1GetExecutionDetails(
|
||||
flowID || "",
|
||||
flowExecutionID || "",
|
||||
@@ -63,6 +67,11 @@ export const useFlow = () => {
|
||||
query: {
|
||||
select: (res) => res.data as GetV1GetExecutionDetails200,
|
||||
enabled: !!flowID && !!flowExecutionID,
|
||||
// Poll while the graph is running to catch updates that arrive before
|
||||
// the WebSocket subscription is established (race condition on fast
|
||||
// executions like dry-runs). Stops once the execution reaches a
|
||||
// terminal state and isGraphRunning becomes false.
|
||||
refetchInterval: isGraphRunning ? 2000 : false,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user