diff --git a/src/claude_agent_sdk/_internal/query.py b/src/claude_agent_sdk/_internal/query.py index 76460100..1f549c7c 100644 --- a/src/claude_agent_sdk/_internal/query.py +++ b/src/claude_agent_sdk/_internal/query.py @@ -233,14 +233,10 @@ async def _handle_control_request(self, request: SDKControlRequest) -> None: # Convert PermissionResult to expected dict format if isinstance(response, PermissionResultAllow): - response_data = { - "behavior": "allow", - "updatedInput": ( - response.updated_input - if response.updated_input is not None - else original_input - ), - } + response_data = {"behavior": "allow"} + # Only include updatedInput if explicitly provided by the user + if response.updated_input is not None: + response_data["updatedInput"] = response.updated_input if response.updated_permissions is not None: response_data["updatedPermissions"] = [ permission.to_dict() diff --git a/tests/test_tool_callbacks.py b/tests/test_tool_callbacks.py index 8ace3c8d..7811406e 100644 --- a/tests/test_tool_callbacks.py +++ b/tests/test_tool_callbacks.py @@ -96,6 +96,13 @@ async def allow_callback( response = transport.written_messages[0] assert '"behavior": "allow"' in response + # IMPORTANT: Verify updatedInput is NOT included when not provided + # This is the regression test for issue #1063 + assert '"updatedInput"' not in response, ( + "updatedInput should not be included when PermissionResultAllow() " + "is returned without updated_input parameter" + ) + @pytest.mark.asyncio async def test_permission_callback_deny(self): """Test callback that denies tool execution."""