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/executor): OrchestratorBlock dry-run credentials + Responses API status field (#12709)
Zamil Majdy6552d9bfdd0b
diff --git a/autogpt_platform/backend/backend/blocks/orchestrator.py b/autogpt_platform/backend/backend/blocks/orchestrator.pyindex 8f9037cc72..6bdbf9acb3 100644--- a/autogpt_platform/backend/backend/blocks/orchestrator.py+++ b/autogpt_platform/backend/backend/blocks/orchestrator.py@@ -251,8 +251,13 @@ def _convert_raw_response_to_dict(# Already a dict (from tests or some providers)return raw_responseelif _is_responses_api_object(raw_response):- # OpenAI Responses API: extract individual output items- items = [json.to_dict(item) for item in raw_response.output]+ # OpenAI Responses API: extract individual output items.+ # Strip 'status' — it's a response-only field that OpenAI rejects+ # when the item is sent back as input on the next API call.+ items = [+ {k: v for k, v in json.to_dict(item).items() if k != "status"}+ for item in raw_response.output+ ]return items if items else [{"role": "assistant", "content": ""}]else:# Chat Completions / Anthropic return message objectsdiff --git a/autogpt_platform/backend/backend/blocks/test/test_orchestrator_responses_api.py b/autogpt_platform/backend/backend/blocks/test/test_orchestrator_responses_api.pyindex b14e24e39f..f9ec7676ba 100644--- a/autogpt_platform/backend/backend/blocks/test/test_orchestrator_responses_api.py+++ b/autogpt_platform/backend/backend/blocks/test/test_orchestrator_responses_api.py@@ -211,6 +211,30 @@ class TestConvertRawResponseToDict:# A single dict is wrong — there are two distinct itemspytest.fail("Expected a list of output items, got a single dict")+ def test_responses_api_strips_status_from_function_call(self):+ """Responses API function_call items have a 'status' field that OpenAI+ rejects when sent back as input ('Unknown parameter: input[N].status').+ It must be stripped before the item is stored in conversation history."""+ resp = _MockResponse(+ output=[_MockFunctionCall("my_tool", '{"x": 1}', call_id="call_xyz")]+ )+ result = _convert_raw_response_to_dict(resp)+ assert isinstance(result, list)+ for item in result:+ assert (+ "status" not in item+ ), f"'status' must be stripped from Responses API items: {item}"++ def test_responses_api_strips_status_from_message(self):+ """Responses API message items also carry 'status'; it must be stripped."""+ resp = _MockResponse(output=[_MockOutputMessage("Hello")])+ result = _convert_raw_response_to_dict(resp)+ assert isinstance(result, list)+ for item in result:+ assert (+ "status" not in item+ ), f"'status' must be stripped from Responses API items: {item}"+# ───────────────────────────────────────────────────────────────────────────# _get_tool_requests (lines 61-86)diff --git a/autogpt_platform/backend/backend/executor/manager.py b/autogpt_platform/backend/backend/executor/manager.pyindex 318f034ea6..3a51682b51 100644--- a/autogpt_platform/backend/backend/executor/manager.py+++ b/autogpt_platform/backend/backend/executor/manager.py@@ -307,9 +307,18 @@ async def execute_node(# Handle regular credentials fieldsfor field_name, input_type in input_model.get_credentials_fields().items():- # Dry-run platform credentials bypass the credential store+ # Dry-run platform credentials bypass the credential store.+ # Keep the existing credential metadata so _execute's input_schema(**...)+ # doesn't fail on the required field. If no metadata is present,+ # synthesize a minimal placeholder from the platform credentials.if _dry_run_creds is not None:- input_data[field_name] = None+ if input_data.get(field_name) is None:+ input_data[field_name] = {+ "id": _dry_run_creds.id,+ "provider": _dry_run_creds.provider,+ "type": _dry_run_creds.type,+ "title": _dry_run_creds.title,+ }extra_exec_kwargs[field_name] = _dry_run_credscontinuediff --git a/autogpt_platform/backend/backend/executor/simulator_test.py b/autogpt_platform/backend/backend/executor/simulator_test.pyindex 4ef4bff8ed..2b9b9f9a34 100644--- a/autogpt_platform/backend/backend/executor/simulator_test.py+++ b/autogpt_platform/backend/backend/executor/simulator_test.py@@ -18,6 +18,7 @@ from backend.executor.simulator import (_truncate_input_values,_truncate_value,build_simulation_prompt,+ get_dry_run_credentials,prepare_dry_run,simulate_block,)@@ -234,6 +235,42 @@ class TestPrepareDryRun:assert result is None+class TestGetDryRunCredentials:+ """get_dry_run_credentials pops _dry_run_api_key and returns APIKeyCredentials.++ The returned object must have fields that can be serialised into a valid+ CredentialsMetaInput placeholder dict for manager.py's schema-construction fix+ (Bug: manager.py nullified input_data[field_name] = None, which caused+ _execute's input_schema(**...) to fail because required credential fields were+ missing after the None-filter pass).+ """++ def test_returns_credentials_when_key_present(self) -> None:+ input_data = {"_dry_run_api_key": "sk-or-test", "other": "val"}+ creds = get_dry_run_credentials(input_data)+ assert creds is not None+ assert creds.api_key.get_secret_value() == "sk-or-test"+ # key is consumed from input_data+ assert "_dry_run_api_key" not in input_data++ def test_returns_none_when_key_absent(self) -> None:+ input_data: dict = {"other": "val"}+ creds = get_dry_run_credentials(input_data)+ assert creds is None++ def test_credentials_have_metadata_fields_for_placeholder(self) -> None:+ """The returned credentials must have id, provider, type, and title so+ manager.py can synthesise a valid CredentialsMetaInput placeholder."""+ from backend.integrations.providers import ProviderName++ creds = get_dry_run_credentials({"_dry_run_api_key": "sk-or-test"})+ assert creds is not None+ assert creds.id == "dry-run-platform"+ assert creds.provider == ProviderName.OPEN_ROUTER+ assert creds.type == "api_key"+ assert creds.title is not None++# ---------------------------------------------------------------------------# simulate_block – input/output passthrough# ---------------------------------------------------------------------------