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(backend): resolve two critical long-running agent execution failures (#11011)

Zamil Majdyf314fbf14f5c
diff --git a/autogpt_platform/backend/backend/blocks/smart_decision_maker.py b/autogpt_platform/backend/backend/blocks/smart_decision_maker.py
index 743f83d62b..0275898c39 100644
--- a/autogpt_platform/backend/backend/blocks/smart_decision_maker.py
+++ b/autogpt_platform/backend/backend/blocks/smart_decision_maker.py
@@ -556,21 +556,42 @@ class SmartDecisionMakerBlock(Block):
None,
)
+ # Get parameters schema from tool definition
if (
tool_def
and "function" in tool_def
and "parameters" in tool_def["function"]
):
- expected_args = tool_def["function"]["parameters"].get("properties", {})
+ parameters = tool_def["function"]["parameters"]
+ expected_args = parameters.get("properties", {})
+ required_params = set(parameters.get("required", []))
else:
- expected_args = tool_args.keys()
-
- # Yield provided arguments and None for missing ones
+ expected_args = {arg: {} for arg in tool_args.keys()}
+ required_params = set()
+
+ # Validate tool call arguments and provide detailed error messages
+ provided_args = set(tool_args.keys())
+ expected_args_set = set(expected_args.keys())
+
+ # Check for unexpected arguments (typos)
+ unexpected_args = provided_args - expected_args_set
+ # Only check for missing REQUIRED parameters
+ missing_required_args = required_params - provided_args
+
+ if unexpected_args or missing_required_args:
+ error_msg = f"Tool call '{tool_name}' has parameter errors:"
+ if unexpected_args:
+ error_msg += f" Unknown parameters: {sorted(unexpected_args)}."
+ if missing_required_args:
+ error_msg += f" Missing required parameters: {sorted(missing_required_args)}."
+ error_msg += f" Expected parameters: {sorted(expected_args_set)}."
+ if required_params:
+ error_msg += f" Required parameters: {sorted(required_params)}."
+ raise ValueError(error_msg)
+
+ # Yield provided arguments, use .get() for optional parameters
for arg_name in expected_args:
- if arg_name in tool_args:
- yield f"tools_^_{tool_name}_~_{arg_name}", tool_args[arg_name]
- else:
- yield f"tools_^_{tool_name}_~_{arg_name}", None
+ yield f"tools_^_{tool_name}_~_{arg_name}", tool_args.get(arg_name)
# Add reasoning to conversation history if available
if response.reasoning:
diff --git a/autogpt_platform/backend/backend/executor/manager.py b/autogpt_platform/backend/backend/executor/manager.py
index 50436ef575..9bcece8416 100644
--- a/autogpt_platform/backend/backend/executor/manager.py
+++ b/autogpt_platform/backend/backend/executor/manager.py
@@ -1735,7 +1735,10 @@ async def synchronized(key: str, timeout: int = settings.config.cluster_lock_tim
yield
finally:
if await lock.locked() and await lock.owned():
- await lock.release()
+ try:
+ await lock.release()
+ except Exception as e:
+ logger.warning(f"Failed to release lock for key {key}: {e}")
def increment_execution_count(user_id: str) -> int:
diff --git a/autogpt_platform/backend/backend/integrations/creds_manager.py b/autogpt_platform/backend/backend/integrations/creds_manager.py
index e5ae0cdb72..f2b6a9da4f 100644
--- a/autogpt_platform/backend/backend/integrations/creds_manager.py
+++ b/autogpt_platform/backend/backend/integrations/creds_manager.py
@@ -151,7 +151,10 @@ class IntegrationCredentialsManager:
fresh_credentials = await oauth_handler.refresh_tokens(credentials)
await self.store.update_creds(user_id, fresh_credentials)
if _lock and (await _lock.locked()) and (await _lock.owned()):
- await _lock.release()
+ try:
+ await _lock.release()
+ except Exception as e:
+ logger.warning(f"Failed to release OAuth refresh lock: {e}")
credentials = fresh_credentials
return credentials
@@ -184,7 +187,10 @@ class IntegrationCredentialsManager:
yield
finally:
if (await lock.locked()) and (await lock.owned()):
- await lock.release()
+ try:
+ await lock.release()
+ except Exception as e:
+ logger.warning(f"Failed to release credentials lock: {e}")
async def release_all_locks(self):
"""Call this on process termination to ensure all locks are released"""